From dd7090c28ddc7ae205a9318da8a2394b6a9b5759 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 16 Sep 2024 10:53:52 +0200 Subject: [PATCH] Add a POST route --- .../api/app/api/hello/{route.js => route.ts} | 4 ++++ examples/api/tsconfig.json | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) rename examples/api/app/api/hello/{route.js => route.ts} (70%) create mode 100644 examples/api/tsconfig.json diff --git a/examples/api/app/api/hello/route.js b/examples/api/app/api/hello/route.ts similarity index 70% rename from examples/api/app/api/hello/route.js rename to examples/api/app/api/hello/route.ts index aebcdfc76..b4028c87f 100644 --- a/examples/api/app/api/hello/route.js +++ b/examples/api/app/api/hello/route.ts @@ -6,3 +6,7 @@ export async function GET() { const sayHi = !!headersList.get("should-say-hi"); return new Response(sayHi ? "Hi World!" : "Hello World!"); } + +export async function POST(request: Request) { + return new Response(`Hello post-World! body=${await request.text()}`); +} diff --git a/examples/api/tsconfig.json b/examples/api/tsconfig.json new file mode 100644 index 000000000..174c9f3c8 --- /dev/null +++ b/examples/api/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "noEmit": true, + "incremental": true, + "module": "esnext", + "esModuleInterop": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "plugins": [ + { + "name": "next" + } + ] + }, + "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +}