MCPcopy Create free account
hub / github.com/coordinape/coordinape / getUserSessionInput

Function getUserSessionInput

api-lib/handlerHelpers.ts:16–34  ·  view source on GitHub ↗
(
  req: VercelRequest,
  schema: InputSchema<T>
)

Source from the content-addressed store, hash-verified

14type ApiPermissions = ApiKeyPermission[] | 'block';
15
16async function getUserSessionInput<T extends z.ZodRawShape>(
17 req: VercelRequest,
18 schema: InputSchema<T>
19) {
20 const fullSchema = z.object({
21 action: z.object({ name: z.string() }),
22 input: z.object({ payload: schema }),
23 session_variables: HasuraUserSessionVariables,
24 request_query: z.string().optional(),
25 });
26
27 // this will throw if the input isn't valid
28 const { action, session_variables, input } = await fullSchema.parseAsync(
29 req.body
30 );
31 assert(input?.payload, 'input.payload is missing after parsing');
32
33 return { action, session: session_variables, payload: input.payload };
34}
35
36export async function getAnonInput<T extends z.ZodRawShape>(
37 req: VercelRequest,

Callers 2

wrapped1Method · 0.85
getInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected