Skip to content

master4-2021/ZUJ

Repository files navigation

Nest Logo

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

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Create database server

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-22-04

Installation

$ yarn install

Prepare husky

$ yarn prepare

Initialize database

# dev env
$ NODE_ENV=dev yarn run initDb
# prod env
$ NODE_ENV=prod yarn run initDb

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Environment variables

dev env

Create env file: .env.dev in the root

PORT=4000
HOST='localhost'
JWT_SECRET='jwt-secret'
JWT_EXPIRES_IN=3600
JWT_REFRESH_SECRET='jwt-refresh-secret'
JWT_REFRESH_EXPIRES_IN=2592000
ENCRYPTION_SECRET='encryption-secret'
SALT_OR_ROUND=10
MYSQL_URL="mysql://admin:master42023@mysql-2.coybptane5cg.ap-southeast-1.rds.amazonaws.com:3306/master4" # mysql://username:password@host:port/database_name
MYSQL_HOST=mysql-2.coybptane5cg.ap-southeast-1.rds.amazonaws.com
MYSQL_PORT=3306
MYSQL_USERNAME=admin
MYSQL_PASSWORD=master42023
MYSQL_DATABASE=master4
MYSQL_SYNCRONIZE=true
MYSQL_DROP_SCHEMA=false

e2e env

Create env file: .env.e2e in the root

PORT=4009
HOST='localhost'
JWT_SECRET='jwt-secret'
JWT_EXPIRES_IN=3600
JWT_REFRESH_SECRET='jwt-refresh-secret'
JWT_REFRESH_EXPIRES_IN=2592000
ENCRYPTION_SECRET='encryption-secret'
SALT_OR_ROUND=10
MYSQL_URL="mysql://admin:master42023@mysql-2.coybptane5cg.ap-southeast-1.rds.amazonaws.com:3306/master4_e2e" # mysql://username:password@host:port/database_name
MYSQL_HOST=mysql-2.coybptane5cg.ap-southeast-1.rds.amazonaws.com
MYSQL_PORT=3306
MYSQL_USERNAME=admin
MYSQL_PASSWORD=master42023
MYSQL_DATABASE=master4_e2e
MYSQL_SYNCRONIZE=true
MYSQL_DROP_SCHEMA=true

APIs

Login

[POST] /api/auth/login
- Body: 
{
  "username": "root",
  "password": "root"
}

- Response: 
{
  "url": "[POST] /api/auth/login",
  "success": true,
  "statusCode": 201,
  "message": "OK",
  "data": {
    "refreshToken": "*****",
    "iv": "f23957f0bcf745b530c05f5d540441aa",
    "userId": "29b98f22-5bf9-494b-818c-7ae549d0fef5",
    "refreshExpiresIn": "2023-06-07T09:03:21.420Z",
    "id": "56d3bb08-ccc4-477b-bb0e-bb237f416fe6",
    "createdAt": "2023-05-08T02:03:21.556Z",
    "updatedAt": "2023-05-08T02:03:21.556Z",
    "accessToken": "*****"
  },
  "correlationId": "ffc7ec92-013e-400e-9d97-136d0a244f24",
  "timestamp": "2023-05-08T16:03:21.720+07:00",
  "took": "650 ms"
}

Get fixture calendar

[GET] /api/fixture/calendar?from=2023-05-01T00%3A00%3A00.000%2B07%3A00&to=2023-05-31T23%3A59%3A59.999%2B07%3A00

- Query (must be endcoded):
{
  "from": "2023-05-01T00:00:00.000+07:00",
  "to": "2023-05-31T23:59:59.999+07:00"
}

- Headers:
Authorization: "Bearer ${token}"

- Response:
{
  "url": "[GET] /api/fixture/calendar?from=2023-05-01T00%3A00%3A00.000%2B07%3A00&to=2023-05-31T23%3A59%3A59.999%2B07%3A00",
  "success": true,
  "statusCode": 200,
  "message": "OK",
  "data": [
    "2023-05-04T02:00:00.000+07:00",
    "2023-05-04T02:00:00.000+07:00",
    "2023-05-11T02:00:00.000+07:00",
    "2023-05-11T02:00:00.000+07:00"
  ],
  "correlationId": "df672c2f-8577-42b5-9f9e-c47c592431eb",
  "timestamp": "2023-05-08T09:32:44.304+07:00",
  "took": "17 ms"
}

Get fixtures

[GET] /api/fixture?type=filter&filter%5BkickoffTime%5D%5Bgte%5D=2023-05-04T00%3A00%3A00.000%2B07%3A00&filter%5BkickoffTime%5D%5Blte%5D=2023-05-04T23%3A59%3A59.999%2B07%3A00&skip=0&limit=1

- Query (must be encoded):
{
  "type": "filter",
  "filter": {
    "kickoffTime": {
      "gte": "2023-05-04T00:00:00.000+07:00",
      "lte": "2023-05-04T23:59:59.999+07:00"
    }
  },
  "skip": "0",
  "limit": "1"
}

- Headers:
Authorization: "Bearer ${token}"

- Response:
{
  "url": "[GET] /api/fixture?type=filter&filter%5BkickoffTime%5D%5Bgte%5D=2023-05-04T00%3A00%3A00.000%2B07%3A00&filter%5BkickoffTime%5D%5Blte%5D=2023-05-04T23%3A59%3A59.999%2B07%3A00&skip=0&limit=1",
  "success": true,
  "statusCode": 200,
  "message": "OK",
  "data": [
    {
      "id": "78667739-e85c-45f6-831c-e43e4fd3d8be",
      "createdAt": "2023-05-08T02:32:43.190Z",
      "updatedAt": "2023-05-08T02:32:43.190Z",
      "tournamentId": "2862927d-7b05-4bc2-a3e0-850574d33717",
      "homeId": "5c6c77bf-2578-47aa-a6ab-887b0d176b86",
      "homeScore": 3,
      "awayId": "061a385a-1eef-40d5-ae81-3b5f363ec054",
      "awayScore": 2,
      "kickoffTime": "2023-05-03T19:00:00.000Z",
      "round": 13,
      "status": "finished",
      "tournament": {
        "id": "2862927d-7b05-4bc2-a3e0-850574d33717",
        "createdAt": "2023-05-08T02:32:42.997Z",
        "updatedAt": "2023-05-08T02:32:42.997Z",
        "name": "Europa League",
        "shortName": "EL",
        "region": "eu",
        "code": "el_eu",
        "logo": "https://upload.wikimedia.org/wikipedia/en/3/3e/Europa_League_logo_2010.svg"
      },
      "home": {
        "id": "5c6c77bf-2578-47aa-a6ab-887b0d176b86",
        "createdAt": "2023-05-08T02:32:43.087Z",
        "updatedAt": "2023-05-08T02:32:43.087Z",
        "name": "Borussia Monchengladbach",
        "shortName": "BMG",
        "logo": "https://upload.wikimedia.org/wikipedia/en/0/04/FC_Bayern_Munich_logo.svg",
        "region": "de"
      },
      "away": {
        "id": "061a385a-1eef-40d5-ae81-3b5f363ec054",
        "createdAt": "2023-05-08T02:32:43.084Z",
        "updatedAt": "2023-05-08T02:32:43.084Z",
        "name": "RB Leipzig",
        "shortName": "RBL",
        "logo": "https://upload.wikimedia.org/wikipedia/en/9/9c/Borussia_Dortmund_logo.svg",
        "region": "de"
      }
    }
  ],
  "correlationId": "4de8d9f2-c8bc-4f0a-9b11-d2899525ac5c",
  "timestamp": "2023-05-08T09:32:44.347+07:00",
  "took": "24 ms"
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages