Skip to content

Commit

Permalink
refactor(cli): use options to specify app port and openapi server
Browse files Browse the repository at this point in the history
  • Loading branch information
marioestradarosa committed Oct 26, 2018
1 parent a3d5d0c commit 4283a98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/cli/generators/app/templates/index.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/integration/generators/app.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ describe('app-generator specific files', () => {
assert.fileContent('src/application.ts', /constructor\(/);
assert.fileContent('src/application.ts', /this.projectRoot = __dirname/);

assert.file('index.js');
assert.fileContent('index.js', /openApiSpec: {/);
assert.fileContent('index.js', /setServersFromRequest: true/);

assert.file('src/index.ts');
assert.fileContent('src/index.ts', /new MyAppApplication/);
assert.fileContent('src/index.ts', /await app.start\(\);/);
Expand Down

0 comments on commit 4283a98

Please sign in to comment.