From 09d1925cc06a31a990a0bec30f9adfc4028caa65 Mon Sep 17 00:00:00 2001 From: michivonah Date: Sun, 7 Sep 2025 21:42:03 +0200 Subject: [PATCH] begin basic app structure --- README.md | 7 ++++ api.md | 54 +++++++++++++++++++++++++ themepark-assistant/src/index.ts | 14 +++++-- themepark-assistant/src/logbook.ts | 13 ++++++ themepark-assistant/src/notification.ts | 13 ++++++ 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 api.md create mode 100644 themepark-assistant/src/logbook.ts create mode 100644 themepark-assistant/src/notification.ts diff --git a/README.md b/README.md index 14d9b9c..a6c73de 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # themepark-assistant A tool for improving your trips to themepark - once developed + +## Testing +Send request + +```bash +curl -H "Authorization: Bearer insecure-token" http://127.0.0.1:8787/notification/list +``` \ No newline at end of file diff --git a/api.md b/api.md new file mode 100644 index 0000000..877fa09 --- /dev/null +++ b/api.md @@ -0,0 +1,54 @@ +# API structure + +## Required endpoints +- authentication (via GitHub OAuth?) + - login + - logout +- list all available themeparks +- list all attractions per themepark +- notification + - list all configured targets + - add webhook target + - remove webhook target + - enable notifications for target + - disable notifications for target + - subscribe attraction + - unsubscribe attraction +- logbook + - list all entries + - option to filter by date (via request parameters) + - option to filter by themepark (via request parameters) + - or both (via request parameters) + - add entry + - remove entry +- user settings + - delete account + +## Concept +- /auth -> for authentication purposes +- /themepark/list -> list all themeparks +- /themepark/list/attraction -> list all attractions from a themepark + - parameters: themepark +- /attraction + - //subscribe -> subscribe notifications + - //unsubscribe -> unsubscribe notifications +- /notification + - /list + - parameters: date, themepark + - /add-target + - parameters: name, url + - /remove-target + - parmeters: target-id + - /enable-notification + - /disable-notification +- /logbook + - /list + - parameters: date, themepark -> both optional + - /add-entry + - parameters: attraction, expected-waittime, real-waittime, unix-timestamp + - /edit-entry -> optional, if it makes sense + - parameters: entry-id, attraction, expected-waittime, real-waittime + - /remove-entry + - parameters: entry-id +- /user + - /delete-account -> deletes current account & all associated data instantly diff --git a/themepark-assistant/src/index.ts b/themepark-assistant/src/index.ts index 3191383..7c67a94 100644 --- a/themepark-assistant/src/index.ts +++ b/themepark-assistant/src/index.ts @@ -1,9 +1,17 @@ import { Hono } from 'hono' +import { bearerAuth } from 'hono/bearer-auth' +import notification from './notification' +import logbook from './logbook' +// create app const app = new Hono() -app.get('/', (c) => { - return c.text('Hello Hono!') -}) +// add bearer authentication +const token = 'insecure-token' +app.use('/*', bearerAuth({ token })) + +// define routes & export app +app.route('/notification', notification) +app.route('/logbook', logbook) export default app diff --git a/themepark-assistant/src/logbook.ts b/themepark-assistant/src/logbook.ts new file mode 100644 index 0000000..fa36f1e --- /dev/null +++ b/themepark-assistant/src/logbook.ts @@ -0,0 +1,13 @@ +import { Hono } from 'hono' + +const app = new Hono() + +app.get('/list', (c) => { + return c.json( + { + message: 'List all logbook entries' + } + ) +}) + +export default app \ No newline at end of file diff --git a/themepark-assistant/src/notification.ts b/themepark-assistant/src/notification.ts new file mode 100644 index 0000000..114fbf4 --- /dev/null +++ b/themepark-assistant/src/notification.ts @@ -0,0 +1,13 @@ +import { Hono } from 'hono' + +const app = new Hono() + +app.get('/list', (c) => { + return c.json( + { + message: 'List all notification methods' + } + ) +}) + +export default app \ No newline at end of file