Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shubhamch95/cars-management-api
This is a RESTful API example based on Node.js, Express.js and MongoDB
https://github.com/shubhamch95/cars-management-api
body-parser dotenv express-js javascript mongodb mongoose node-js nodemon rest-api
Last synced: 29 days ago
JSON representation
This is a RESTful API example based on Node.js, Express.js and MongoDB
- Host: GitHub
- URL: https://github.com/shubhamch95/cars-management-api
- Owner: shubhamch95
- Created: 2023-11-27T17:05:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-01T13:12:39.000Z (about 1 year ago)
- Last Synced: 2023-12-01T14:27:13.432Z (about 1 year ago)
- Topics: body-parser, dotenv, express-js, javascript, mongodb, mongoose, node-js, nodemon, rest-api
- Language: JavaScript
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cars-management-api
Node.js REST API with MongoDB This is a simple Node.js REST API project using Express.js and MongoDB for managing a collection of cars.
## Getting Started
**Clone the repository:**
**git clone** https://github.com/shubhamch95/cars-management-api
**cd** /cars-management-api## Install dependencies:
**npm install**Create a .env file in the root directory and add your MongoDB connection URL and the desired port:
**PORT**=2000
**DB_CONNECTION_URL**=mongodb://127.0.0.1:27017/yourdatabase## Start the server:
**npm start**
The server will run on the specified port, and you should see "Server is Running Fine.!!" in the console.
## Project Structure:
* **index.js:** The main entry point of the application where the Express app is configured and the server is started.
* **models/model.js:** Defines the Mongoose schema for the cars collection.
* **routers/routes.js:** Contains the Express routes for handling CRUD operations on the cars collection.## API Endpoints:
**Get All Cars URL:**
/api/v1/
Method: GET
Description: Get a list of all cars.**Get Single Car URL:**
/api/v1/:carId
Method: GET
Description: Get details of a single car by its ID.**Create a New Car URL:**
/api/v1/
Method: POST
Description: Create a new car. Requires a JSON body with car details.**Example JSON body:**
{
"brand": "Toyota",
"type": "Sedan",
"year": 2022,
"price": 25000,
"color": "Blue"
}## Database Connection:
The project uses Mongoose to connect to a MongoDB database.
The connection URL is specified in the .env file.
**DB_CONNECTION_URL**=mongodb://127.0.0.1:27017/yourdatabase## Contributing:
Feel free to contribute to the project by opening issues or creating pull requests.
Your feedback and contributions are highly appreciated!