jvcjunior / test_lemoney_node_functional

Node test for lemoneys company

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lemoney - Node Challenge

Concepts applied

  • REST architecture ✔️
  • Authentication and permissions ✔️
  • Data modeling and migrations ✔️
  • SQL database ✔️
  • Query optimization ✔️
  • Serialization ✔️
  • Production builds ✔️
  • Rate Limit ✔️
  • Request Data validation with Joi ✔️
  • Unit Tests with Jest ✔️

THE PROJECT

Requirements

Running the application - Development

Run our app locally with sqlite database First, we need to install all depedencies:

yarn install or npm install

Once all dependencies are installed we now can run our application.


Run our app locally with sqlite database

The fastest way of run our app is using a sqlite database. First, we need to make a copy of .env.sqlite.local and save as .env

cp .env.sqlite.local .env

Then we need to create our tables and add initial data:

Generate tables in database:

yarn run migrate:dev

Load fake data in database:

yarn run seed:dev

Now, just execute:

yarn start:dev

Our app is going to be running using port 5000.


Run our app locally with postgres database running on Docker

Make a copy of .env.docker.development and save as .env.

cp docker/.env.docker.development .env

Install dependencies and run the application locally.

docker-compose -f docker/docker-compose.dev.yml up -d db 

Then we need to create our tables and add initial data:

Generate tables in database:

yarn run migrate:dev

Load fake data in database:

yarn run seed:dev

Now, just execute:

yarn start:dev

Our app is going to be running using port 5000.


Run both our app and the database on Docker

Make a copy of .env.docker.development and save as .env.

cp docker/.env.docker.development .env

Install dependencies and run the application locally.

docker-compose -f docker/docker-compose.dev.yml up -d

Testing the application

it's really simple to test the aplpication see the results. You just need to run:

yarn test

Running the application - Production

Make a copy of .env.docker.production and save as .env.

cp docker/.env.docker.production .env

TO run the app in prod you just need to run:

docker-compose -f docker/docker-compose.prod.yml up -d

After that, please run the following commands to create the database and run seeds:

docker exec -it api-prod yarn run migrate:prod
docker exec -it api-prod yarn run seed:prod

About

Node test for lemoneys company


Languages

Language:TypeScript 99.7%Language:Shell 0.3%