NodeJS and Database
Project to learn the fundamentals of NodeJS with database
- To run the project do a clone or download the zip file, after that access the folder on terminal or cmd and type:
yarn
or
npm install
- Open the file ormconfig.json and configure your database:
{
"type": "postgres", // database type
"host": "localhost", // database server
"port": 5432, // database port
"username": "postgres", // database user
"password": "postgres", // database password
"database": "gostack_desafio06", // database name
"entities": ["./src/models/*.ts"],
"migrations": ["./src/database/migrations/*.ts"],
"cli": {
"migrationsDir": "./src/database/migrations"
}
}
- Go back to the terminal e run to migrate your database:
yarn typeorm migration:run
or
npm run typeorm migration:run
- To start the server run:
yarn dev:server
or
npm run dev:server
- To execute some request use Insomnia or Postman
Test
- To run the tests, first create the database gostack_desafio06_tests (
to change the database alter the file src/database/index.ts
) and run:
yarn test
or
npm run test