// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved. // Node module: @loopback/example-express-composition // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {ApplicationConfig, ExpressServer} from './server'; export * from './server'; export async function main(options: ApplicationConfig = {}) { const server = new ExpressServer(options); await server.boot(); await server.start(); console.log('Server is running at http://127.0.0.1:3000'); } if (require.main === module) { // Run the application const config = { rest: { port: +(process.env.PORT ?? 3000), host: process.env.HOST ?? 'localhost', openApiSpec: { // useful when used with OpenAPI-to-GraphQL to locate your application setServersFromRequest: true, }, // Use the LB4 application as a route. It should not be listening. listenOnStart: false, }, }; main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); }