This is a RESTful API built using Node.js, TypeScript, Express, and MongoDB. It follows best practices for clean code, scalability, and maintainability.
- TypeScript for static typing and improved maintainability
- Express.js for handling HTTP requests
- MongoDB with Mongoose for database management
- Environment variable management using dotenv
- API request validation with Joi
- Centralized error handling and logging
- CRUD operations for a sample resource
Ensure you have the following installed:
- Node.js (v16+ recommended)
- MongoDB
- Clone the repository:
- Install dependencies:
- Create a .env file in the root directory and define the following environment variables:
- Start the development server:
- npm run dev - Starts the development server with nodemon
- npm run build - Compiles TypeScript into JavaScript
- npm start - Runs the production build
- GET /api/health
- Response:
- GET /api/users - Fetch all users
- POST /api/users - Create a new user
- GET /api/users/:id - Get a specific user by ID
- PUT /api/users/:id - Update user information
- DELETE /api/users/:id - Delete a user
This project is licensed under the MIT License.
Contributions are welcome! Feel free to open an issue or submit a pull request.
For inquiries, reach out at email@example.com.