Skip to content

Commit

Permalink
Start OpenAPI at boot up if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
canmingir committed Apr 29, 2023
1 parent 261072a commit 1a6e04d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ function init() {
}
});
});

try {
const {
api,
types,
prefix,
port,
functions,
} = require(`${_config.path}/openapi.json`);
context.run(functions);
openapi.init();
openapi.load({ api, types, prefix });
openapi.start(port || _config.port.openapi);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") {
console.error("Error loading OpenAPI", err);
process.exit(1);
}
}
}

module.exports.init = init;

0 comments on commit 1a6e04d

Please sign in to comment.