Muchori / taxi-simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Taxi-Simulator

We need you to build a simple backend API that can be accessed by an admin user. This user can be hard-coded for this exercise and there is no need to manage users roles. This user will need to create and suspend drivers and monitor ongoing rides. Also we would like for you to simulate passengers calling drivers, and have you create some endpoints to register passengers and perform a ride simulation (no geolocation calculation is necessary to link the passenger with the best driver, this can be passed in the API).

Description

NestJS REST API simulating a taxi ordering ride by a passenger.

Table of Contents

Features

  • Database (typeorm).
  • Seeding.
  • Config Service (@nestjs/config).
  • Sign in and sign up via email.
  • Admin and User roles.
  • Swagger.
  • E2E and units tests.
  • Docker.

Technlogies and Tools used

  • TypeScript / JavaScript
  • NestJS Framework
  • Docker for containerization
  • Postgis / Postgres - Database
  • Jest for testing
  • Shell
  • Git and GitHub
  • Visual Studio Code

Quick run

git clone --depth 1 git@github.com:Muchori/taxi-simulator.git
cd taxi-simulator/
cp env-example .env
docker compose up -d

For check status run

docker compose logs

Comfortable development

I would recommend this for better experience

git clone --depth 1 git@github.com:Muchori/taxi-simulator.git
cd taxi-simulator/
cp env-example .env

Run additional container:

docker compose up -d postgres
npm install

npm run migration:run

npm run seed:run

npm run start:dev

Links

Database utils

Generate migration

npm run migration:generate -- src/database/migrations/CreateNameTable

Run migration

npm run migration:run

Revert migration

npm run migration:revert

Drop all tables in database

npm run schema:drop

Run seed

npm run seed:run

Tests

# unit tests
npm run test

# e2e tests
npm run test:e2e

Tests in Docker

docker compose -f docker-compose.ci.yaml --env-file env-example -p ci up --build --exit-code-from api && docker compose -p ci rm -svf

Test benchmarking

docker run --rm jordi/ab -n 100 -c 100 -T application/json -H "Authorization: Bearer USER_TOKEN" -v 2 http://<server_ip>:3000/api/v1/users

About


Languages

Language:TypeScript 89.1%Language:Shell 9.0%Language:JavaScript 1.1%Language:Dockerfile 0.8%