Web API created to gerencia-me project, made for Mega Hack Hackathon
Technologies: Node.JS, Express, Sequelize, PostgreSQL, BCrypt and JWT
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
To run this API it's necessary set some Environment variables in .env
file
- APP_PORT - Port that will be used by app
- 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
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)
- SECRET_KEY - The secret key used to JWT Auth
- "/auth"
- POST - Login with email and password (return: a JWT Token)
Warning: "Users" routes it's allowed for admin only
- "/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"
- 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"
- 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"
- 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
- 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
id: INTEGER,
email: STRING(130), // Should be unique
name: STRING(130),
password: STRING(80),
docNumber: STRING(20), // Can be null
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
id: INTEGER,
name: STRING(80),
userId: INTEGER
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 ❤️