import type {LogLevel} from '@rocicorp/logger'; import {newLogContext} from './logger.js'; import {newApp} from './app.js'; const port = process.env.PORT || 8080; // default port to listen if (process.env.ADMIN_PW === undefined) { throw 'ADMIN_PW environment variable must be set'; } let logLevel: LogLevel = 'debug'; if (process.env.LOG_LEVEL === 'info' || process.env.LOG_LEVEL === 'error') { logLevel = process.env.LOG_LEVEL; } const allowNewlines = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'staging'; const lc = newLogContext(logLevel, allowNewlines); // start the Express server const app = newApp(process.env.ADMIN_PW, lc); app.listen(port, () => { // This is a helpful hint for when developing. We don't log if the // pw is non-empty, as it is in production. if (process.env.ADMIN_PW === '') { lc.info?.("admin user is 'admin', pw is empty string"); } lc.info?.(`server started at http://localhost:${port}`); });