This project is a market REST API that allows the management of purchases, workers, and product stock.
- Node.js
- Express.js
- TypeScript
- PostgreSQL
- JWT & bcrypt for authentication
- Postman
- User/worker authentication and authorization
- Batch product creation and management
- Easy addition of products to stock through batch creation
- Stock management
- Sales profit and expected profit management
- Worker management
- Purchase creation
- Clone the repository or download the
.zipfile. - Import the application Postman collection using the file
market-API.postman_collection.json. - Install the required dependencies using
npm install. - Rename the file
.envExampleto.env. - Set up the database and configure the connection in the
.envfile. - Run the application through the console using
npm start. - Use the application routes through Postman.
This application main url is localhost:3000/api-market/.
- Use the application through Postman.
- Create an admin user first to use the application(use the route
/user/register/adminfor this). - After creating an admin you can access the route
/user/register/workerto create workers. - Log in with the created user by using the route
/user/login - Remember to always provide the Bearer token when accessing a route. Also, remember that the token expires in 1 hour.
For a better first experience with the application, I recommend creating an Admin user and explore all the routes using this user.
- Admins: Can access all routes.
- Managers: Can access the following routes:
- Create User/Worker - /user/register/worker
- Update User/Worker - /user/update/:id
- Update User/Worker Role - /user/update/role/:id
- Delete User/Worker - /user/delete/:id
- Get All Stockers - /user/all/stocker
- Get All Cashiers - /user/all/cashier
- Get Stocker by ID - /user/stocker/:id
- Get Cashier by ID - /user/cashier/:id
- Get User/Worker by Name - /user/name
- Get Stock Total Profit (estimated value) - /stock/total-profit
- All routes related to batch management
- Almost all routes related to purchase management, except the route to create a purchase
- Stockers:
- All routes related to stock management
- All routes related to product management
- Cashiers:
- Can only access the route to create a purchase
This project is licensed under the MIT License.
- Document this API using Swagger
- Add description to the folders of the Postman Collection