Skip to content

ErikaEspejo/twitter-api

Repository files navigation

Node APIRest

Prerequisites

Before starting

Make sure you have yarn installed, run on console.

> yarn --version

If it return an error, please install yarn.

> npm install -g yarn

Clone the repo

> git clone https://github.com/jestrade/api-make-it-real-2021.git

Enter to folder project

> cd api-make-it-real-2021

Install the app

> yarn

Create .env file

  • Configuration Example:
    • HTTP_HOST -> IP of server, default is 127.0.0.1.
    • HTTP_PORT -> Node listening port, default is 3000.
    • LOG_ACCESS -> Path where the logs will be stored, don't specify the path, just the file name, default access.log.
    • JWTKEY -> Is used by JWT to sign the token.
    • APIWEATHERKEY -> Is used to consume the API.
    • DB_CONNECTION_STRING -> Connection string to connect mongodb database
    • SALT_ROUNDS -> Controls how much time is needed to calculate a single BCrypt hash, default is 10.

Example connection string local, more info. MongoDB.

mongodb://username:password@host:port/database

Example connection string in cloud, more info MondoDB Atlas.

mongodb+srv://<username>:<password>@cluster0.rwp0b.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Rename .env.example to .env, and set parameters required, please dont include env:.

env:

# This is parameters required.
HTTP_HOST=
HTTP_PORT=
LOG_ACCESS=
JWTKEY=
APIWEATHERKEY=
DB_CONNECTION_STRING=
SALT_ROUNDS=

Install nodemon as development dependency

> yarn add -D nodemon

Run the seeds

> yarn run seeds

Run the app

Without nodemon

Run project without nodemon

> yarn start

With nodemon

Run project with nodemon

> yarn run dev

Run tests

> yarn run test