Skip to content

Commit

Permalink
fix(config): log when invalid config (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinTh authored Sep 18, 2024
1 parent bbe01e4 commit 4e61c2c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/app-server/src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import process, { env } from 'node:process';
import { safelySync } from '@corentinth/chisels';
import { serve } from '@hono/node-server';
import { serveStatic } from '@hono/node-server/serve-static';
import { getConfig } from './modules/app/config/config';
import { createServer } from './modules/app/server';

import { deleteExpiredNotesTask } from './modules/notes/tasks/delete-expired-notes.tasks';
import { createLogger } from './modules/shared/logger/logger';
import { createFsLiteStorage } from './modules/storage/factories/fs-lite.storage';
import { createTaskScheduler } from './modules/tasks/task-scheduler';

const config = getConfig({ env });
const logger = createLogger({ namespace: 'app-server' });

const [config, configError] = safelySync(() => getConfig({ env }));

if (configError) {
logger.error({ error: configError }, `Invalid config: ${configError.message}`);
process.exit(1);
}

const { storage } = createFsLiteStorage({ config });

const { app } = createServer({ config, storageFactory: () => ({ storage }) });
Expand Down

0 comments on commit 4e61c2c

Please sign in to comment.