https://github.com/nlang/sls-lambda-router
Another router for aws-lambda
https://github.com/nlang/sls-lambda-router
api-gateway aws-lambda serverless
Last synced: 3 months ago
JSON representation
Another router for aws-lambda
- Host: GitHub
- URL: https://github.com/nlang/sls-lambda-router
- Owner: nlang
- License: mit
- Created: 2017-05-11T17:08:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-22T16:37:34.000Z (about 4 years ago)
- Last Synced: 2025-10-02T09:45:56.247Z (6 months ago)
- Topics: api-gateway, aws-lambda, serverless
- Language: TypeScript
- Size: 156 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serverless Lambda Router
> A router for AWS Lambda serverless applications written in TypeScript that makes use
of `@Decorators` to register resource handlers and stuff.
## Usage
(more details to come)
```typescript
/** play.resource.ts **/
export class PlayResource {
@GET(["/my/api/v1/play/:game"])
public playGame(@HttpEvent event: APIGatewayEvent,
@PathParam("game") game: string): Promise {
const game = Game.get(game);
return game.start().then((res) => {
return Response.ok(res, "application/json");
}).catch ((err) => {
throw new BadRequestException(err);
});
}
/** handler.ts **/
class Appllication {
public handler(event: APIGatewayEvent, context: Context, callback: Callback) {
this.router.registerResource(new PlayResource());
this.router.route(event, context, callback).then(() => {
// some final stuff if everything went well
}).catch((err) => {
// some final stuff if something went wrong
});
}
}
```