Giter VIP home page Giter VIP logo

api-server's Introduction

SESC-master-api-server

This is GraphQL API server for sescmaster.

Installation:

yarn install

Building:

yarn build

Start:

yarn start

Principe

Caches

Caches are objects, that implements ICache interface. They should somehow store data, and return it with async getValue method. Also, Cache object should update data by updateValue async method and return true, if values is different.

There used simple Cache class and caches, that store data in memory, like common object's fields. But others that implement the ICache interface can be used.

Parsers

Parsers are just functions, that parse html pages or JS scripts from site of SESC UrFU. List of them below, in table of updaters.

Updaters

Updaters are objects of Updater class, that execute updater function by schedule and load value to provided cache. If updater function has returned new value (that is not equal with previous one), updater executes onChange function (if this one`s provided) and triggers updaters, which are subscribed to executed one.

Updater Parsers Parsing time Required link
IDsUpdater parseIDs.ts 09-01-07:00 https://lyceum.urfu.ru/ucheba/raspisanie-zanjatii
calendarChartsUpdater parseCalendarChart.ts parseLessonsTimings.ts 09-01-07:00 https://lyceum.urfu.ru/fileadmin/user_upload/scripts/zvonkiCalGraf.js
announcementsUpdater parseAnnouncements.ts 07:00 https://lyceum.urfu.ru/dopolnitelnye-stranicy/objavlenija
schedulesUpdater Every 30 minutes IDsUpdater https://lyceum.urfu.ru/ucheba/raspisanie-zanjatii
eatTimingsUpdater parseEatTimings.ts 09-01-07:00 calendarChartsUpdater https://lyceum.urfu.ru/ucheba/godovoi-kalendarnyi-grafik

SESCRequest

SESCRequest is function, that just return body of HTTPS response as string by options or URL. Also, it redoes HTTPS request, if got stub page with text Page is being generated.. And if got 502 HTTP code, function locks for a time in SESC_REQUEST_LOCK_DELAY environment variable. These 2 aspects are necessary, because of the CRM and nginx configuration used on the SESC UrFU site.

Environment

This is an example .env file:

PORT=4000

SESC_REQUEST_LOCK_DELAY=10000

SCHEDULES_MAX_PARALLEL_REQUESTS=10

GRAPHQL_LANDING_PAGE=playground

SCHEDULING_TZ=Asia/Yekaterinburg

PORT

This variable specifies port, on which server will listen. Default value is 4000.

SCHEDULES_TYPE_DELAY

This variable specifies delay in milliseconds between several requests for schedules of weekday with different types. If it`s not defined, delay will not occur.

SCHEDULES_MAX_PARALLEL_REQUESTS

This variable specifies max parallel requests when getting a schedule in schedulesUpdater. If defined value less than 1, value will be forced to 1. Default value is 10.

GRAPHQL_LANDING_PAGE

This variable specifies landing page of graphql endpoint. If it is set playground, on endpoint in browser will be GraphQL Playground page, otherwise nothing.

SCHEDULING_TZ

This variable specifies timezone for schedules of updaters. Default is Asia/Yekaterinburg, because of SESC UrFU location.

api-server's People

Contributors

lukramancer avatar unusualnick avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.