This project is a RESTful API built with Node.js and Express, designed to manage logistics centers. It utilizes MongoDB for data storage and implements JWT for authentication. The API is versioned to ensure backward compatibility.
- CRUD operations for logistics centers
- JWT authentication for secure access
- Versioned API routes
node-express-api
├── src
│ ├── controllers # Contains controllers for handling requests
│ ├── models # Contains Mongoose models
│ ├── routes # Contains route definitions
│ ├── middlewares # Contains middleware functions
│ ├── utils # Contains utility functions
│ ├── app.js # Initializes the Express application
│ └── server.js # Starts the server
├── config # Configuration files
│ └── db.js # MongoDB connection configuration
├── package.json # NPM package configuration
├── .env # Environment variables
├── .gitignore # Files to ignore in Git
└── README.md # Project documentation
-
Clone the repository:
git clone <repository-url> cd node-express-api -
Install dependencies:
npm install -
Create a
.envfile in the root directory and add your MongoDB connection string and JWT secret:MONGODB_URI=<your_mongodb_connection_string> JWT_SECRET=<your_jwt_secret>
-
Start the server:
npm start -
The API will be running on
http://localhost:4000.
- GET /api/v1/logistics-centers: Retrieve all logistics centers
- GET /api/v1/logistics-centers/:id: Retrieve a logistics center by ID
- POST /api/v1/logistics-centers: Create a new logistics center
- PUT /api/v1/logistics-centers/:id: Update an existing logistics center
- DELETE /api/v1/logistics-centers/:id: Delete a logistics center
Feel free to submit issues or pull requests for improvements or bug fixes.
This project is licensed under the MIT License.