added endpoint to download certificates

This commit is contained in:
Rahul Somasundaram
2021-08-23 09:03:24 +05:30
parent 5e9ff4d2bf
commit e5a3b5ee2f
3 changed files with 75 additions and 0 deletions

View File

@ -209,6 +209,35 @@ router
.catch(next);
});
/**
* Download LE Certs
*
* /api/nginx/certificates/123/download
*/
router
.route('/:certificate_id/download')
.options((req, res) => {
res.sendStatus(204);
})
.all(jwtdecode())
/**
* POST /api/nginx/certificates/123/download
*
* Renew certificate
*/
.get((req, res, next) => {
internalCertificate.download({
id: parseInt(req.params.certificate_id, 10)
})
.then((result) => {
res.status(200)
.download(result.fileName);
})
.catch(next);
});
/**
* Validate Certs before saving
*