ita666 / Innovorder

SImple NestJS API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nest Logo

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

Coverage Discord

Description

Step by step guidance to install and run the API

Installation

$ npm install

Database SetUp

This API runs on a MySQL Database - the syntax for MySQL database URL is:

mysql://<user>:<password>@localhost:3306/<database-name>

First generate the database tables by running the command

$ npm run prisma:migrate

Then deploy the database for development or test purposes

$ npm run prisma:deploy:dev     or    npm run prisma:deploy:test

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Environment Variables

This project requires some environment variables in order to function - The app will not work without these variables, please populate them accordingly

These variables should be set in a '.env' file at the source of the project, and in a '.env.test' file for test-related environment variables

Below, an example of these variables:

# MySQL database URL with correct syntax
DATABASE_URL="mysql://<user>:<password>@localhost:3306/<database>"

# Key used to hash Jwt
JWT_KEY="<secret-key>"

# Possible values: "error", "warn", "info", "debug"
LOGGER_LEVEL="<value>"

Routes

Users

Returns the information about the current user

# GET
# JWT-PROTECTED

users/me

Returns the information about the user corresponding to the 'id' param

# GET
# JWT-PROTECTED
# @Param - id: string

users/:id

Updates the User corresponding to the 'id' param, returns the updated user data including a new token

# PATCH
# JWT-PROTECTED
# @Param - id: string
# @Body - (optional params) {email: string, firstName: string, lastName: string, password: string}

users/:id

Auth

Creates a user in the database and returns a jwt token

# POST
# @Param - {email: string, firstName: string, lastName: string, password: string}

auth/signup

Logs in a user and returns a jwt token if email & password are correct

# POST
# @Param - {email: string, password: string}

auth/login

Products

Returns the information about the product corresponding to the @id param, id representing the product's bar code | Cached for 5 minutes with key: 'offApiCalls - id'

# GET
# JWT-PROTECTED
# @Param - {id: string}

products/:id

License

Nest is [MIT licensed].

About

SImple NestJS API


Languages

Language:TypeScript 98.7%Language:JavaScript 1.0%Language:Shell 0.3%