$ yarn install
NOTE: you should create your .env
file.
example;
DB_HOST=127.0.0.1
DB_USER=***
DB_PASS=***
DB_NAME=***
If you don't have sequelize globally installed globally: $ yarn install sequelize -g
run migrations: $ yarn sequelize db:migrate
run seeds: yarn sequelize-cli db:seed:all
$ yarn start
import the Insomnia file to Insomnia or Postman
OBS: You can do login with the credentials (admin user):
email: teste@gmail.com
password: nodeERP2803
https://www.edureka.co/community/77202/how-can-i-set-node-env-production-on-windows
Inside src/
;
app.js
=> server logic (application)
server.js
=> allocate ports
routes.js
=> application routes
https://jestjs.io/ Node.js unit tests, mocks, coverage, etc.
-
install jest
yarn add jest -D
-
Jest Init
yarn jest --init
-
configure your
jest.config.js
& create your test in tests/integration or _tests/unit -
run your tests
yarn test
yarn add sequelize pg
(I'm using PostgreSQL)
yarn add sequelize-cli -D
yarn sequelize init
creates files config/config.json
& models/index.js
& the emptys folders migrations/
and seeders/
;
yarn sequelize migration:create --name=create-users
yarn sequelize seed:generate --name users
If you are using postgreSQL & pgAdmin;
Create a new database in PgAdmin
NOTE: you can change the username & password in src/config/database.js
and the database name must be the same name
yarn sequelize db:migrate
create tables in the database if they don't exist & update database
after create your table you can access in pgAdmin -> Databases -> 'your_database' -> Schemas -> public -> Tables
Node.js unit tests, mocks, coverage, etc.
-
install jest
yarn add jest -D
-
Jest Init
yarn jest --init
It is an ORM that makes it easier for us to deal with the data and tables of our Database, using Javascript
syntax instead of SQL
.
lib for sequelize to handle PostgreSQL Database
Helps to deal with the creation of migrations, which are the files that will control the version of our DB tables