💾 Archived View for iich.space › src › index.ts captured on 2022-03-01 at 15:59:14.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

🚧 View Differences

-=-=-=-=-=-=-

import { readFileSync } from 'fs';

import dotenv from '@/dotenv';
import { createServer } from '@/gemini';
import { I18n, createApplication, files } from '@/mission-control';

if (process.env.NODE_ENV !== 'production') {
  dotenv();
}

import app from './app';
import { startBackupJob } from './db/backup';
import { startGateway } from './gateway';
import { startPurgeJob } from './util/tokens';
import { staticFiles } from './modules/mission-control/files';

const server = createServer({
  ca: process.env.SSL_CA_PATH
    ? readFileSync(process.env.SSL_CA_PATH)
    : undefined,
  cert: readFileSync(process.env.SSL_CERT_PATH!),
  key: readFileSync(process.env.SSL_KEY_PATH!),
});

const application = createApplication(server, {
  i18n: new I18n(['en'], 'locales'),
});

application.use('/src/*', files('src', true));

application.use('/*', staticFiles('public'));

application.use('/', app);

export default server;

if (require.main === module) {
  server.listen(1965);

  startGateway();
  startPurgeJob();
  startBackupJob();
}