14 Commits

Author SHA1 Message Date
01afbea9a3 Merge branch 'development' into f092_ViewAuth-von-User-vereinfachen 2025-10-17 10:37:39 +02:00
549ea896c7 select storage path depending on local testing or prod
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 10:39:07 +02:00
662211e1c3 make sure the DB is initiated
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 09:48:04 +02:00
5082e6d526 select path for DB depending on local or dev environment 2025-10-14 09:40:23 +02:00
9bf85c79e4 clean up, remove console.logs and debugging code 2025-10-14 09:39:06 +02:00
3b0b9d724a testing PV: kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 08:50:55 +02:00
915153cb62 testing PV: kick off build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 08:15:08 +02:00
c0a25c7a26 testing PV: run DB init before server run
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-14 07:46:20 +02:00
b44bac760d testing PV: remove DB init run during build
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:47:46 +02:00
ddee170aea testing: run DB init script before server start
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:41:46 +02:00
04b5aaa0dc testing PV: debug DB init script
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:31:12 +02:00
5128398516 add DB init during container start
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 13:10:02 +02:00
5d6ac9438d testing PV: temporarily disable test creating dir
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
2025-10-13 12:58:54 +02:00
76c2e26e8c test persistent storage
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
2025-10-13 12:44:48 +02:00
7 changed files with 14 additions and 37 deletions

View File

@@ -8,11 +8,10 @@ RUN npm i --unsafe-perm
COPY . ./ COPY . ./
COPY config_dev.json ./config.json COPY config_dev.json ./config.json
RUN npm run build RUN npm run build
RUN npm run init-db
# --- Production stage --- # --- Production stage ---
FROM node:24-alpine FROM node:24-alpine
COPY --from=build /app . COPY --from=build /app .
ENV HOST=0.0.0.0 ENV HOST=0.0.0.0
EXPOSE 3000 EXPOSE 3000
CMD ["sh", "-c", "ORIGIN=https://tatort-dev.innovation-hub-niedersachsen.de node build/index.js"] CMD ["sh", "-c", "npm run init-db && ORIGIN=https://tatort-dev.innovation-hub-niedersachsen.de node build/index.js"]

View File

@@ -1,8 +1,9 @@
import Database from 'better-sqlite3'; import Database from 'better-sqlite3';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { DB_FULLPATH } from '../routes';
const fullPath = './src/lib/data/tatort.db'; const fullPath = DB_FULLPATH;
const dir = path.dirname(fullPath); const dir = path.dirname(fullPath);
if (!fs.existsSync(dir)) { if (!fs.existsSync(dir)) {

View File

@@ -1,12 +1,7 @@
import Database from 'better-sqlite3'; import Database from 'better-sqlite3';
import fs from 'fs'; import { DB_FULLPATH } from '../../routes';
import path from 'path';
const fullPath = './src/lib/data/tatort.db'; // make sure the DB is initiated
const dir = path.dirname(fullPath); import '../../init/init_db'
if (!fs.existsSync(dir)) { export const db = new Database(DB_FULLPATH);
fs.mkdirSync(dir);
}
export const db = new Database(fullPath);

View File

@@ -3,30 +3,10 @@ import type { PageServerLoad } from '../anmeldung/$types';
import { ROUTE_NAMES } from '..'; import { ROUTE_NAMES } from '..';
// *** [START] check for dir
import fs from 'fs';
const path = '/daten';
let path_existing: string;
fs.access(path, fs.constants.F_OK, (err) => {
if (err) {
console.error(`❌ Directory "${path}" does NOT exist or is not accessible.`);
path_existing = "NO";
} else {
console.log(`✅ Directory "${path}" exists and is accessible.`);
path_existing = "YES";
}
});
// ***
export const load: PageServerLoad = (event: ServerLoadEvent) => { export const load: PageServerLoad = (event: ServerLoadEvent) => {
if (!event.locals.user && event.url.pathname !== ROUTE_NAMES.ANMELDUNG) if (!event.locals.user && event.url.pathname !== ROUTE_NAMES.ANMELDUNG)
throw redirect(303, ROUTE_NAMES.ANMELDUNG); throw redirect(303, ROUTE_NAMES.ANMELDUNG);
return { return {
user: event.locals.user, user: event.locals.user
path_existing
}; };
}; };

View File

@@ -11,7 +11,7 @@
<div <div
class=" inset-x-0 top-0 -z-10 h-full flex items-center justify-center bg-white shadow-lg ring-1 ring-gray-900/5" class=" inset-x-0 top-0 -z-10 h-full flex items-center justify-center bg-white shadow-lg ring-1 ring-gray-900/5"
><h3>Pfad existiert: {data.path_existing}</h3> >
<div class="mx-auto flex justify-center max-w-7xl py-10 px-8 w-full"> <div class="mx-auto flex justify-center max-w-7xl py-10 px-8 w-full">
{#if data.user.admin} {#if data.user.admin}
<div class="group relative rounded-lg p-6 text-sm leading-6 hover:bg-gray-50 w-1/4"> <div class="group relative rounded-lg p-6 text-sm leading-6 hover:bg-gray-50 w-1/4">

View File

@@ -36,3 +36,6 @@ export const API_ROUTES = {
USERS: '/api/users', USERS: '/api/users',
USER: (userId: string) => `/api/users/${userId}` USER: (userId: string) => `/api/users/${userId}`
}; };
const isProd = process.env.NODE_ENV == 'production';
export const DB_FULLPATH = !isProd ? './src/lib/data/tatort.db' : '/daten/tatort.db';

View File

@@ -22,9 +22,8 @@ describe('+layout.server load(): Teste korrekte URL', () => {
}); });
describe('+layout.server load(): Teste erfolgreichen Pfad', () => { describe('+layout.server load(): Teste erfolgreichen Pfad', () => {
// [TODO] test('Werfe kein Fehler', async () => {
test.skip('Werfe kein Fehler', async () => {
const result = load(mockEvent); const result = load(mockEvent);
expect(result).toEqual({ user: baseData.user }); expect(result).toEqual({ user: baseData.user });
}); });
}); });