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.
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
important to use dotenv to use the env variables
PORT=3000
MONGO_URI=mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
MONGO_DB_NAME=<database>
-
/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)
-
/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
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 options can be set in the config.js file.
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
Install dev dependencies: npm install --dev Run tests: npm test
This project is licensed under the MIT License - see the LICENSE file for details.