Skip to content

PDV System is a pilot RESTful API for point-of-sale, built with Node.js and Express.

Notifications You must be signed in to change notification settings

esythir/PDV-System-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

120 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Header Banner

PDV-System-REST-API

Backend Development Project: Building a pilot RESTful API for a Point-of-Sale System.

npm Node.js express PostgreSQL Knex Nodemailer Swagger Version

Table of contents

Project Description

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.

How to Setup?

  • Fork this repository to your GitHub;
  • Clone your repository to your machine;
    git clone https://github.com/your-user/digital-bank-api.git

Set up your development environment:

  • 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 install or npm -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!

Local Setup

To access and test the project locally, follow these steps:

  1. 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.
  2. Environment Configuration:

    • Create a .env file 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=
      
  3. 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
  4. Run the Project:

    • Start the application using the command:
      npm start
    • The API will be accessible at http://localhost:<your_port>.

🎊 Now, have fun!

Endpoints

You can interact with the RESTful API using the following endpoints:

Note: Authentication with bearerAuth is required for some endpoints.

CATEGORIES

List Categories

  • Method: GET
  • Description: Returns the list of all registered categories.
  • Endpoint: /categoria
  • Function: Retrieve all categories from the database.

USERS

Register User

  • 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.

Login User

  • 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.

User Profile Details

  • 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.

PRODUCTS

Create Product

  • 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.

List Products

  • Method: GET
  • Description: Returns the list of all registered products.
  • Endpoint: /produto
  • Function: Retrieve all products from the database.

Product Details

  • Method: GET
  • Description: Returns the details of a specific product.
  • Endpoint: /produto/:id
  • Function: Retrieve the details of a product based on the ID.

ORDERS

Create Order

  • 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.

List Orders

  • Method: GET
  • Description: Returns the list of all registered orders.
  • Endpoint: /pedido
  • Function: Retrieve all orders from the database.

Order Details

  • Method: GET
  • Description: Returns the details of a specific order.
  • Endpoint: /pedido/:id
  • Function: Retrieve the details of an order based on the ID.

Documentation

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.

tags: Node.js Express JavaScript PostgreSQL CRUD AWS SDK bcrypt CORS Joi Knex JSON Web Token multer nodemailer Handlebars Backblaze Agile SCRUM Multitier architecture API Documentation (Swagger)
GitHub Header Banner

About

PDV System is a pilot RESTful API for point-of-sale, built with Node.js and Express.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5