This project is a Node.js API server with CRUD operations for managing a collection of APIs. The API uses MongoDB as the database.
- Create, Read, Update, and Delete API in the MongoDB database.
- Uses Express.js for the server and Mongoose for MongoDB interactions.
Follow these instructions to set up and run the project on your local machine.
-
Clone the repository:
git clone https://github.com/yourusername/rest-api-server.git cd rest-api-server
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add your MongoDB connection string and the port number:MONGODB_URI=mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority PORT=3000
-
Seed the database (optional):
To seed the database with initial data, run:
npm run data:import
To destroy the seeded data, run:
npm run data:destroy
Start the server in development mode with:
npm run dev
http://localhost:3000/api/create
http://localhost:3000/api/getAll
http://localhost:3000/api/[give_id]
http://localhost:3000/api/update/[give_id]
http://localhost:3000/api/delete/[give_id]