chore: add package.json with initial dependencies and project metadata

This commit is contained in:
2026-02-27 22:00:22 +01:00
parent 20b908d397
commit a5ae3f9e52
4 changed files with 1172 additions and 0 deletions

39
index.js Normal file
View File

@@ -0,0 +1,39 @@
require('dotenv').config()
const express = require('express')
const luxon = require('luxon');
const { WebUntis } = require('webuntis');
const app = express()
const port = process.env.PORT || 3000
app.get('/', (req, res) => {
res.send('server is running')
})
app.get('/timetable', async (req, res) => {
const untis = new WebUntis(process.env.WEBUNTIS_SCHOOL, process.env.WEBUNTIS_USER, process.env.WEBUNTIS_PASS, process.env.WEBUNTIS_URL);
try {
await untis.login();
// Start und Ende der aktuellen Woche bestimmen
const now = luxon.DateTime.local();
const startOfWeek = now.startOf('week').toJSDate(); // Montag
const endOfWeek = now.endOf('week').plus({ days: 7*4*4 }).toJSDate(); // Sonntag
// Stundenplan für diese Woche abrufen
const timetable = await untis.getOwnTimetableForRange(startOfWeek, endOfWeek);
await untis.logout();
res.json({ status: 'success', data: timetable });
} catch (error) {
console.log(error);
res.statusCode = 500;
res.json({ status: 'error', message: error.message || error.toString() });
}
})
console.log(process.env)
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})