We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 915ae64 commit 599ec43Copy full SHA for 599ec43
examples/snippets/event-handler/rest/gettingStarted_route_prefix.ts
@@ -0,0 +1,15 @@
1
+declare function getUserTodos(auth: string | null): Promise<{ id: string }>;
2
+
3
+import { Router } from '@aws-lambda-powertools/event-handler/experimental-rest';
4
+import type { Context } from 'aws-lambda';
5
6
+const app = new Router({ prefix: '/todos' });
7
8
+// matches POST /todos
9
+app.post('/', async ({ req: { headers } }) => {
10
+ const todos = await getUserTodos(headers.get('Authorization'));
11
+ return { todos };
12
+});
13
14
+export const handler = async (event: unknown, context: Context) =>
15
+ app.resolve(event, context);
0 commit comments