💾 Archived View for iich.space › src › index.ts captured on 2021-12-04 at 18:04:22.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

➡️ Next capture (2022-03-01)

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

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';

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('/public/*', files('public', true));

application.use('/', app);

export default server;

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

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