Initial commit: Cat Sitting Planner with PWA, SQLite, and Webhook Notifications

This commit is contained in:
2026-01-12 20:48:23 +01:00
commit 3121ef223d
52 changed files with 13722 additions and 0 deletions

23
lib/notifications.ts Normal file
View File

@@ -0,0 +1,23 @@
export async function sendNotification(webhookUrl: string | null, message: string) {
if (!webhookUrl) return;
try {
const response = await fetch(webhookUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": "CatSittingPlanner/1.0"
},
// Works for Discord (content) and generic Telegram Webhook bridges (text)
body: JSON.stringify({
content: message,
text: message
}),
});
if (!response.ok) {
console.error(`[Notification] Webhook failed with status ${response.status}`);
}
} catch (error) {
console.error("Failed to send notification:", error);
}
}

17
lib/prisma.ts Normal file
View File

@@ -0,0 +1,17 @@
import { PrismaClient } from '@prisma/client'
const prismaClientSingleton = () => {
return new PrismaClient()
}
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton | undefined
}
const prisma = globalForPrisma.prisma ?? prismaClientSingleton()
export default prisma
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

6
lib/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}