When implementing TypeScript code that uses the axum package, maintain consistent and idiomatic usage:
Router
, Middleware
, and RequestBody
.task_local
to pass state between middleware and handlers.Example of correct axum usage in TypeScript:
```typescript import { Router, RequestBody } from ‘@awslabs/aws-lambda-typescript-runtime’;
const router = new Router();
router.get(‘/’, (req) => { return { message: ‘Hello, axum!’ }; });
router.post(‘/users’, async (req: RequestBody<{ name: string }>) => { const { name } = req.body; // Handle user creation logic here return { id: 1, name }; });
export default router;
Enter the URL of a public GitHub repository