Vapor server for KPIHub iOS app which is used for:
- Parsing rozklad.kpi.ua or API requests to schedule.kpi.ua
- Parsing campus.kpi.ua.
Server is hosted by digital ocean cloud.
Domain: kpihub.xyz
- Vapor
- vapor-routing (by poinfree)
- fluent-postgres (for storing groups)
- Docker, docker-compose
- Github Actions, Secrets
GET /api/groups/all
GET /api/groups/search?name=$(groupName)
GET /api/group/$(ID)/lessons
GET /api/campus/userInfo?username=$(username)&password=$(password)
GET /api/campus/studySheet?username=$(username)&password=$(password)
The main thing that the server does is parisng.
Looks like rozklad.kpi.ua is migrating to new site schedule.kpi.ua. As rozklad.kpi.ua is not reacheable now, I created a wrapper RozkladV2 above new API.
Every 28th on every mounth crone script updates group list. This is a rather labor-intensive task, and if you do it too often, the rozklad.kpi.ua will ban your IP.
When user request lessons for particular group, server goes to rozklad.kpi.ua and parse lessons live.
Every request for campus-related staff need to be provieded with campus credentials.
Server do not store any credential information. So that’s why u need to pass credentials for every request.
Server use this data for receiving Bearer token and cookies.
At the heart of the approach for routing was taken vapor-routing
by pointfree. This library gives an opportunity to move routing-related code to separate library and use it in iOS application and server.
This server use swift-parsing
library for parsing HTML pages.
Parsers:
-
GroupParser
Receive groups IDs from HTML pages
-
LessonsParser
Extract lessons from two schedule tables (first and second weeks)
-
StudySheetActivitiesParser
Parse studysheet table for all years of study
-
StudySheetLessonsParser
Parse marks from a specific subject table