01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
import path from 'path';
import { createDB } from './database';
const { PORT } = process.env; // Get environment variables.
const validExt = (p) => /\.[a-z0-9]{1,4}$/i.test(p);
/**
* Application factory.
* @return {App} Application instance
*/
async function createApp(config: Config): App {
return new App({
port: Number(env.PORT ?? 8000),
db: await createDB(config.db),
...config.app,
});
}