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

Function getUserOrAdminSessionInput

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

Source from the content-addressed store, hash-verified

53// FIXME there's probably a better way to get typing to work than
54// almost-duplicating the method above
55async function getUserOrAdminSessionInput<T extends z.ZodRawShape>(
56 req: VercelRequest,
57 schema: InputSchema<T>
58) {
59 const fullSchema = z.object({
60 action: z.object({ name: z.string() }),
61 input: z.object({ payload: schema }),
62 session_variables: HasuraUserOrAdminSessionVariables,
63 request_query: z.string().optional(),
64 });
65
66 // this will throw if the input isn't valid
67 const { action, session_variables, input } = await fullSchema.parseAsync(
68 req.body
69 );
70 assert(input?.payload, 'input.payload is missing after parsing');
71
72 return { action, session: session_variables, payload: input.payload };
73}
74
75async function getUserSessionNoInput(req: VercelRequest) {
76 const fullSchema = z.object({

Callers 2

wrapped3Method · 0.85
getInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected