Skip to content

osamabari/phonebook-api-nodejs

Repository files navigation

Phonebook Rest API

Rest api for phonebook

Requirements

Getting Started

Clone the repo and make it yours:

git clone --depth 1 https://github.com/osamabari/rest_api
cd rest_api

Install dependencies:

yarn

Set environment variables:

cp .env.example .env

Running Locally

yarn dev

and open http://localhost:3000/v1/status to check api is running or not

Running Documenation

Step 1:

yarn docs

Step2:

yarn dev

Step3:

open http://localhost:3000/v1/docs in web browser

Check API In Postma

Import Phonebook_API.postman_collection.json file in postman to start

Running in Production

yarn start

Lint

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

Test

# run all tests with Mocha
yarn test

Logs

# show logs in production
pm2 logs

Documentation

# generate and open api documentation
yarn docs

Docker

# run container locally
yarn docker:dev

# run container in production
yarn docker:prod

# run tests
yarn docker:test

Deploy

Set your server ip:

DEPLOY_SERVER=127.0.0.1

Replace my Docker username with yours:

nano deploy.sh

Run deploy script:

yarn deploy