1
0

feat: Convert to modules
All checks were successful
Remote Deploy / deploy (push) Successful in 3s

This commit is contained in:
2025-08-31 16:48:40 +02:00
parent 1a29836e44
commit c82fef9e4f
9 changed files with 23 additions and 129 deletions

View File

@@ -1,9 +1,9 @@
const XLSX = require('xlsx');
const fs = require("fs");
const parseAbsence = require('./utils/parseAbsence');
const parseTeachers = require('./utils/parseTeachers');
import XLSX from "xlsx";
import fs from "fs";
import parseAbsence from "./utils/parseAbsence.js";
import parseTeachers from "./utils/parseTeachers.js";
async function parseThisShit(downloadedFilePath) {
export default async function parseThisShit(downloadedFilePath) {
const workbook = XLSX.readFile(downloadedFilePath);
const sheetNames = workbook.SheetNames;
@@ -138,6 +138,4 @@ async function parseThisShit(downloadedFilePath) {
fs.writeFileSync('db/current.json', JSON.stringify(data));
}
module.exports = parseThisShit;
// parseThisShit("downloads/table.xlsx");

View File

@@ -1,7 +1,7 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
const parseThisShit = require('./parse');
import puppeteer from 'puppeteer';
import path from 'path';
import fs from 'fs';
import parseThisShit from './parse.js';
const EMAIL = process.env.EMAIL;
const PASSWORD = process.env.PASSWORD;

View File

@@ -1,4 +1,4 @@
function parseAbsence(str, teacherMap) {
export default function parseAbsence(str, teacherMap) {
str = str.trim().replace(/\s+/g, " ");
const result = {
@@ -40,5 +40,3 @@ function parseAbsence(str, teacherMap) {
return result;
}
module.exports = parseAbsence;

View File

@@ -1,9 +1,8 @@
const cheerio = require("cheerio");
const fetch = require("node-fetch");
import * as cheerio from "cheerio";
globalThis.File = class File {};
async function parseTeachers() {
export default async function parseTeachers() {
const url = "https://spsejecna.cz/ucitel";
const response = await fetch(url);
const data = await response.text(); // fetch needs .text() to get HTML
@@ -24,5 +23,3 @@ async function parseTeachers() {
return map;
}
module.exports = parseTeachers;