Giter Club home page Giter Club logo

gerencia-me-backend's Introduction

Gerencia-me Backend

Web API created to gerencia-me project, made for Mega Hack Hackathon

Technologies: Node.JS, Express, Sequelize, PostgreSQL, BCrypt and JWT

Steps to Run

  • git clone https://github.com/TeijiW/gerencia-me-backend
  • cd gerencia-me-backend
  • Create and configure the .env file (instructions below)
  • yarn install
  • yarn migrate
  • yarn populate
  • yarn start

Environment Variables

To run this API it's necessary set some Environment variables in .env file

APPLICATION

  • APP_PORT - Port that will be used by app

DATABASE

  • DB_DIALECT - Dialect used to set DBMS that will be used (postgres by default)
  • DB_NAME - Database name ("gerencia_me" bt default)
  • DB_HOST - Database Host name (localhost by default)
  • DB_USER - Database user ("root" by default)
  • DB_PASSWORD - Database password ("default" by default) Database port is determined in accordance with database dialect

AUTHENTICATION

Warning: A admin user is created with these credentials to manage another users

  • ADMIN_EMAIL - Admin email to login (""[email protected]" by default)
  • ADMIN_PASSWORD - Admin password ("admin" by default)

OTHER

  • SECRET_KEY - The secret key used to JWT Auth

ROUTES

AUTHENTICATION

  • "/auth"
    • POST - Login with email and password (return: a JWT Token)

Warning: "Users" routes it's allowed for admin only

USERS

  • "/users"
    • GET - Get all Users
    • POST - Create new user
  • "/users/{userId}"
    • GET - Get user by id
    • PUT - Update the user
    • DELETE - Remove the user

STORES

  • "/stores"
    • GET - Get stores by user
    • POST - Create a store to the refered user
  • "/stores/{storeId}"
    • GET - Get store by id
    • PUT - Update the store of the refered user
    • DELETE - Remove the store of the refered user

CATEGORIES

  • "/categories"
    • GET - Get categories by user
    • POST - Create a category to the refered user
  • "/categories/{categoryId}"
    • GET - Get category by id
    • PUT - Update the category of the refered user
    • DELETE - Remove the category of the refered user
  • "/stores/{storeId}/categories
    • GET - Get categories by store
    • POST - Add a category to store

PRODUCTS

  • "/products"
    • GET - Get products by user
    • POST - Create a product to the refered user
  • "/products/{productId}"
    • GET - Get product by id
    • PUT - Update the product of the refered user
    • DELETE - Remove the product of the refered user
  • "/stores/{storeId}/products
    • GET - Get products by store
    • POST - Add a product to store

Models to made a request

OBSERVATIONS

  • If the request body to "Add/create category or product" has a id, the system will try insert the category or product with that id
  • Requests must have bearer auth with the JWT token

USERS

id: INTEGER,
email: STRING(130), // Should be unique
name: STRING(130),
password: STRING(80),
docNumber: STRING(20), // Can be null

STORES

id: INTEGER,
name: STRING(80),
address: STRING(80), // Can be null
desc: STRING(140),
docNumber: STRING(20), // Can be null
storeType: ENUM(
  "food",
  "supermakert",
  "clothing",
  "drugstore",
  "building materials",
  "other"
),
userId: INTEGER

CATEGORIES

id: INTEGER,
name: STRING(80),
userId: INTEGER

PRODUCTS

id: INTEGER
name: STRING(80),
desc: STRING(140),
imageUrl: STRING(140), // Can be null
price: DECIMAL(10, 2),
categoryId: INTEGER, // Can be null
userId: INTEGER

By TeijiW with ❤️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.