Skip to content

Fake API listing movie theaters and random movie schedules.

Notifications You must be signed in to change notification settings

otroboe/nestjs-playground

Repository files navigation

NestJS Playground - API Movie Schedule (rams)

Stack

NodeJS: https://nodejs.org/en/

Nest: https://nestjs.com/

A progressive Node.js framework for building efficient and scalable server-side applications on top of TypeScript & JavaScript (ES6 / ES7 / ES8) heavily inspired by Angular

TypeORM: http://typeorm.io

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap and Ionic platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7)

MariaDB: https://mariadb.org/

Docker: https://www.docker.com/

Requirements

Install NodeJS and npm

Install Docker and docker-compose

Configuration files

You have to create your own .env file, avoiding sharing password, and customizing depending on your own dev environment.

You can copy the default file, and have to update it. Or create your own.

cp .env.default .env

Set your DB_PASSWORD and DB_ROOT_PASSWORD (for dev environment).

Commands

Dev

First time

./bin/dev-start.sh

It will starts 2 containers:

  • MariaDB server for the API data on 3306 port.
  • Adminer to manage MariaDB data while programming on http://localhost:8080.

Start the app

npm run start

# Watch for changes for automatic restart
npm run start:watch

The default URL is http://localhost:3000.

Clear all dev data and containers:

./bin/dev-clear.sh

Prod

# Build for production
npm run prestart:prod

# Start the production app version
npm run start:prod
# Start all stack
DB_PASSWORD={{your_pwd}} DB_ROOT_PASSWORD={{your_pwd}} ./bin/prod-start.sh
# Inject fixtures
docker exec rams-prod-app node dist/bin/fixtures-init.js
# Clear all prod data and containers
./bin/prod-clear.sh

Data

# Insert fixtures data
npm run fixtures:init

# Remove all fixtures from DB
npm run fixtures:clear

Tests

# Run unit tests
npm test

# Run and watch unit tests
npm run test:watch

# Run unit tests coverage
npm run test:coverage

# Opn coverage html report
npm run open:coverage
# Run end-to-end tests
npm run e2e

# Run and watch end-to-end tests
npm run e2e:watch

URLs

TODO

  • Check the compatibility for enum in swagger nestjs library (Github issue).
  • Check the tests coverage for constructor with injection
  • Find a way to not expose URLs in Swagger (e.g. list of movies)

Issues

  • The logger is logging duplication when a request is called.

Resources

NestJS

Docker

Misc

Tips

  • TypeORM repositories for unit testing: here

About

Fake API listing movie theaters and random movie schedules.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages