From 2e7d4bb6e7b30aedfcc373a0d2bed3c0f1ad07c8 Mon Sep 17 00:00:00 2001 From: Mario Estrada Date: Fri, 26 Oct 2018 00:01:51 -0600 Subject: [PATCH] refactor: examples, specifies port,host and OpenAPI server --- examples/hello-world/index.js | 12 +++++++++++- examples/soap-calculator/index.js | 12 +++++++++++- examples/todo-list/index.js | 10 ++++++++++ examples/todo/index.js | 12 +++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/examples/hello-world/index.js b/examples/hello-world/index.js index 23bcda999e32..2800ea495ada 100644 --- a/examples/hello-world/index.js +++ b/examples/hello-world/index.js @@ -9,7 +9,17 @@ module.exports = application; if (require.main === module) { // Run the application - application.main().catch(err => { + const config = { + rest: { + port: +process.env.PORT || 3000, + host: process.env.HOST || 'localhost', + openApiSpec: { + // useful when used with OASGraph to locate your application + setServersFromRequest: true, + }, + }, + }; + application.main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); diff --git a/examples/soap-calculator/index.js b/examples/soap-calculator/index.js index 12484ccad1c7..78018fcf4412 100644 --- a/examples/soap-calculator/index.js +++ b/examples/soap-calculator/index.js @@ -4,7 +4,17 @@ module.exports = application; if (require.main === module) { // Run the application - application.main().catch(err => { + const config = { + rest: { + port: +process.env.PORT || 3000, + host: process.env.HOST || 'localhost', + openApiSpec: { + // useful when used with OASGraph to locate your application + setServersFromRequest: true, + }, + }, + }; + application.main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); diff --git a/examples/todo-list/index.js b/examples/todo-list/index.js index f60622546c19..d9b161f4c190 100644 --- a/examples/todo-list/index.js +++ b/examples/todo-list/index.js @@ -9,6 +9,16 @@ module.exports = application; 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 OASGraph to locate your application + setServersFromRequest: true, + }, + }, + }; application.main().catch(err => { console.error('Cannot start the application.', err); process.exit(1); diff --git a/examples/todo/index.js b/examples/todo/index.js index 08ea81118b44..35bffe4aca7a 100644 --- a/examples/todo/index.js +++ b/examples/todo/index.js @@ -9,7 +9,17 @@ module.exports = application; if (require.main === module) { // Run the application - application.main().catch(err => { + const config = { + rest: { + port: +process.env.PORT || 3000, + host: process.env.HOST || 'localhost', + openApiSpec: { + // useful when used with OASGraph to locate your application + setServersFromRequest: true, + }, + }, + }; + application.main(config).catch(err => { console.error('Cannot start the application.', err); process.exit(1); });