chore: add package.json with initial dependencies and project metadata
This commit is contained in:
29
.gitignore
vendored
Normal file
29
.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/node
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
39
index.js
Normal file
39
index.js
Normal 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}`)
|
||||
})
|
||||
1081
package-lock.json
generated
Normal file
1081
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
package.json
Normal file
23
package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "moodle",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.bolke.org/BolkeDerBaer/moodle.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"dotenv": "^17.3.1",
|
||||
"express": "^5.2.1",
|
||||
"luxon": "^3.7.2",
|
||||
"webuntis": "^2.2.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user