This repository contains a simple Node.js CRUD (Create, Read, Update, Delete) application with APIs. This application allows you to perform basic CRUD operations on a collection of items.
- Create: Add new items to the collection.
- Read: Retrieve all items or a specific item from the collection.
- Update: Update the details of an existing item.
- Delete: Remove an item from the collection.
Before running this application, make sure you have the following installed:
- Node.js
- npm (Node Package Manager)
- MongoDB
- Mongoose
- REST APIs
- nodemon
- Express
- Clone this repository to your local machine:
git clone https://github.com/your_username/nodejs-crud-app.git
- Navigate to the project directory:
cd nodejs-crud-app
- Install dependencies:
npm install
-
Set up your environment variables:
-
Create a
.env
file in the root directory. -
Define the following environment variables in the
.env
file:PORT=8080 MONGODB_URI=your_mongodb_connection_uri
Replace
your_mongodb_connection_uri
with your MongoDB connection URI.
-
- Start the server:
npm start index.js
- Once the server is running, you can use your preferred API testing tool (e.g., Postman) to interact with the APIs.
- GET /items: Get all items.
- GET /items/:id: Get item by ID.
- POST /items: Create a new item.
- PUT /items/:id: Update an existing item.
- DELETE /items/:id: Delete an item by ID.