/rick-n-morty-fanbase-nestjs

Headless CRUD API for Rick and Morty favourites and reviews.

Primary LanguageTypeScript

Rick & Morty - Fanbase

Description

This simple CRUD REST application, based on generated NestJS started plate, is a brief demonstration of TypeScript and NestJS skills, coveringv following requirements:

Simple CRUD service exposing REST endpoints to:

  1. Favourite characters, locations, & episodes.
  2. Review and rate episodes.
    1. Include text.
    2. Star rating (1-5).
  3. Create open API definition for your schema (OAS3).
  4. Write unit tests and show coverage report.

Installation

$ npm install

Running the app

# Development.
$ npm run start

# Watch mode.
$ npm run start:dev

# Production mode.
$ npm run start:prod

# Initialize the database with seed data (only needed once).
$ npm run seed

Main REST API Endpoints:

See Swagger UI for details on all endpoints and operations.

Data

For local development purposes, the app is backed by SQLite database in data/database.db.

To initialize the databse with seed data run npm run seed.

Entity relations

erDiagram
    User {
        int id PK
        string name UK "NN"
    }
    Favourite {
        int id PK
        int userId FK, UK "NN, Unique constraint on (userId, entityId, entityTypeId)"
        int entityId "NN"
        int entityTypeId FK "NN"

    }
    EntityType {
        int id PK
        string type UK "NN"
    }
    Review {
        int id PK
        int userId FK "NN, Unique constraint on (userId, episodeId)"
        int episodeId "NN"
        string text "NN"
        int rating "NN"
    }

    User ||--|{ Favourite : "has"
    EntityType ||--|{ Favourite : "categorizes"
    User ||--|{ Review : "writes"

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

License

Nest is MIT licensed.

Screenshots

Swagger UI