Skip to content

Commit

Permalink
feat: update hello-world route to JSON:API format
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Jan 29, 2024
1 parent b274d11 commit da50fb9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions skeleton/base/src/route/hello-world/foo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { z } from "zod";
import { parseBody, parseQuery } from "../../util/zod.js";

const getHelloWorld = (context: Context) => {
context.body = { message: "hello-world" };
context.body = {
data: {
message: "hello-world",
},
};
};

const listQuerySchema = z.object({
Expand All @@ -14,18 +18,18 @@ const listQuerySchema = z.object({
const listHelloWorld = (context: Context) => {
const query = parseQuery(listQuerySchema, context);

context.body = { foo: query.foo };
context.body = { data: { foo: query.foo } };
};

const listPostSchema = z.object({
const postSchema = z.object({
foo: z.string(),
});

const postHelloWorld = (context: Context) => {
const input = parseBody(listPostSchema, context);
const input = parseBody(postSchema, context);

context.status = 201;
context.body = { foo: input.foo };
context.body = { data: { foo: input.foo } };
};

export const registerFooRoutes = (router: Router): void => {
Expand Down

0 comments on commit da50fb9

Please sign in to comment.