import { readFileSync } from 'fs'; import { Config, init } from './app'; const DEFAULT_CONFIG = process.env.CONFIG_FILE || '/app/config.json'; (async () => { const configFile = process.env.CONFIG_FILE || '/app/config.json'; let config: Config try { config = JSON.parse(readFileSync(configFile || DEFAULT_CONFIG, 'utf8')) as Config; } catch (err) { console.log(`Config file at ${configFile || DEFAULT_CONFIG} not found`); process.exit(1); } const app = await init({ config }); app.app.listen(process.env.PORT || 8000); console.log(`API service now listening on port ${process.env.PORT || 8000}`); })();