Skip to content

Commit

Permalink
finished migrating the GET and POST methods for the todos route
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoluizpoli committed Oct 11, 2023
1 parent a7969fd commit 90401c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
20 changes: 1 addition & 19 deletions app/api/todos/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,5 @@ export const GET = async (request: Request) => {
};

export const POST = async (request: Request) => {
await todoController.create(request);
return await todoController.create(request);
};

// import { NextApiRequest, NextApiResponse } from 'next';

// const handler = async (request: NextApiRequest, response: NextApiResponse) => {
// if (request.method === 'GET') {
// return;
// }

// if (request.method === 'POST') {
// return;
// }
// response.status(405).json({
// error: {
// message: 'Method not allowed',
// },
// });
// };
// export default handler;
2 changes: 1 addition & 1 deletion src/server/controller/todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TodoCreateBodySchema = z.object({
content: z.string(),
});
const create = async (req: Request) => {
const parsedBody = TodoCreateBodySchema.safeParse(req.body);
const parsedBody = TodoCreateBodySchema.safeParse(await req.json());
if (!parsedBody.success) {
return new NextResponse(
JSON.stringify({
Expand Down

0 comments on commit 90401c6

Please sign in to comment.