- Neue CalDAV-Route mit PROPFIND und GET-Endpoints - ICS-Format-Generator für Buchungsdaten - Token-basierte Authentifizierung für CalDAV-Zugriff - Admin-Interface mit CalDAV-Link-Generator - Schritt-für-Schritt-Anleitung für Kalender-Apps - 24h-Token-Ablaufzeit für Sicherheit - Unterstützung für Outlook, Google Calendar, Apple Calendar, Thunderbird Fixes: Admin kann jetzt Terminkalender in externen Apps abonnieren
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { call, os } from "@orpc/server";
|
|
import { z } from "zod";
|
|
import { randomUUID } from "crypto";
|
|
import { createKV } from "../../lib/create-kv.js";
|
|
const DemoSchema = z.object({
|
|
id: z.string(),
|
|
value: z.string(),
|
|
});
|
|
// createKV provides simple key-value storage with publisher/subscriber support
|
|
// perfect for live queries and small amounts of data
|
|
const kv = createKV("demo");
|
|
// Handler with input validation using .input() and schema
|
|
const create = os
|
|
.input(DemoSchema.omit({ id: true }))
|
|
.handler(async ({ input }) => {
|
|
const id = randomUUID();
|
|
const item = { id, value: input.value };
|
|
await kv.setItem(id, item);
|
|
});
|
|
const remove = os.input(z.string()).handler(async ({ input }) => {
|
|
await kv.removeItem(input);
|
|
});
|
|
// Handler without input - returns all items
|
|
const list = os.handler(async () => {
|
|
return kv.getAllItems();
|
|
});
|
|
// Live data stream using generator function
|
|
// Yields initial data, then subscribes to changes for real-time updates
|
|
const live = {
|
|
list: os.handler(async function* ({ signal }) {
|
|
yield call(list, {}, { signal });
|
|
for await (const _ of kv.subscribe()) {
|
|
yield call(list, {}, { signal });
|
|
}
|
|
}),
|
|
};
|
|
export const router = {
|
|
create,
|
|
remove,
|
|
list,
|
|
live,
|
|
};
|