import { generateTypings, unravel } from '@yourcause/common/server'; import { static as _static } from 'express'; import { readFileSync } from 'fs'; import * as https from 'https'; import { join, resolve } from 'path'; import { createApp } from './server.js'; const appRoot = join(__dirname, '..', '..', '..', '..', 'dist'); (async () => { const app = await createApp(); app.use( _static(appRoot) ); app.use( (req, res, next) => { (res.sendFile || res.sendfile).call(res, resolve(appRoot, 'index.html'), (err?: any) => err && next()); }); const server = https.createServer({ key: readFileSync(join(__dirname, '..', 'ssl', 'server.key')), cert: readFileSync(join(__dirname, '..', 'ssl', 'server.crt')), ca: readFileSync(join(__dirname, '..', 'ssl', 'ca.crt')) }, app); const port = process.env.NO_WEBPACK ? 51852 : 51849; server.listen(port); if (!!process.env.NEW_I18N) { await unravel(); } await generateTypings(); console.log('listening on', port); })();