This project is meant to be used as a code assignment which was given to me for a job interview.
Evaluation test project specifications:
- this solution must be done with Nest.Js.
- this solution should not contain the use of ‘any’ type.
- this solution should contain a clear ‘Readme.md’ which indicates how to install and run the solution.
- stick to the modular architecture.
- create unit tests as much as you think is required.
- create API documentation in Swagger or Postman collection format.
- create an open repository in your GitHub account and push everything there.
Create a Restful API for three different areas:
- User registration and login which should give the user AccessToken.
- User Wallet which is of different currencies.
- Currencies.
Try to install dependency with pnpm
and then set these enviroment varibles.
DB_PASSWORD=<postgres_db_password>
DB_USERNAME=<postgres_db_username>
DB_NAME=<database name>
DB_HOST=<database host>
JWT_SECRET_KEY=<set a secret key here>
Please follow the below instructions.
- At first install
docker
on your system and then use - Run this command
docker compose up -d
You can change docker compose.yml
file as you want.
version: "3"
services:
pgdb:
image: postgres:latest
container_name: postgres_db
restart: always
environment:
POSTGRES_USER: <SET_DB_USERNAME>
POSTGRES_PASSWORD: <SET_DB_PASSWORD>
POSTGRES_DB: <SET_DB_NAME>
nest-api:
build:
context: .
dockerfile: Dockerfile
container_name: nest-api
restart: always
ports:
- 3000:3000
depends_on:
- pgdb
environment:
DB_PASSWORD: <DB_PASSWORD>
DB_USERNAME: <DB_USERNAME>
DB_NAME: <DB_NAME>
DB_HOST: pgdb
JWT_SECRET_KEY: <SECRET_KEY>
In the root of project there is hopp-http-collection.json
file. import this file into hoppscotch
pnpm build
: It builds project and generates transpiled .js files.pnpm start:dev
: It starts development serverpnpm test
: It runs unit tests.pnpm test:coverage
: It runs the tests and then generatehtml
coverage file.pnpm test:watch
: It runs test in watch mode.
- It uses Fastify
as the webserver to achieve blazing-fast speed 🔥.
- It uses SWC 🦀 compiler for faster build time during development and CI/CD pipelines.
- It uses Vitest 🧪 as the main test runner to have great fetureas like test graph. checkout
pnpm vitest --ui
- It uses pnpm 📦 as the package manager to save extra disk space to save a little bit money 💸.
- It uses Mikro-ORM with different patterns like DataMapper to showcase mikro-orm capabilities 💪
- It uses decimal.js to have a high precision of numbers and to avoid IEEE 754 floating point pitfalls when working with monetary system
- Useing DAO (Data Access Object) Pattern to eliminate dependency between ORM And Business Logics
- Adding more integration and unit tests. One of the project modules doesn't have any tests at all.
- Test Coverage :
- UtilModule - 100% - ✅
- AuthModule - 80% - ✅
- CurrencyModule 70% -
⚠️ - WalletModule - No Test - ❌
- Test Coverage :
- Adding End2End testing pipeline to the project.