A template project for building a Node.js API using Fastify and MongoDB, with user CRUD operations, JWT authentication, and other basic CRUD functionalities.
- Features
- Prerequisites
- Getting Started
- API Documentation
- Live Demo
- Dependencies
- Dev Dependencies
- License
- User CRUD operations (Create, Read, Update, Delete)
- User registration and login with JWT authentication
- MongoDB integration for data storage
- API documentation with Swagger UI
- CORS configuration for cross-origin requests
- Node.js v18.x
- MongoDB instance (local or remote)
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/WillishakespeareSKR13/Template-Node-Fastify-Mongo.git cd Template-Node-Fastify-Mongo
-
Install dependencies:
yarn install
The application can be configured through the config.ts
file in the root directory. Modify the configuration according to your needs:
- APP: Configuration related to the application, such as port, host, environment, logger, and JWT secret.
- DB: Database configuration, including MongoDB URI, host, port, and database name.
-
Start the application in development mode:
yarn run dev
-
Build and run the application in production mode:
yarn run build yarn start
API documentation is available using Swagger UI. Once the application is running, you can access the documentation at:
A live demo of the application is available at:
Documentation for the live demo is available at:
- @fastify/cors
- @fastify/jwt
- @fastify/swagger
- @fastify/swagger-ui
- @hapi/boom
- bcryptjs
- dotenv
- fastify
- mongoose
- zod
- zod-to-json-schema
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to use the code, and if you do, please give me credit.