1.0.38 • Published 3 years ago

@payw/eodiro-server-types v1.0.38

Weekly downloads
440
License
MIT
Repository
github
Last release
3 years ago

📦 Spec

Node.js running on NGINX using reverse proxy.

NGINX

SSL: Let's Encrypt and Certbot python plugin

Configuration

Resolve 413 Request Entity Too Large

server {
    client_max_body_size 3M;
}

Don't forget

  • to set timezone correctly of both system and database

Database

It uses MySQL internally as its database.

Installation

Cron

We have multiple periodic jobs. Those are including clearing pending users, garbage collecting dangling user-uploaded files, scraping data from websites and much more. Previously these jobs were running inside the main process through so called node-cron. Unfortunately we faced the issue(#41) where the headless browsers(Zombie.js and Puppeteer) leak memories on every browser instance creation. So, from v2.1.0, they are separated from the main process and moved to cron. This approach additionally provides few improvements as well as resolving the memory leak problem which is critical. They are now isolated and run in background even when the main server process got blocked or updating. It means that periodic jobs never halt and always achieve what they have to.

Configuration


📚 API References

REST

One API (deprecated)


One API (deprecated)

Introducing a new way to create APIs on server side and to use them on client side.

One API does not follow the traditional RESTful way. It has only one endpoint for all of its APIs. All you have to do is send a post request with an action and data.

https://api2.eodiro.com/one

One API Client

Another amazing thing is that the One API provides client side npm module ready to be used right now. Thanks to this module, you don't have to write duplicate type definitions or AJAX calls every time the new APIs are added. Just npm update and you're good to go.

Install

npm install @payw/eodiro-one-api

Dependencies

  • Axios

Usage

import { oneAPIClient } from '@payw/eodiro-one-api'

oneAPIClient(
  action: 'actionName',
  data: { ... }
).then(payload => {
  ...
})

TypeScript will automatically inference the types of request data and payload as you choose the action.

Development Guide


Common

Response

  • Server responds with 500 HTTP response code when there are some problems while processing the APIs

Types

We share some specific types across the APIs.

TypeDetailed Type
Day'sun' \| 'mon' \| 'tue' \| 'wed' \| 'thu' \| 'fri' \| 'sat'
Semester'1' \| '하계' \| '2' \| '동계'
Campus'서울' \| '안성'

Lectures

Get Lectures

Params

KeyType
yearnumber
semesterSemester
campusCampus

Queries

KeyTypeDescription
amount?numberThe number of lectures you get. Default 20.
offset?numberThe start index of lectures. Initial 0.

Search Lectures

Params

KeyType
yearnumber
semesterSemester
campusCampus

Queries

KeyTypeDescription
qstringSearch keyword
amount?numberThe amount of search results. Default 20.
offset?numberThe offset of search results. Initial 0.

Vacant

Get Buildings Vacant

Params

KeyType
yearnumber
semesterSemester
campusCampus

Queries

KeyType
day?Day
hour?number
minute?number

Get Classrooms

Params

KeyType
yearnumber
semesterSemester
campusCampus
buildingstring

Queries

KeyType
day?Day

Cafeteria

Get Menus

Params

KeyType
servedAtYYYY-MM-DD
campusCampus

Response

CodeDescription
204No menus data on the day

Dev Prerequisites

Dev Tools

Node >= 13

MySQL >= 8

Visual Studio Code: We enforce you to use VSCode as an editor for developing the eodiro server.

  • Essential Extensions
    • ESLint
    • Prettier
    • sort-imports
    • Prisma

Config

eodiro

Duplicate src/config/example.ts, rename it to index.ts and fill the information with your environment values.

Prisma

Create prisma/.env and fill with your database information.

DATABASE_URL="mysql://username:password@address:3306/db_name"

NPM Scripts

You can run the scripts below by npm run [script-name].

Application

  • dev: Runs in development mode (listens at port config.DEV_PORT)
    • --nomail: Use this argument if you want to bootstrap the application without an email feature
  • build: Generate JavaScript artifacts into build directory
  • start: Start the production server using the build outputs (listens at port config.PORT)
    • --nomail: Same as above

Database

  • sync-db:prod: Syncs the database models with the database described in config.DB_NAME.
  • sync-db:dev: Same as the previous one but instead syncs with config.DB_NAME_DEV.

CDN

  • cdn:dev: Starts the CDN server in development mode (listens at config.CDN_DEV_PORT)
  • cdn: Starts the CDN server in production mode (listens at config.CDN_PORT)

Prisma

  • introspect: Looks up the database described in prisma/.env and generate a prisma schema file. Never run this script unless there exists any changes in db models. And if you do run, open prisma/schema.prisma and format the file with the Prisma extension in VSCode.
  • generate: Generates Prisma Client with prisma/schema.prisma. Run this script before start developing.
1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.19

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

3 years ago

1.0.12

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago