Live version: https://car-fleet-manager.herokuapp.com/api-docs/
- Car fleets are owned by one user
- Only fleet owners can see their car's fleet
- A car can be part of just one fleet
- Cars are available to all the users for pickup
The following insertion endpoints were not developed:
- POST /cars was not developed. To add new cars.
- POST /fleet was not developed. To add new fleets.
- User registration endpoint
Instead, data is being inserted by the
SeedDb
component on app startup car_fleet_hist
table to store history of transactions on a fleet. (Add/Remove cars)- Create different user roles. Fleet operator(owner), Admins, etc.
Unit tests coverage is low due the task time. The test case for addCar
was done as an example
- PORT: Port where the API is going to run
- SQL_DB: Name of the Database
- SQL_USERNAME: Connection DB user name
- SQL_PASSWORD: Connection DB password
- SQL_HOST: Database host
- SQL_PORT: Database port
- SQL_DIALECT: Database dialect. Ex: postgres
- SQL_LOGGING: boolean to enable/disable query logging
- ENCRYPTION_KEY: key to encrypt sensitive data, like passwords
- JWT_KEY: key to sign the JWT tokens
- Create a DB in your local environment or using a DB provider like elephantsql
- Update the environment variables in env.local
- start with dev database
yarn start:dev
- start with local database
yarn start:local
- This project is a seed for building a node.js api. It includes the following features:
-
- tsoa
typescript
- tsoa
-
- inversify
inversion of controll / dependency injection
- inversify
-
- typeorm
SQL ORM
- typeorm
-
- ts-mockito
testing
- ts-mockito
<url>/api-docs
<url>/service
- instalation:
yarn install
- dev:
yarn start
build tsoa routes, swagger definitions and starts the server on development mode listening to file changes (swagger definition changes will require a manual restart) - test:
yarn test
unit tests - build:
yarn build
production build - prod:
yarn start:prod
starts the server on production mode - local:
yarn start:local
starts the server locally, listening to changes
- config
express server, DB connection, Logger, etc
- env
.env files
- env
- controllers
routes configuration
- persistance
data abstraction layers
- Entities
classes and interfaces representing entities.
- Repositories
abstraction layer being used by services to access entities
- Entities
- services
business logic to be used primary by controllers
- Dtos
Data transfer objects, to decouple domain from Rest resources
- Dtos
- utils
- tests
- Base Image
phusion/baseimage
- Process Manager for Nodejs
PM2