Git Product home page Git Product logo

chingu-dashboard-be's Introduction

Chingu Dashboard

NestJS Typescript Prisma

Description

This is the Chingu Dashboard backend project. Be sure to set your .env environment variables files

  • if using the docker databases, and an external terminal, use these DATABASE_URL
# .env
DATABASE_URL=postgresql://chingu:chingu@localhost:5433/dashboard?schema=public
# .env.test
DATABASE_URL=postgresql://chingu:chingu@localhost:5434/dashboard?schema=public
# .env
DATABASE_URL={your database url}
PORT=8000

JWT_SECRET=
AT_SECRET=
RT_SECRET=
BCRYPT_HASHING_ROUNDS=10

MJ_APIKEY_PRIVATE=
MJ_APIKEY_PUBLIC=

NODE_ENV=development

FRONTEND_URL=https://chingu-dashboard-git-dev-chingu-dashboard.vercel.app/

# .env.test
DATABASE_URL={your test database connection string}
NODE_ENV=test

Installation

To install all the project's dependencies run:

$ yarn install

Prisma IMPORTANT: If you're using the docker setup in this project, go to the docker section

To prepare the DB

# migrate db schema
$ yarn migrate

# seed db
$ yarn seed

# run Prisma Studio
$ yarn studio

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Test

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# integration tests
$ yarn test:int

# test coverage
$ yarn test:cov

If using the docker terminal the commands would be

# unit tests
$ yarn test:docker

# e2e tests
$ yarn test:e2e:docker

# integration tests
$ yarn test:int:docker

# test coverage
$ yarn test:cov:docker

Docker

By using Docker you can: spin up Postgres, the API & PGAdmin, as well as run prisma Studio and even tests.

Running the project in Docker

With Docker open, from the project's root you can run Docker in dev or testing mode:

# spin up dev Docker services (API, PGAdmin, Postgres DB)
$ yarn docker

Docker will run in detached mode, meaning it's effectively running in the background, however, you will need to use the various scripts inside the docker cli.

Once the services are spun up, go to your docker desktop and go to chingu-dashboard-be_api container and click into it.

After, click on the CLI to into the terminal inside the container.

From here, type all the commands above.

PG Admin

http://localhost:4000/

Login with

[email protected]
chingu5432

Right click Servers -> Register -> Server...

dev database

hostname: postgres
port: 5433
maintenance database: dashboard
username: chingu
password: chingu

test database

hostname: postgres-test
port: 5434
maintenance database: dashboard
username: chingu
password: chingu

Having spun up your Docker services and migrated + seeded your DB your services will be running on the following default ports:

  • API: 8000
  • Postgres: 5433
  • PGAdmin: 4000
  • Prisma Studio: 5555

To stop and tear down the Docker services:

# tear down all Docker services but retain volumes
$ yarn docker:down

# tear down Docker services and remove all volumes
$ yarn docker:clean

Custom Pipes

FormInputValidationPipe

For use with form responses, this pipe validates that the responses or response (array) values include a questionId and at least one input value of any type.

Example: @Body(new FormInputValidationPipe())

Custom Decorators

@Roles()

Adds role(s) requirements for the route in conjunction with the RolesGuard

Examples:
@Roles(AppRoles.Admin) will restrict the route for users with admin roles
@Roles(AppRoles.Admin, AppRoles.Voyager) restricts the route to admin and voyagers

@Permissions()

Adds permissions requirements for the route in conjunction with the PermissionGuard

Examples:
@Permissions(AppPermissions.OWN_TEAM) will restrict the route for voyagers to access their own team data

Roles

  • Admin
  • Voyager

Permissions

  • OWN_TEAM - only access their own team data, teamId param required (admins excepted)

chingu-dashboard-be's People

Contributors

cherylli avatar curtwl avatar smurph7894 avatar timdehof avatar joshuahinman avatar jenny-alexander avatar siasktv avatar kennytram avatar dan-y-ko avatar marktlinn avatar alcb1310 avatar jdmedlock avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.