fix(xo-server/RestApi): don't fail on missing express

Which is the case when instanciated from `xo-server-recover-account`.
This commit is contained in:
Julien Fontanet
2022-03-03 14:26:26 +01:00
parent 9cd1784667
commit bc7fc750f0

View File

@@ -49,6 +49,13 @@ const subRouter = (app, path) => {
export default class RestApi {
constructor(app, { express }) {
// don't setup the API if express is not present
//
// that can happen when the app is instanciated in another context like xo-server-recover-account
if (express === undefined) {
return
}
const api = subRouter(express, '/rest/v0')
api.use(({ cookies }, res, next) => {