SomeRandomDolphin / RPLorer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RPLorer Backend

Prerequisite

  1. Typescript
  2. Nodejs
  3. Docker

Quick Start

Clone the repo:

git clone https://github.com/SomeRandomDolphin/RPLorer.git

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables

set up postgres database using docker

# set up postgres with docker
docker-compose up -d

Commands

Running the application:

# running locally
npm run dev

# running in prodution
npm run start
# migrate and seed database
prisma migrate dev
prisma db seed

access localhost:8000

Program flow

request > router > controller > service > repository > service > controller > router > response

Git Commit Message

It is forced to commit Conventional Commit to this repository. For commiting in this style you can use this VSCode Extension.

Project Structure

prisma\
 |--migration\      # migration history
 |--schema.prisma   # database schema
src\
 |--config\         # Environment variables and configuration related things
 |--controller\     # Route controllers (controller layer)
 |--middleware\     # Custom express middlewares
 |--model\          # interface models (data layer)
 |--repository\     # database queries
 |--router\         # Routes
 |--seed\           # database seeding
 |--service\        # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--index.ts        # App entry point

Response Format (Error handling)

Response api functions are arranged in API-Response file containing:

  1. responseOK
  2. responseData
  3. responseError

Success

{
    message: string, (optional)
    data: [] or {}
}

Error

{
    message: string,
    errors: {
        field1: "error message",
        field2: "error message",
        ...
    }
}

API Documentation

Please refer to this postman

References

  1. setting up ts and node
  2. migration
  3. seeding
  4. unknown type checking
  5. envalid
  6. prisma cli commands
  7. postgres docker
  8. boilerplate #1
  9. boilerplate #2
  10. prisma error reference
  11. prisma handling exception
  12. typescript ellipsis

About


Languages

Language:TypeScript 96.7%Language:JavaScript 2.9%Language:Shell 0.4%