mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
refactor(server): non-DI islands read env via app-config
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readEnv } from '../app-config';
|
||||
|
||||
const dataDir = path.join(__dirname, '../../data');
|
||||
const dbPath = path.join(dataDir, 'travel.db');
|
||||
@@ -14,7 +15,8 @@ function resetDemoUser(): void {
|
||||
const { db, closeDb, reinitialize } = require('../db/database');
|
||||
|
||||
// Save admin's current credentials and API keys (these should survive the reset)
|
||||
const adminEmail = process.env.DEMO_ADMIN_EMAIL || 'admin@nomad.app';
|
||||
// NOTE: different default than demo-seed (admin@trek.app) — pinned legacy quirk.
|
||||
const adminEmail = readEnv().demo.adminEmailRaw || 'admin@nomad.app';
|
||||
interface AdminData { password_hash: string; maps_api_key: string | null; openweather_api_key: string | null; unsplash_api_key: string | null; avatar: string | null; }
|
||||
let adminData: AdminData | undefined = undefined;
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import Database from 'better-sqlite3';
|
||||
import { readEnv } from '../app-config';
|
||||
|
||||
function seedDemoData(db: Database.Database): { adminId: number; demoId: number } {
|
||||
const ADMIN_USER = process.env.DEMO_ADMIN_USER || 'admin';
|
||||
const ADMIN_EMAIL = process.env.DEMO_ADMIN_EMAIL || 'admin@trek.app';
|
||||
const ADMIN_PASS = process.env.DEMO_ADMIN_PASS || 'admin12345';
|
||||
const ADMIN_USER = readEnv().demo.adminUser;
|
||||
const ADMIN_EMAIL = readEnv().demo.adminEmailRaw || 'admin@trek.app';
|
||||
const ADMIN_PASS = readEnv().demo.adminPass;
|
||||
const DEMO_EMAIL = 'demo@trek.app';
|
||||
const DEMO_PASS = 'demo12345';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user