- Fastify + Typebox + TypeScript
- Generated Swagger Schema based on registered routes and Typebox schemas
- Swagger UI
npm run startand then, via httpie or cURL:- GET all users
http localhost:8080/users?name=Taylor - CREATE new user
http POST localhost:8080/users name=Alex - Check the generate Schema:
http GET http://localhost:8080/docs/json - View the Swagger UI
- GET all users
- Take care to always add routes inside a
.registerblock. Otherwise swagger does not seem to pick up on them.
npm init -ynpm i fastifynpm i -D typescript @types/node ts-nodenpx tsc --initand configureoutdir: "dist","target": "es2017"and other smaller things.mkdir src && touch src/index.tsand put code from fastify swagger.- Add
"build": "tsc"and"start": "ts-node src/server.ts"to package.json. npm i @sinclair/typebox @fastify/type-provider-typebox @fastify/swaggerand add /users with schema to src/index.ts according to the official docs