Skip to content

Commit

Permalink
fix(api-generate): API docs generation now is run through a separate …
Browse files Browse the repository at this point in the history
…npm command ZMS-139 (#659)

* added generate-api-docs npm command and corresponding code changes

* fix typo
  • Loading branch information
NickOvt committed Apr 3, 2024
1 parent 2d08b61 commit 6548f3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion api.js
Expand Up @@ -581,7 +581,18 @@ module.exports = done => {
);
}

server.pre(restifyApiGenerate.restifyApiGenerate(server, restifyApiGenerateConfig));
if (process.env.GENERATE_API_DOCS === 'true') {
server.pre(restifyApiGenerate.restifyApiGenerate(server, restifyApiGenerateConfig));
}

if (process.env.REGENERATE_API_DOCS === 'true') {
// allow 2.5 seconds for services to start and the api doc to be generated, after that exit process
(async function () {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
await sleep(2500);
process.exit(0);
})();
}

server.on('error', err => {
if (!started) {
Expand All @@ -605,6 +616,7 @@ module.exports = done => {
}
started = true;
log.info('API', 'Server listening on %s:%s', config.api.host || '0.0.0.0', config.api.port);

done(null, server);
});
};
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -12,7 +12,8 @@
"apidoc": "apidoc -i lib/api/ -o docs/api/",
"show": "NODE_CONFIG_ONLY=true node server.js",
"start": "node server.js",
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install",
"generate-api-docs": "GENERATE_API_DOCS=true REGENERATE_API_DOCS=true node server.js"
},
"keywords": [
"imap",
Expand Down

0 comments on commit 6548f3c

Please sign in to comment.