A simple and secure RESTful API for managing Todo tasks, built with Fastify.
Simply run:
npm run compose
Don't forget to edit
.envfile variables likeJWT_SECRETwith your own secret in case you are using this in production.
First edit .env file to connect to your own Postgres database then run:
npm run dev
- JWT authentication
- Zod schema validation
- RESTful routes (CRUD)
- Type-safe
- Modular service-based architecture
- HATEOAS
- NodeJS
- Fastify
- PostgreSQL
- Docker
- Postgrator
- Zod
- fastify-jwt
You can import Postman collection file Todos API.postman_collection.json to your Postman and play with the API endpoints.
The collection has scripts handles saving and sending the JWT Token automatically.
All endpoints except /register and /login require a valid JWT token in the Authorization header (Bearer <token>).
{
"_links": {
"self": {
"href": "/api/todos"
},
"todo": {
"href": "/api/todos/:id"
}
},
"data": [
{
"id": 1,
"title": "Todo 1",
"description": null,
"completed": false,
"created_at": "2025-07-02T08:42:48.481Z",
"updated_at": "2025-07-02T08:42:48.481Z",
"user_id": 6
},
{
"id": 3,
"title": "Todo 2",
"description": "Some task",
"completed": false,
"created_at": "2025-07-02T10:04:58.281Z",
"updated_at": "2025-07-02T10:04:58.281Z",
"user_id": 6
}
]
}Response:
{
"_links": {
"self": {
"href": "/api/todos/3"
}
},
"data": {
"id": 2,
"title": "Todo 2",
"description": "Some task",
"completed": false,
"created_at": "2025-07-02T10:04:58.281Z",
"updated_at": "2025-07-02T10:04:58.281Z",
"user_id": 6
}
}