Skip to content

Commit

Permalink
Show off simple schema parsing of query params
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterKale committed Aug 9, 2024
1 parent 9177e6e commit 2dd60c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/handlers/handleCreateRegOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Context } from 'hono';
import { zfd } from 'zod-form-data';

import { regOptionsInputSchema } from '../schemas';


/**
* Generate registration options
*/
export async function handleCreateRegOptions(context: Context): Promise<Response> {
return context.text('handleCreateRegOptions');
const parsedInput = zfd.formData(regOptionsInputSchema).parse(context.req.query());
console.log(parsedInput);
return context.text(`handleCreateRegOptions ${JSON.stringify(parsedInput)}`);
}
4 changes: 3 additions & 1 deletion src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export { ZodError } from 'zod';
/**
* Schema for incoming query params to configure registration options
*/
export const regOptionsInputSchema = z.object({});
export const regOptionsInputSchema = z.object({
foo: z.string().optional(),
});


/**
Expand Down

0 comments on commit 2dd60c3

Please sign in to comment.