Backend Development Project: Building a pilot RESTful API for a Point-of-Sale System.
PDV System is a pilot RESTful API for point-of-sale, built with Node.js and Express. It provides secure authentication and CRUD for category, customer, order, and product management. It offers automated and custom email alerts via nodemailer/Handlebars and cloud image storage with PostgreSQL and Backblaze. As the project leader, we adopted the agile SCRUM methodology and documented the API with Swagger.
- Fork this repository to your GitHub;
- Clone your repository to your machine;
git clone https://github.com/your-user/digital-bank-api.git- Make sure you have Node.js installed on your machine. You can download it from here.
- Open the terminal of your preferred IDE. Navigate to the project's root directory and install the dependencies with
npm installornpm -i.
cd your-bank-project
npm install- I choose you! Now it's your turn, improve or rebuild my project with Node.js, creating a REST API the way you prefer!
Note: If you'd like, create a PR with your changes so I can take a look!
To access and test the project locally, follow these steps:
-
Database Setup:
- Create a local PostgreSQL database based on the scripts located at
src/configs/database/dump. - Execute the script to create the necessary tables and initial data.
- Create a local PostgreSQL database based on the scripts located at
-
Environment Configuration:
- Create a
.envfile at the root of the project. - Configure the file with the necessary environment variables based on your local database setup. Example
.env.example:PORT= DB_HOST= DB_PORT= DB_USER= DB_PASSWORD= DB_DATABASE= NODE_ENV=development JWT_SECRET_KEY= JWT_EXPIRED= ENDPOINT_S3= KEY_ID= KEY_NAME= ACCESS_KEY= AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 node createProductService.js EMAIL_HOST= EMAIL_PORT= # true for 465, false for other ports EMAIL_SECURE= EMAIL_USER= # generated ethereal user EMAIL_PASSWORD= # generated ethereal password EMAIL_NAME= EMAIL_FROM=
- Create a
-
Install Dependencies:
- Open the terminal in your preferred IDE, navigate to the project's root directory, and install the dependencies using the command:
npm install
- Open the terminal in your preferred IDE, navigate to the project's root directory, and install the dependencies using the command:
-
Run the Project:
- Start the application using the command:
npm start
- The API will be accessible at
http://localhost:<your_port>.
- Start the application using the command:
🎊 Now, have fun!
You can interact with the RESTful API using the following endpoints:
Note: Authentication with bearerAuth is required for some endpoints.
- Method: GET
- Description: Returns the list of all registered categories.
- Endpoint:
/categoria - Function: Retrieve all categories from the database.
- Method: POST
- Description: Allows users to register in the system.
- Endpoint:
/usuario - Function: Create a new user in the database with name, email, and password.
- Method: POST
- Description: Allows users to log in to the system.
- Endpoint:
/login - Function: Verify user credentials (email and password) and issue a JWT token for subsequent authentication.
- Method: GET
- Description: Returns the details of the profile of the logged-in user.
- Endpoint:
/usuario - Function: Retrieve the profile details of the user based on the authentication token.
- Method: POST
- Description: Allows the logged-in user to register a new product.
- Endpoint:
/produto - Function: Validate and register a new product in the system.
- Method: GET
- Description: Returns the list of all registered products.
- Endpoint:
/produto - Function: Retrieve all products from the database.
- Method: GET
- Description: Returns the details of a specific product.
- Endpoint:
/produto/:id - Function: Retrieve the details of a product based on the ID.
- Method: POST
- Description: Allows the logged-in user to register a new order.
- Endpoint:
/pedido - Function: Validate and register a new order in the system.
- Method: GET
- Description: Returns the list of all registered orders.
- Endpoint:
/pedido - Function: Retrieve all orders from the database.
- Method: GET
- Description: Returns the details of a specific order.
- Endpoint:
/pedido/:id - Function: Retrieve the details of an order based on the ID.
Explore the comprehensive API documentation for in-depth insights into the project functionalities. Access the complete API documentation by navigating to http://localhost:8181/swagger-ui.html or via your localhost: <your_port>/swagger-ui.html.
The documentation provides detailed information about each endpoint, including request methods, expected parameters, and sample responses. It serves as a valuable resource for developers, offering a clear understanding of how to interact with the PDV System REST API effectively.
Feel free to use this documentation as a guide while developing and testing your applications. If you encounter any issues or have suggestions for improvement, please don't hesitate to reach out. We appreciate your collaboration in making the PDV System API even better!
Finally, I would like to mention that this project is just the beginning! Soon, we will have new features and better organization, including the implementation of a real database.

