mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-09-30 04:34:49 +02:00
Merge branch 'main' of github.com:open-reception/appointment-booking-software into 34-api-structure-and-third-party-libs
This commit is contained in:
@@ -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>
|
||||
|
||||
Vendored
+14
-16
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { json } from "@sveltejs/kit";
|
||||
|
||||
export async function GET() {
|
||||
return json(true);
|
||||
}
|
||||
return json(true);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user