项目作者: avatsaev

项目描述 :
Backend API server for Angular Contacts App
高级语言: TypeScript
项目地址: git://github.com/avatsaev/angular-contacts-app-example-api.git



Nest Logo

NestJS Contacts API

This project uses @nestjsx/crud to simplify and standardize the REST API

This backend is based on NestJS Framework V6 (https://nestjs.com/)

  • DB: Postgres
  • Websockets: Socket.io
  • Synchronises sockets thourgh Redis adapter for horizontal scaling

Frontend is available here: https://github.com/avatsaev/angular-contacts-app-example

Env VARS:

  1. SERVER_PORT: 3000
  2. POSTGRES_HOST: db
  3. POSTGRES_PORT: 5432
  4. POSTGRES_USER: contacts_db
  5. POSTGRES_PASSWORD: contacts_db_pass
  6. POSTGRES_DB: contacts_db
  7. REDIS_HOST: redis
  8. REDIS_PORT: 6379
  9. REDIS_ENABLED: 'true'

Run

docker-compose up --build

Server will be running on http://localhost:3000

Endpoints

  • GET /contacts : returns an array of Contacts
  • GET /contacts/:id: returns a Contact shape
  • POST /contacts: Create a contact, returns a Contact shape
  • PATCH /contacts/:id: Partially update a Contact, returns a Contact shape
  • DELETE /contacts/:id: Delete a Contact, empty response

Contact shape:

  1. interface Contact {
  2. id?: number | string;
  3. name: string;
  4. email: string;
  5. phone?: string;
  6. }

Installation

  1. $ npm install

Running the app

  1. # development
  2. $ npm run start
  3. # watch mode
  4. $ npm run start:dev
  5. # production mode
  6. npm run start:prod

Test

  1. # unit tests
  2. $ npm run test
  3. # e2e tests
  4. $ npm run test:e2e
  5. # test coverage
  6. $ npm run test:cov