Merge branch 'main' of github.com:open-reception/appointment-booking-software into 34-api-structure-and-third-party-libs

This commit is contained in:
Hendrik Belitz
2025-06-24 14:40:13 +02:00
13 changed files with 368 additions and 172 deletions
+9 -9
View File
@@ -1,15 +1,15 @@
<script>
import { onMount } from 'svelte';
let envVarsOkay = {};
onMount(async () => {
const response = await fetch('/api/env');
envVarsOkay = (await response.json()).envOkay ? "okay" : "not okay";
});
import { onMount } from "svelte";
let envVarsOkay = {};
onMount(async () => {
const response = await fetch("/api/env");
envVarsOkay = (await response.json()).envOkay ? "okay" : "not okay";
});
</script>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
<p>Environment configuration is {envVarsOkay}</p>
<p>Environment configuration is {envVarsOkay}</p>
+14 -16
View File
@@ -1,21 +1,19 @@
import { json } from '@sveltejs/kit';
import dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand'
import { json } from "@sveltejs/kit";
import dotenv from "dotenv";
import dotenvExpand from "dotenv-expand";
const cfg = dotenv.config()
dotenvExpand.expand(cfg)
const cfg = dotenv.config();
dotenvExpand.expand(cfg);
export async function GET() {
let envOkay = true;
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "development")
envOkay = false;
if (!process.env.DATABASE_URL?.startsWith("postgres:")) envOkay = false;
let envOkay = true;
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "development")
envOkay = false;
if (!process.env.DATABASE_URL?.startsWith("postgres:"))
envOkay = false;
console.warn("Environment is okay", envOkay);
console.warn("Environment is okay", envOkay)
return json({
envOkay
});
}
return json({
envOkay
});
}
+3 -3
View File
@@ -1,5 +1,5 @@
import { json } from '@sveltejs/kit';
import { json } from "@sveltejs/kit";
export async function GET() {
return json(true);
}
return json(true);
}
+10 -1
View File
@@ -1,9 +1,18 @@
import { describe, test, expect } from "vitest";
import { describe, test, expect, vi, beforeEach } from "vitest";
import "@testing-library/jest-dom/vitest";
import { render, screen } from "@testing-library/svelte";
import Page from "./+page.svelte";
describe("/+page.svelte", () => {
beforeEach(() => {
// Mock fetch to avoid the "Invalid URL" error
global.fetch = vi.fn(() =>
Promise.resolve({
json: () => Promise.resolve({ envOkay: true })
} as Response)
);
});
test("should render h1", () => {
render(Page);
expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();