Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 2.84 KB

README.md

File metadata and controls

87 lines (64 loc) · 2.84 KB

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

Description

Nest framework TypeScript backend. Used with swagger for api documentation (see swagger-spec.json).

Basic Documentation

I'd recommend looking at nestjs docs, but here is what you need to know. The app is run from main.ts where it creates a nest app using the App Module.

Modules are responsible for setting up imports, controllers and services and are being used on a endpoint basis represented by the folders. As you can see in the App Module, it imports the other modules that are used, for example the BoardModule.

The board module then sets up the board controller, services and the auth module (responsible for ensuring users are authenticated). Every controller is then split up by endpoint, represented by the function where the decorators represent the endpoint information.

Compatibility

Be sure to run using Node 14 and npm 7

Installation

$ npm install --include=dev

Running the app

# development
# runs on port 3000
$ npm run start:dev

# production mode
$ npm run start:prod

Database

Database credentials should be stored in .env which should be created from .env.bak. Follow these steps withing the .env.bak to connect prisma to your local db

$ cp .env.bak .env

Setup with MacOS

# Install
$ brew install mysql

# Start the db server
$ brew services start mysql

# Stop the db server
$ brew services stop mysql

Setup with windows

# Good luck figuring it out lol

Adding a mysql connection

  • Run mysql as root in bash
$ mysql -uroot
  • Update the connection email/password
ALTER USER 'root'@'localhost' IDENTIFIED BY '<YOURNEWPASSWORD>';
  • Now go to .env file and update it with your username and password
# to apply schema to your database
$ npx prisma db push

# to apply database to your schema
$ npx prisma db pull

# To reflect prisma changes to the client
$ npx prisma generate

Swagger

Swagger documentation is available at swagger-spec.json or at localhost:3000/api-docs. If you would like to visualize swagger-spec.json and don't have localhost set, you can use the Swagger editor to visualize it.