- Install Nodejs 12 or activate using nvm
- npm install
npm install
cp .env.sample .env
For ubuntu: sudo apt install postgresql
Setup all db
./setup_db.sh
For reseting db use:
psql -U postgres -f setup-db.sql
npm run db:migrate
npm run start:dev
npm run test
or
npm test -- --silent
npm run test:cov
npm run db:make-migrate <migration_name>
.
├── migrations
├── src
│ ├── authentication
│ │ ├── handler.ts
│ │ ├── repo.ts
│ │ ├── router.ts
│ │ └── stypes.ts
│ ├── phonebook
│ │ ├── handler.ts
│ │ ├── repo.ts
│ │ ├── router.ts
│ │ └── stypes.ts
│ ├── user
│ │ ├── handler.ts
│ │ ├── repo.ts
│ │ ├── router.ts
│ │ └── stypes.ts
│ ├── diagnostic
│ │ └── router.ts
│ ├── config.ts
│ ├── db.ts
│ ├── index.ts
│ └── server.ts
├── test
│ ├── env
│ │ ├── factories.ts
│ │ └── testEnvironment.ts
│ ├── functional
│ │ ├── auth.spec.ts
│ │ ├── search.spec.ts
│ │ ├── spam.spec.ts
│ │ └── userSignup.spec.ts
│ ├── nonfunctional
│ │ ├── diagnostic.spec.ts
│ │ └── swagger.spec.ts
│ └── dummy.ts
├── Dockerfile
├── setup_db_sh
├── .env.sample
└── README.md
1. migrations - Conrtains the database migration files
2. src/authentication - Contains Api for login are in this folder.
route.ts - Contains all the routes
handler.ts - contains buisness logic.
repo.ts - contains handlers to fetch/persist data in the db
type.ts - contains all the types.
3. src/phonebook - Contains Apis for Searching, Spam and Contact detaiils
4. src/user - Contains APi for sign up
5. config.ts - Contains constants which can be configured based on environment
6. db.ts - Knex.js setup
7. index.ts - Initialise the server
8. server.ts - Server configuration and setup.
9. test - This folder contains all the tests.
10. env/testEnvironment.ts - Test server setup
11. functional - Unit tests for auth, serach, spam, and user
12. dummy.ts - Script for genrating dummy contact list
13. setup_db_sh - Script to create database
NodeJS Framework
- Hapi.js
Orm/Query Builder
- Knex.js
Database
- PostgreSQL
Testing Framework
- Mocha
- Chai (assertion library)