🎨 Make the parser modular

- Move some DSB related functions from parser/index to parser/dsbmobile
- Make the dsb parser a fileProvider with the DSBClient class
- Initialize the parser with a fileProvider and documentParser instance
This commit is contained in:
2023-06-02 16:59:20 +02:00
parent 54fa25f3dd
commit c6120e5f68
3 changed files with 48 additions and 42 deletions

View File

@ -11,6 +11,8 @@ import {
} from "./api/index.js";
import auth from "./api/auth.js";
import { Parser } from "./parser/index.js";
import { DSBClient } from "./parser/dsbmobile.js";
import { parseSubstitutionPlan } from "./parser/untis.js";
// Check DSB Mobile credentials are supplied
if (!process.env.DSB_USER || !process.env.DSB_PASSWORD) {
@ -28,8 +30,8 @@ app.use(express.urlencoded({ extended: true }));
// Initialize the Parser and set it to update the
// substitution plan at the specified update interval
new Parser(
process.env.DSB_USER,
process.env.DSB_PASSWORD,
new DSBClient(process.env.DSB_USER, process.env.DSB_PASSWORD),
parseSubstitutionPlan,
process.env.UPDATE_INTERVAL || 1 * 60 * 1000 // Default to 1 minute
);