Routing
Table of contents
- Methods
- Parameters
- Request typing
- Grouping
- Middlewares
- Per route
- Per group
- Globally
- Error handlers
- Stand-alone usage
- Installation
- Example server
Methods
Parameters
Request typing
It’s possible to define types for your parameters, query and body.
Grouping
Middlewares
Having middlewares is as easy as adding more handlers to a route.
Middlewares will be executed by the order you define them.
Stopping the chain of execution
The chain of execution will be ended when a response is sent by methods like: sendStatus(), send() or json()
.
Per route
Per group
Globally
Error handlers
You can define error handlers the same way as middlewares, the signature is slightly different. Also for error handlers, the order is respected.
Stand-alone usage
Installation
npm install @serverless-framework/router
Example server
Below is a simple example that uses Node’s build-in http server.