https://github.com/josecorreamorales/node-rest-api
This is a REST API for a simple store management system. It allows you to create, read, update and delete products and users. It also allows you to generate a report of all products in an excel file.
https://github.com/josecorreamorales/node-rest-api
expressjs mongoatlas nodejs rest-api
Last synced: about 2 months ago
JSON representation
This is a REST API for a simple store management system. It allows you to create, read, update and delete products and users. It also allows you to generate a report of all products in an excel file.
- Host: GitHub
- URL: https://github.com/josecorreamorales/node-rest-api
- Owner: JoseCorreaMorales
- License: mit
- Created: 2023-09-02T22:56:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-03T22:42:10.000Z (over 2 years ago)
- Last Synced: 2025-06-18T15:44:39.578Z (about 1 year ago)
- Topics: expressjs, mongoatlas, nodejs, rest-api
- Language: JavaScript
- Homepage: https://node-rest-api-production-b87c.up.railway.app/
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node-REST-API
### Technologies
## Description
This is a REST API for a simple store management system. It allows you to create, read, update and delete products and users. It also allows you to generate a report of all products in an excel file.
## Usage
Start the server: npm start
Open a web browser and navigate to http://localhost:3000
run the following command to install all the dependencies
```
npm install
```
run the following command to start the server
```
npm run dev
```
### env example
important to use **dotenv** to use the env variables
```env
PORT=3000
MONGO_URI=mongodb+srv://:@/?retryWrites=true&w=majority
MONGO_DB_NAME=
```
## API Endpoints
* **/api/products**
* **GET**: Get all products
* **POST**: Create a new product
* **/api/products/:id**
* **GET:** Get a single product by ID
* **PUT:** Update a product by ID
* **DELETE:** Delete a product by ID
* **/api/products/report**
* **GET:** Get a report of all products (Excel)
###### ⚠️ to get a report on postman use the toggle button and select the option "Send and download" and then send the request
* **/api/users**
* **GET**: Get all users
* **POST:** Create a new user
* **/api/users/:id**
* **GET:** Get a single user by ID
* **PUT:** Update a user by ID
* **DELETE:** Delete a user by ID
* **/api/sales**
* **GET**: Get all sales
* **POST:** Create a new sale
* **/api/sales/:id**
* **GET:** Get a single sale by ID
* **PUT:** Update a sale by ID
* **DELETE:** Delete a sale by ID
# Database
This project uses MongoDB as the database (Mongo Atlas). The database connection is established in the database/index.js file. The database name is "catalog" and the collection names are "products", "sales" and "users".
## Configuration
Configuration options can be set in the config.js file.
## Debugging
Debugging can be enabled by setting the DEBUG environment variable to "app:*". For example, on Linux or macOS, use the following command:
```
DEBUG=app:* npm start
```
On Windows, use the following command:
```
set DEBUG=app:* & npm start
```
## Testing
Install dev dependencies: npm install --dev
Run tests: npm test
## Resources
* [Node.js](https://nodejs.org/en/)
* [Express](https://expressjs.com/)
* [MongoDB](https://www.mongodb.com/)
* [Debug ](https://www.npmjs.com/package/debug)
* [excel4node ](https://www.npmjs.com/package/excel4node)
* [http-errors ](https://www.npmjs.com/package/http-errors)
## License
This project is licensed under the MIT License - see the LICENSE file for details.