mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-26 01:40:48 +08:00
fix(api-generate): API docs generation now is run through a separate npm command ZMS-139 (#659)
* added generate-api-docs npm command and corresponding code changes * fix typo
This commit is contained in:
parent
2d08b6132f
commit
6548f3cd5e
2 changed files with 15 additions and 2 deletions
14
api.js
14
api.js
|
@ -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) {
|
||||
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue