https://github.com/douaaaaa/simple-crud-api-backend
CRUD API built using Node JS, Express JS and MongoDB
https://github.com/douaaaaa/simple-crud-api-backend
backend crud-api express javascript mongodb mongoose nodejs
Last synced: 3 months ago
JSON representation
CRUD API built using Node JS, Express JS and MongoDB
- Host: GitHub
- URL: https://github.com/douaaaaa/simple-crud-api-backend
- Owner: douaaaaa
- Created: 2024-08-01T14:03:08.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-01T16:33:15.000Z (almost 2 years ago)
- Last Synced: 2025-02-26T17:25:25.679Z (over 1 year ago)
- Topics: backend, crud-api, express, javascript, mongodb, mongoose, nodejs
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple CRUD API with Express and MongoDB
## Overview
This project implements a basic CRUD (Create, Read, Update, Delete) API for managing products. It uses Express.js for the server framework and MongoDB for data storage. The API provides endpoints to perform basic operations on product data.
## Features
- Create: Add new products.
- Read: Retrieve all products or get details of a specific product by ID.
- Update: Modify existing product details.
- Delete: Remove products from the database.
## Requirements
- Node.js (v14 or later recommended)
- MongoDB Atlas account (for the cloud database)
- npm or yarn (for dependency management)
## Installation
1. Clone the repository:
```
git clone https://github.com/douaaaaa/simple-crud-api-backend
cd your-app
```
2. Install dependencies:
```
npm install
```
3. Configure environment variables:
Create a .env file in the root of the project and add MongoDB Atlas connection string and port:
```
MONGO=mongodb+srv://:@cluster0.mongodb.net/yourdatabase?retryWrites=true&w=majority
PORT=3000
```
Replace username, password, and yourdatabase with your MongoDB Atlas credentials and the name of your database. You can find these details in the MongoDB Atlas dashboard.
## Usage
1. Start the server:
```
npm run dev
```
2. API Endpoints:
- GET /api/products: Retrieve a list of all products.
- GET /api/products/:id: Retrieve a product by its ID.
- POST /api/products: Create a new product.
- PUT /api/products/:id: Update an existing product.
- DELETE /api/products/:id: Delete a product.