Skip to content

unit214/superhero-dex-backend

 
 

Repository files navigation

Dex Backend

Local development

Prerequisites

Setup DB & run the application

  1. Install dependencies:
npm install
  1. Run docker container with DB locally, this will also run the DB migrations
npm run db:start
  1. Start the development server:
npm run serve:dev

Database

Schema changes

This application uses Prisma as an ORM. To make changes to the DB schema, you need to update the schema in prisma/schema.prisma.

  • For prototyping during development you can push the schema changes to the DB using:
    npm run db:push-schema
  • Once the schema changes are ready to deploy, you can generate and apply a prisma migration file with the change using:
    prisma migrate dev --name <NAME_OF_YOUR_MIGRATION>

User defined PostgreSQL functions

This application uses user defined functions in the PostgreSQL database. These functions are defined in the sql-functions directory.

  • For prototyping during development you can push the functions to the DB using:
    npm run db:push-functions
  • Once the functions are ready to deploy you have to manually create an empty prisma migration for them using:
    prisma migrate dev --create-only --name <NAME_OF_YOUR_MIGRATION>
    Then, copy your sql code into the newly created migration file. Afterwards, apply the changes using prisma migrate dev

Testing

# unit tests
npm run test

# e2e tests
npm run test:e2e

# test coverage
npm run test:cov

Further commands for interacting with the DB container

# to start
npm run db:start

# to stop container
npm run db:stop

# to remove (will delete all db data)
npm run db:remove

# to reset (delete all data and recreate db)
npm run db:reset

Further commands for running the app

# development
npm run serve

# watch mode
npm run serve:dev

# debug mode
npm run serve:debug

# production mode
npm run build
npm run serve:prod

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.5%
  • JavaScript 1.2%
  • Other 0.3%