From b83d814c7caa81f6a93e68b78d74df647e847b7b Mon Sep 17 00:00:00 2001 From: BolkeDerBaer Date: Sat, 28 Feb 2026 00:12:54 +0100 Subject: [PATCH] docs: update README to reflect project name change and enhance setup instructions --- readme.md | 62 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/readme.md b/readme.md index cd163fc..e8f241c 100644 --- a/readme.md +++ b/readme.md @@ -1,33 +1,61 @@ +**Project** +- **Name:**: Simple WebUntis → PocketBase sync +- **Description:**: A small Node.js script that fetches your WebUntis timetable and synchronizes classes into a PocketBase collection. -# Moodle Timetable Server +**Files** +- **Main script:**: [index.js](index.js) +- **Package metadata:**: [package.json](package.json) +- **Dockerfile:**: [dockerfile](dockerfile) -A Node.js server that fetches timetable data from WebUntis. +**Requirements** +- **Node.js:**: v14+ recommended +- **Environment:**: A PocketBase instance reachable from the script (the URL is currently set inside `index.js`). -## Setup +**Dependencies** +- **webuntis**: fetches timetable data +- **pocketbase**: PocketBase client +- **luxon**: date handling +- **dotenv**: load environment variables + +**Configuration** +- **Environment variables:**: Create a `.env` in the project root with at least: -1. Install dependencies: -```bash -npm install express dotenv luxon webuntis ``` - -2. Create a `.env` file with: -```env -PORT=3000 WEBUNTIS_SCHOOL=your_school WEBUNTIS_USER=your_username WEBUNTIS_PASS=your_password WEBUNTIS_URL=your_webuntis_url ``` -## API Endpoints +- **PocketBase URL:**: The script currently instantiates PocketBase with a hard-coded URL (`https://fsae41.de`). Edit `index.js` to change this or make it configurable via an env var. -- `GET /` - Health check -- `GET /timetable` - Fetch timetable for next 4 weeks - -## Running +**Install** ```bash -node server.js +npm install ``` -Server runs on `http://localhost:3000` by default. +**Run** + +```bash +node index.js +``` + +The script runs an initial sync and then repeats every 30 minutes (see `setInterval` near the end of `index.js`). + +**Behavior** +- **Merging lessons:**: The script sorts and merges adjacent lessons that end and start at the same time on the same day. +- **PocketBase collection:**: Records are created/updated in the `classes` collection. Existing records are compared and updated if changes are detected. + +**Docker** +- A `dockerfile` is present; you can containerize the app. Ensure environment variables and PocketBase URL are provided to the container. + +**Notes & Next steps** +- Consider moving the PocketBase URL into `.env` for easier configuration. +- Add error handling and logging for production use. + +**License** +- No license specified. Add one if you plan to publish. + +**Contact** +- Questions or improvements: edit `index.js` and open an issue or PR in your repo.