Getting Started with Fastify-CLI
This project was bootstrapped with Fastify-CLI and includes additional features for authentication, authorization, validation, and API documentation.
- JWT Authentication: Secure your endpoints with JSON Web Token-based authentication.
- Role-Based Authorization: Control access to resources based on user roles.
- Zod Validation: Ensure data integrity with Zod schema validation.
- Swagger Documentation: Automatically generate and serve API documentation using Swagger UI.
In the project directory, you can run:
Starts the app in development mode.
Open http://localhost:3000 to view it in the browser.
Runs the app in production mode.
Executes the test cases.
Once the server is running, you can access the Swagger UI documentation at:
http://localhost:3000/documentation
This provides an interactive interface to explore and test your API endpoints.
To authenticate, obtain a JWT token by sending a POST request to the /login
endpoint with valid credentials. Include this token in the Authorization
header of subsequent requests:
Authorization: Bearer <your_jwt_token>
Endpoints are protected based on user roles. Ensure your JWT token includes the appropriate role claims to access restricted resources.
Request and response payloads are validated using Zod schemas. Refer to the API documentation for the expected data structures.