UNPKG

@slsplus/ui

Version:
32 lines (31 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.startServer = void 0; const tslib_1 = require("tslib"); const dotenv_1 = tslib_1.__importDefault(require("dotenv")); const path_1 = tslib_1.__importDefault(require("path")); dotenv_1.default.config({ path: path_1.default.join(process.cwd(), '.env') }); const open_1 = tslib_1.__importDefault(require("open")); const app_1 = require("./app"); const find_port_1 = tslib_1.__importDefault(require("./utils/find-port")); /** * Start Express server. */ async function startServer(route = '/') { const PORT = await find_port_1.default(process.env.PORT); const server = app_1.app.listen(PORT, async () => { const url = `http://localhost:${PORT}`; const openUrl = `${url}${route}`; console.log(` App is running at ${url} in ${app_1.app.get('env')} mode`); try { await open_1.default(openUrl, { wait: false, url: true }); console.log(` Serverless config page is opened.`); } catch (e) { // no op } console.log(' Press CTRL-C to stop\n'); }); return server; } exports.startServer = startServer;