2021-01-14 15:55:19 +00:00
|
|
|
import * as express from "express"
|
2021-01-14 15:53:58 +00:00
|
|
|
import { createApp } from "../src/node/app"
|
2021-01-14 15:55:19 +00:00
|
|
|
import { parse, setDefaults, parseConfigFile, DefaultedArgs } from "../src/node/cli"
|
2021-01-14 15:53:58 +00:00
|
|
|
import { register } from "../src/node/routes"
|
|
|
|
import * as httpserver from "./httpserver"
|
|
|
|
|
2021-01-14 15:55:19 +00:00
|
|
|
export async function setup(
|
|
|
|
argv: string[],
|
|
|
|
configFile?: string,
|
|
|
|
): Promise<[express.Application, express.Application, httpserver.HttpServer, DefaultedArgs]> {
|
2021-01-14 15:53:58 +00:00
|
|
|
const cliArgs = parse(argv)
|
2021-01-14 15:55:19 +00:00
|
|
|
const configArgs = parseConfigFile(configFile || "", "test/integration.ts")
|
2021-01-14 15:53:58 +00:00
|
|
|
const args = await setDefaults(cliArgs, configArgs)
|
|
|
|
|
|
|
|
const [app, wsApp, server] = await createApp(args)
|
|
|
|
await register(app, wsApp, server, args)
|
|
|
|
|
|
|
|
return [app, wsApp, new httpserver.HttpServer(server), args]
|
|
|
|
}
|