As soon you clone the project you have to run this command in the terminal in the directory of the project.
npm install
This is to install all the dependencies necesaries in the project. Then we have this commands to run the project:
npm run dev //This one to start nodemon with the project. Any saved change in the
// files of the project will restart the server
npm run debug // Same as before but allows you to debug the app with Chrome
// dev Tools
npm run test // Runs certains test in the project to verify everythings working fine
We have two main folders: Express and Sequelizer
Express is the responsible to mount the server and to manage the routes for each entity in the database with all the HTTP actions.
Here we have different folders for different parts of logic:
lib: This folder is for conections to different databases. We do a migration from MongoDB to PostgreSQL so this file is now deprecated
routes: Here we have all the routes of the api. One file for each required entity. The form to name the routes are like this:
[word of entity as in database] + Router.js ⇒ for example ⇒ alimentoRouter.js
scripts: This is for any script we need to run. This is for example if we have to initialize the database or to fill the data in case of truncate a table, etc.
services: This is a complement to the lib folder. This has all the functions to routes using mongoDB but again this folder is now deprecated and the responsability of the database is Sequelizer.
test: Here goes all tests for the app. We try to test each route per file and each HTTP verb at least. For this we use proxyquire and mocks.
utils: Any other function or part of logic goes here. We have mocks, auth methods, schemas and middlewares handlers.
Sequelizer is responsible to manage all the database from PostgreSQL. It is the ORM. Here we can define tables, columns, associations and so. The folders in here are: