Skip to content

jvcjunior/node_express_functional

Repository files navigation

Jungle Devs - Node Challenge

Description

Challenge goal: The purpose of this challenge is to give an overall understanding of a backend application. You’ll be implementing a simplified version of news provider API. The concepts that you’re going to apply are:

  • REST architecture ✔️
  • Authentication and permissions ✔️
  • Data modeling and migrations ✔️
  • SQL database ✔️
  • Query optimization ✔️
  • Serialization ✔️
  • Production builds ✔️

Added:

  • Rate Limit
  • Request Data validation with Joi
  • Unit Tests with Jest

Target level: This is an all around challenge that cover both juniors and experience devs based on the depth of how the concepts were applied.

Final accomplishment: By the end of this challenge you’ll have a production ready API.

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.

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/Express API using some functional approach

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published