Api REST for 4all-locadora app
# install dependencies
$ npm install
# compose container with postgres
$ docker-compose up -d
# migrate database
$ node_modules/.bin/sequelize db:migrate
# or with sequelize-cli
$ npx sequelize-cli db:migrate
# seed database
$ node_modules/.bin/sequelize db:seed:all
# or with with sequelize-cli
$ npx sequelize-cli db:seed:all
# serve with hot reload at localhost:4000
$ npm run dev
# launch server
$ npm start
# test application
$ npm run test
# API DOCS: http://localhost:4000/api-docs
After runing the project in dev mode, you can access the documentation with every route specification at
If you seeded the database as described above, you can use theese default sample users to authenticate
- admin:
- email: [email protected]
- password: adminadmin
- client:
- email: [email protected]
- password: clientclient
You should provide the authorization token in the request header when accessing a restricted endpoint, it must be in the following format
- Authorization: Bearer < token >
If you need to change any database configuration params, you can do it at
- ./config
- config.json
If you are using the docker container setted up from docker-compose.yaml file, the default pgAdmin4 credentals are
- email: admin@admin
- password: admin
and postgres default password:
- password: adminadmin
- Node.js - JavaScript runtime
- Babel.js - JavaScript compiler
- Express.js - REST api webservice
- Sequelize - ORM for relational database
- JWT - Web tokens for authentications
- Bcrypt - Encrypting passwords
- Swagger.io - Api Docs
- Mocha- Asynchronous testing
- supertest - HTTP testing
- Chai - Assertion Framework
- Docker - Container with postgres and pgadmin4
- config - contains config file, which tells CLI how to connect with database
- models - contains all models and data structure
- migrations - contains all database migration files
- seeders - contains all seed files,
- tests - contains all tests code,
- services - contains all services and business logic
- controllers - contains all controllers that links routes with services
- middlewares - contains all middlewares, like jwt validation for authenticated users
- routes - contains all declared express http routes