Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chuongtrh/fastify-list-routes
A simple plugin for Fastify list all available routes.
https://github.com/chuongtrh/fastify-list-routes
fastify router
Last synced: about 2 months ago
JSON representation
A simple plugin for Fastify list all available routes.
- Host: GitHub
- URL: https://github.com/chuongtrh/fastify-list-routes
- Owner: chuongtrh
- License: mit
- Created: 2022-10-27T04:53:03.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-28T14:22:59.000Z (about 2 years ago)
- Last Synced: 2024-10-14T11:47:22.175Z (2 months ago)
- Topics: fastify, router
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fastify-list-routes
- Size: 18.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A simple plugin for Fastify list all available routes.
## Installation
```base
npm i fastify-list-routes
``````base
yarn add fastify-list-routes
```## Usage
Try to register a plugin as early as possible before register routes.
- `colors`: If to use colors to highlight routes.
## Example
```js
const fastify = require("fastify")();
const fastifyListRoutes = require("fastify-list-routes");async function run() {
await fastify.register(fastifyListRoutes, { colors: true });fastify.get("/", (request, reply) => {
reply.send({ hello: "world" });
});fastify.get("/path1/:id", {
async handler() {
return { ok: true };
},
});fastify.post("/path2", {
async handler() {
return { ok: true };
},
});fastify.register(require("./demo"), { prefix: "/demo" });
fastify.listen({ port: 3000 }, (err, address) => {
if (err) throw err;console.log(`Server is now listening on ${address}`);
});
}
run();
```Result when started successfully
![](screenshot.png)
## License
MIT