Compare commits
14 Commits
69422d1f92
...
01afbea9a3
| Author | SHA1 | Date | |
|---|---|---|---|
| 01afbea9a3 | |||
| 549ea896c7 | |||
| 662211e1c3 | |||
| 5082e6d526 | |||
| 9bf85c79e4 | |||
| 3b0b9d724a | |||
| 915153cb62 | |||
| c0a25c7a26 | |||
| b44bac760d | |||
| ddee170aea | |||
| 04b5aaa0dc | |||
| 5128398516 | |||
| 5d6ac9438d | |||
| 76c2e26e8c |
@@ -8,11 +8,10 @@ RUN npm i --unsafe-perm
|
||||
COPY . ./
|
||||
COPY config_dev.json ./config.json
|
||||
RUN npm run build
|
||||
RUN npm run init-db
|
||||
|
||||
# --- Production stage ---
|
||||
FROM node:24-alpine
|
||||
COPY --from=build /app .
|
||||
ENV HOST=0.0.0.0
|
||||
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"]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import fs from 'fs';
|
||||
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);
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { DB_FULLPATH } from '../../routes';
|
||||
|
||||
const fullPath = './src/lib/data/tatort.db';
|
||||
const dir = path.dirname(fullPath);
|
||||
// make sure the DB is initiated
|
||||
import '../../init/init_db'
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
|
||||
export const db = new Database(fullPath);
|
||||
export const db = new Database(DB_FULLPATH);
|
||||
|
||||
@@ -3,30 +3,10 @@ import type { PageServerLoad } from '../anmeldung/$types';
|
||||
|
||||
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) => {
|
||||
if (!event.locals.user && event.url.pathname !== ROUTE_NAMES.ANMELDUNG)
|
||||
throw redirect(303, ROUTE_NAMES.ANMELDUNG);
|
||||
return {
|
||||
user: event.locals.user,
|
||||
path_existing
|
||||
user: event.locals.user
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<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"
|
||||
><h3>Pfad existiert: {data.path_existing}</h3>
|
||||
>
|
||||
<div class="mx-auto flex justify-center max-w-7xl py-10 px-8 w-full">
|
||||
{#if data.user.admin}
|
||||
<div class="group relative rounded-lg p-6 text-sm leading-6 hover:bg-gray-50 w-1/4">
|
||||
|
||||
@@ -36,3 +36,6 @@ export const API_ROUTES = {
|
||||
USERS: '/api/users',
|
||||
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';
|
||||
@@ -22,9 +22,8 @@ describe('+layout.server load(): Teste korrekte URL', () => {
|
||||
});
|
||||
|
||||
describe('+layout.server load(): Teste erfolgreichen Pfad', () => {
|
||||
// [TODO]
|
||||
test.skip('Werfe kein Fehler', async () => {
|
||||
test('Werfe kein Fehler', async () => {
|
||||
const result = load(mockEvent);
|
||||
expect(result).toEqual({ user: baseData.user });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user