mirror of
https://github.com/caprover/caprover
synced 2026-09-25 16:15:34 +00:00
created generic catcher
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
"use strict";
|
||||
const CaptainError_1 = require("./CaptainError");
|
||||
const BaseApi = require("./BaseApi");
|
||||
const Logger = require("../utils/Logger");
|
||||
let apiStatusCode = {
|
||||
createError: function (code, message) {
|
||||
return new CaptainError_1.CaptainError(code, message || 'NONE');
|
||||
},
|
||||
createCatcher: function (res) {
|
||||
return function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
};
|
||||
},
|
||||
STATUS_OK: 100,
|
||||
STATUS_OK_DEPLOY_STARTED: 101,
|
||||
STATUS_ERROR_GENERIC: 1000,
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"ApiStatusCodes.js","sourceRoot":"","sources":["../../src/api/ApiStatusCodes.ts"],"names":[],"mappings":";AAAA,iDAA6C;AAE7C,IAAI,aAAa,GAAG;IAChB,WAAW,EAAE,UAAS,IAAY,EAAE,OAAe;QAC/C,OAAO,IAAI,2BAAY,CAAC,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC,CAAA;IACpD,CAAC;IAED,SAAS,EAAE,GAAG;IAEd,wBAAwB,EAAE,GAAG;IAE7B,oBAAoB,EAAE,IAAI;IAE1B,oCAAoC,EAAE,IAAI;IAE1C,iCAAiC,EAAE,IAAI;IAEvC,2BAA2B,EAAE,IAAI;IAEjC,0BAA0B,EAAE,IAAI;IAEhC,qBAAqB,EAAE,IAAI;IAE3B,qBAAqB,EAAE,IAAI;IAE3B,yBAAyB,EAAE,IAAI;IAE/B,mBAAmB,EAAE,IAAI;IAEzB,iBAAiB,EAAE,IAAI;IAEvB,WAAW,EAAE,IAAI;IAEjB,iBAAiB,EAAE,IAAI;IAEvB,SAAS,EAAE,IAAI;CAClB,CAAA;AAED,iBAAS,aAAa,CAAA"}
|
||||
{"version":3,"file":"ApiStatusCodes.js","sourceRoot":"","sources":["../../src/api/ApiStatusCodes.ts"],"names":[],"mappings":";AAAA,iDAA6C;AAE7C,qCAAqC;AACrC,0CAA0C;AAE1C,IAAI,aAAa,GAAG;IAChB,WAAW,EAAE,UAAS,IAAY,EAAE,OAAe;QAC/C,OAAO,IAAI,2BAAY,CAAC,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC,CAAA;IACpD,CAAC;IAED,aAAa,EAAE,UAAS,GAAa;QACjC,OAAO,UAAS,KAAyB;YACrC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;YAEf,IAAI,KAAK,IAAI,KAAK,CAAC,gBAAgB,EAAE;gBACjC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;gBAC/D,OAAM;aACT;YAED,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC,CAAA;IACL,CAAC;IAED,SAAS,EAAE,GAAG;IAEd,wBAAwB,EAAE,GAAG;IAE7B,oBAAoB,EAAE,IAAI;IAE1B,oCAAoC,EAAE,IAAI;IAE1C,iCAAiC,EAAE,IAAI;IAEvC,2BAA2B,EAAE,IAAI;IAEjC,0BAA0B,EAAE,IAAI;IAEhC,qBAAqB,EAAE,IAAI;IAE3B,qBAAqB,EAAE,IAAI;IAE3B,yBAAyB,EAAE,IAAI;IAE/B,mBAAmB,EAAE,IAAI;IAEzB,iBAAiB,EAAE,IAAI;IAEvB,WAAW,EAAE,IAAI;IAEjB,iBAAiB,EAAE,IAAI;IAEvB,SAAS,EAAE,IAAI;CAClB,CAAA;AAED,iBAAS,aAAa,CAAA"}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"BaseApi.js","sourceRoot":"","sources":["../../src/api/BaseApi.ts"],"names":[],"mappings":";AAEA,MAAM,OAAO;IAGT,YAAoB,MAAc,EAAU,WAAmB;QAA3C,WAAM,GAAN,MAAM,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;QAC3D,EAAE;IACN,CAAC;CACJ;AAED,iBAAS,OAAO,CAAA"}
|
||||
{"version":3,"file":"BaseApi.js","sourceRoot":"","sources":["../../src/api/BaseApi.ts"],"names":[],"mappings":";AAAA,MAAM,OAAO;IAGT,YAAoB,MAAc,EAAU,WAAmB;QAA3C,WAAM,GAAN,MAAM,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;QAC3D,EAAE;IACN,CAAC;CACJ;AAED,iBAAS,OAAO,CAAA"}
|
||||
@@ -22,14 +22,7 @@ router.get('/:appName/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/:appName/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -41,14 +34,7 @@ router.post('/:appName/', function (req, res, next) {
|
||||
// nothing to do with app, just to make sure that it exists!
|
||||
next();
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/:appName/', upload.single('sourceFile'), function (req, res, next) {
|
||||
const dataStore = res.locals.user.dataStore;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"AppDataRouter.js","sourceRoot":"","sources":["../../src/routes/AppDataRouter.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,0CAA0C;AAC1C,wD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,MAAM,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC,CAAC,CAAA;QACN,CAAC,CAAC;aACD,IAAI,CAAC,UAAS,OAAe;YAC1B,OAAO,cAAc,CAAC,6BAA6B,CAC/C,OAAO,EACP,OAAO,CACV,CAAA;QACL,CAAC,CAAC;aACD,KAAK,CAAC,UAAS,KAAK;YACjB,OAAO,IAAI,OAAO,CAAO,UAAS,OAAO,EAAE,MAAM;gBAC7C,cAAc,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;gBAC7C,MAAM,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACV,CAAC;AACL,CAAC,CAAC,CAAA;AAEF,iBAAS,MAAM,CAAA"}
|
||||
@@ -39,14 +39,7 @@ router.get('/unusedImages', function (req, res, next) {
|
||||
baseApi.data.unusedImages = unusedImages;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
// unused iamges
|
||||
router.post('/deleteImages', function (req, res, next) {
|
||||
@@ -61,14 +54,7 @@ router.post('/deleteImages', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Images Deleted.');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
// Get All App Definitions
|
||||
router.get('/', function (req, res, next) {
|
||||
@@ -101,14 +87,7 @@ router.get('/', function (req, res, next) {
|
||||
baseApi.defaultNginxConfig = defaultNginxConfig;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/enablebasedomainssl/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -123,14 +102,7 @@ router.post('/enablebasedomainssl/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/customdomain/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -151,14 +123,7 @@ router.post('/customdomain/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/removecustomdomain/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -177,14 +142,7 @@ router.post('/removecustomdomain/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/enablecustomdomainssl/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -205,14 +163,7 @@ router.post('/enablecustomdomainssl/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/register/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -255,14 +206,7 @@ router.post('/register/', function (req, res, next) {
|
||||
return createRejectionPromise();
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/delete/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -277,14 +221,7 @@ router.post('/delete/', function (req, res, next) {
|
||||
Logger.d('AppName is deleted: ' + appName);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'App is deleted'));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/update/', function (req, res, next) {
|
||||
let dataStore = res.locals.user.dataStore;
|
||||
@@ -318,14 +255,7 @@ router.post('/update/', function (req, res, next) {
|
||||
Logger.d('AppName is updated: ' + appName);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Updated App Definition Saved'));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
module.exports = router;
|
||||
//# sourceMappingURL=AppDefinitionRouter.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,6 @@ const TokenApi = require("../api/TokenApi");
|
||||
const BaseApi = require("../api/BaseApi");
|
||||
const Authenticator = require("../user/Authenticator");
|
||||
const ApiStatusCodes = require("../api/ApiStatusCodes");
|
||||
const Logger = require("../utils/Logger");
|
||||
const CaptainConstants = require("../utils/CaptainConstants");
|
||||
const router = express.Router();
|
||||
router.post('/', function (req, res, next) {
|
||||
@@ -25,15 +24,7 @@ router.post('/', function (req, res, next) {
|
||||
res.cookie(CaptainConstants.header.cookieAuth, cookieAuth);
|
||||
res.send(new TokenApi(authToken));
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
}
|
||||
else {
|
||||
Logger.e(error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
module.exports = router;
|
||||
//# sourceMappingURL=LoginRouter.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"LoginRouter.js","sourceRoot":"","sources":["../../src/routes/LoginRouter.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,4CAA4C;AAC5C,0CAA0C;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aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,iBAAS,MAAM,CAAA"}
|
||||
@@ -20,14 +20,7 @@ router.post('/insert/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/all/', function (req, res, next) {
|
||||
const captainManager = CaptainManager.get();
|
||||
@@ -47,14 +40,7 @@ router.get('/all/', function (req, res, next) {
|
||||
baseApi.data.defaultPushRegistryId = defaultPush;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/delete/', function (req, res, next) {
|
||||
let registryId = req.body.registryId + '';
|
||||
@@ -67,14 +53,7 @@ router.post('/delete/', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Registry deleted');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/setpush/', function (req, res, next) {
|
||||
let registryId = req.body.registryId + '';
|
||||
@@ -87,14 +66,7 @@ router.post('/setpush/', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Push Registry changed');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
module.exports = router;
|
||||
//# sourceMappingURL=RegistriesRouter.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"RegistriesRouter.js","sourceRoot":"","sources":["../../src/routes/RegistriesRouter.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,0CAA0C;AAC1C,wDAAwD;AACxD,0CAA0C;AAC1C,yDAAyD;AAIzD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;AAE/B,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,UAAS,GAAG,EAAE,GAAG,EAAE,IAAI;IAC3C,IAAI,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;IAC7C,IAAI,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;IACrD,IAAI,cAAc,GAAG,GAAG,CAAC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;IACjD,IAAI,mBAAmB,GAAG,GAAG,CAAC,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAA;IAE3D,MAAM,cAAc,GAAG,cAAc,CAAC,GAAG,EAAE,CAAA;IAE3C,OAAO,OAAO,CAAC,OAAO,EAAE;SACnB,IAAI,CAAC;QACF,OAAO,cAAc,CAAC,WAAW,CAC7B,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,mBAAmB,CACtB,CAAA;IACL,CAAC,CAAC;SACD,IAAI,CAAC;QACF,IAAI,GAAG,GAAG,oBAAoB,CAAA;QAC9B,MAAM,CAAC,CAAC,CAAC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AAC,CAAA;IAC5D,CAAC,CAAC;SACD,IAAI,CAAC;QACF,IAAI,OAAO,GAAG,IAAI,OAAO,CACrB,cAAc,CAAC,SAAS,EACxB,uBAAuB,CAC1B,CAAA;QACD,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC,CAAC;SACD,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,iBAAS,MAAM,CAAA"}
|
||||
@@ -31,15 +31,7 @@ router.post('/changerootdomain/', function (req, res, next) {
|
||||
.then(function () {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Root domain changed.'));
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
}
|
||||
else {
|
||||
Logger.e(error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/enablessl/', function (req, res, next) {
|
||||
const emailAddress = req.body.emailAddress || '';
|
||||
@@ -59,15 +51,7 @@ router.post('/enablessl/', function (req, res, next) {
|
||||
.then(function () {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Root SSL Enabled.'));
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
}
|
||||
else {
|
||||
Logger.e(error); //
|
||||
res.sendStatus(500); //
|
||||
}
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/forcessl/', function (req, res, next) {
|
||||
let isEnabled = !!req.body.isEnabled;
|
||||
@@ -77,15 +61,7 @@ router.post('/forcessl/', function (req, res, next) {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Non-SSL traffic is now ' +
|
||||
(isEnabled ? 'rejected.' : 'allowed.')));
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
}
|
||||
else {
|
||||
Logger.e(error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/enableregistryssl/', function (req, res, next) {
|
||||
return Promise.resolve()
|
||||
@@ -99,14 +75,7 @@ router.post('/enableregistryssl/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/enableregistry/', function (req, res, next) {
|
||||
const LOCAL = 'local';
|
||||
@@ -159,14 +128,7 @@ router.post('/enableregistry/', function (req, res, next) {
|
||||
.then(function () {
|
||||
return captainManager.resetSelf();
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/info/', function (req, res, next) {
|
||||
const dataStore = res.locals.user.dataStore;
|
||||
@@ -192,14 +154,7 @@ router.get('/info/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/loadbalancerinfo/', function (req, res, next) {
|
||||
const dataStore = res.locals.user.dataStore;
|
||||
@@ -214,14 +169,7 @@ router.get('/loadbalancerinfo/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/versionInfo/', function (req, res, next) {
|
||||
return Promise.resolve()
|
||||
@@ -264,14 +212,7 @@ router.get('/versionInfo/', function (req, res, next) {
|
||||
};
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/versionInfo/', function (req, res, next) {
|
||||
let latestVersion = req.body.latestVersion;
|
||||
@@ -283,14 +224,7 @@ router.post('/versionInfo/', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Captain update process has started...');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/netdata/', function (req, res, next) {
|
||||
const dataStore = res.locals.user.dataStore;
|
||||
@@ -308,14 +242,7 @@ router.get('/netdata/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/netdata/', function (req, res, next) {
|
||||
let netDataInfo = req.body.netDataInfo;
|
||||
@@ -329,14 +256,7 @@ router.post('/netdata/', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Netdata info is updated');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/nginxconfig/', function (req, res, next) {
|
||||
return Promise.resolve()
|
||||
@@ -348,14 +268,7 @@ router.get('/nginxconfig/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/nginxconfig/', function (req, res, next) {
|
||||
let baseConfigCustomValue = req.body.baseConfig.customValue;
|
||||
@@ -368,14 +281,7 @@ router.post('/nginxconfig/', function (req, res, next) {
|
||||
let baseApi = new BaseApi(ApiStatusCodes.STATUS_OK, 'Nginx config is updated');
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.get('/nodes/', function (req, res, next) {
|
||||
return Promise.resolve()
|
||||
@@ -387,14 +293,7 @@ router.get('/nodes/', function (req, res, next) {
|
||||
baseApi.data = data;
|
||||
res.send(baseApi);
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
router.post('/nodes/', function (req, res, next) {
|
||||
const MANAGER = 'manager';
|
||||
@@ -435,14 +334,7 @@ router.post('/nodes/', function (req, res, next) {
|
||||
Logger.d(msg);
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Logger.e(error);
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
return;
|
||||
}
|
||||
res.sendStatus(500);
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
module.exports = router;
|
||||
//# sourceMappingURL=SystemRouter.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,6 @@ const WebhooksRouter = require("./WebhooksRouter");
|
||||
const AppDefinitionRouter = require("./AppDefinitionRouter");
|
||||
const AppDataRouter = require("./AppDataRouter");
|
||||
const Authenticator = require("../user/Authenticator");
|
||||
const Logger = require("../utils/Logger");
|
||||
const onFinished = require("on-finished");
|
||||
const router = express.Router();
|
||||
const threadLockNamespace = {};
|
||||
@@ -63,15 +62,7 @@ router.post('/changepassword/', function (req, res, next) {
|
||||
.then(function () {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Password changed.'));
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage));
|
||||
}
|
||||
else {
|
||||
Logger.e(error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
.catch(ApiStatusCodes.createCatcher(res));
|
||||
});
|
||||
// semi-secured end points:
|
||||
router.use('/webhooks/', WebhooksRouter);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"UserRouter.js","sourceRoot":"","sources":["../../src/routes/UserRouter.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,0CAA0C;AAC1C,wDAAwD;AACxD,kDAAkD;AAClD,+CAA+C;AAC/C,mDAAmD;AACnD,6DAA6D;AAC7D,iDAAiD;AACjD,uDAAuD;AACvD,0CAA0C;AAC1C,0CAA0C;AAE1C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAA;AAE/B,MAAM,mBAAmB,GAAG,EAA8B,CAAA;AAE1D,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAA;AAEzD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;AAEjC,SAAS,eAAe,CAAC,GAAoB;IACzC,OAAO,GAAG,CAAC,MAAM,KAAK,KAAK,CAAA;AAC/B,CAAC;AAED,MAAM,CAAC,GAAG,CAAC,UAAS,GAAG,EAAE,GAAG,EAAE,IAAI;IAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;QAClB,IAAI,QAAQ,GAAG,IAAI,OAAO,CACtB,cAAc,CAAC,2BAA2B,EAC1C,gCAAgC,CACnC,CAAA;QACD,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAClB,OAAM;KACT;IAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;QAC9B,IAAI,QAAQ,GAAG,IAAI,OAAO,CACtB,cAAc,CAAC,iCAAiC,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pC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAA;AAEnD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;AAEtC,iBAAS,MAAM,CAAA"}
|
||||
@@ -15,21 +15,22 @@ function getTime() {
|
||||
moment().format('MMMM Do YYYY, h:mm:ss.SSS a ') +
|
||||
'\x1b[0m');
|
||||
}
|
||||
module.exports = {
|
||||
d: function (msg) {
|
||||
class Logger {
|
||||
static d(msg) {
|
||||
console.log(getTime() + msg + '');
|
||||
},
|
||||
w: function (msg) {
|
||||
}
|
||||
static w(msg) {
|
||||
console.log(getTime() + msg + '');
|
||||
},
|
||||
dev: function (msg) {
|
||||
}
|
||||
static dev(msg) {
|
||||
if (CaptainConstants.isDebug) {
|
||||
console.log(getTime() + '########### ' + msg + '');
|
||||
}
|
||||
},
|
||||
e: function (msgOrError) {
|
||||
}
|
||||
static e(msgOrError) {
|
||||
let err = errorize(msgOrError);
|
||||
console.error(getTime() + err + '\n' + err.stack);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
module.exports = Logger;
|
||||
//# sourceMappingURL=Logger.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AACtD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,SAAS,QAAQ,CAAC,KAAe;IAC7B,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;KAC3D;IAED,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,SAAS,OAAO;IACZ,OAAO,CACH,UA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AAE,CAAC,MAAM,CAAC,iCAAiC,CAAC;QAClD,SAAS,CACZ,CAAA;AACL,CAAC;AAED,MAAM,MAAM;IACR,MAAM,CAAC,CAAC,CAAC,GAAW;QAChB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,GAAW;QAChB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,GAAW;QAClB,IAAI,gBAAgB,CAAC,OAAO,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,cAAc,GAAG,GAAG,GAAG,EAAE,CAAC,CAAA;SACrD;IACL,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,UAAoB;QACzB,IAAI,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAA;IACrD,CAAC;CACJ;AACD,iBAAS,MAAM,CAAA"}
|
||||
@@ -1,10 +1,26 @@
|
||||
import { CaptainError } from './CaptainError'
|
||||
import { Response } from 'express'
|
||||
import BaseApi = require('./BaseApi')
|
||||
import Logger = require('../utils/Logger')
|
||||
|
||||
let apiStatusCode = {
|
||||
createError: function(code: number, message: string) {
|
||||
return new CaptainError(code, message || 'NONE')
|
||||
},
|
||||
|
||||
createCatcher: function(res: Response) {
|
||||
return function(error: CaptainError | any) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
}
|
||||
},
|
||||
|
||||
STATUS_OK: 100,
|
||||
|
||||
STATUS_OK_DEPLOY_STARTED: 101,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import ApiStatusCode = require('./ApiStatusCodes')
|
||||
|
||||
class BaseApi {
|
||||
public data: any
|
||||
|
||||
|
||||
@@ -29,16 +29,7 @@ router.get('/:appName/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/:appName/', function(req, res, next) {
|
||||
@@ -52,16 +43,7 @@ router.post('/:appName/', function(req, res, next) {
|
||||
// nothing to do with app, just to make sure that it exists!
|
||||
next()
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/:appName/', upload.single('sourceFile'), function(
|
||||
|
||||
@@ -57,16 +57,7 @@ router.get('/unusedImages', function(req, res, next) {
|
||||
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
// unused iamges
|
||||
@@ -86,16 +77,7 @@ router.post('/deleteImages', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
// Get All App Definitions
|
||||
@@ -136,16 +118,7 @@ router.get('/', function(req, res, next) {
|
||||
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/enablebasedomainssl/', function(req, res, next) {
|
||||
@@ -163,16 +136,7 @@ router.post('/enablebasedomainssl/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/customdomain/', function(req, res, next) {
|
||||
@@ -198,16 +162,7 @@ router.post('/customdomain/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/removecustomdomain/', function(req, res, next) {
|
||||
@@ -230,16 +185,7 @@ router.post('/removecustomdomain/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/enablecustomdomainssl/', function(req, res, next) {
|
||||
@@ -265,16 +211,7 @@ router.post('/enablecustomdomainssl/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/register/', function(req, res, next) {
|
||||
@@ -331,16 +268,7 @@ router.post('/register/', function(req, res, next) {
|
||||
return createRejectionPromise()
|
||||
}
|
||||
})
|
||||
.catch(function(error: CaptainError) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/delete/', function(req, res, next) {
|
||||
@@ -359,16 +287,7 @@ router.post('/delete/', function(req, res, next) {
|
||||
Logger.d('AppName is deleted: ' + appName)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'App is deleted'))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/update/', function(req, res, next) {
|
||||
@@ -424,16 +343,7 @@ router.post('/update/', function(req, res, next) {
|
||||
)
|
||||
)
|
||||
})
|
||||
.catch(function(error: CaptainError) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
export = router
|
||||
|
||||
@@ -34,14 +34,7 @@ router.post('/', function(req, res, next) {
|
||||
res.cookie(CaptainConstants.header.cookieAuth, cookieAuth)
|
||||
res.send(new TokenApi(authToken))
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
} else {
|
||||
Logger.e(error)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
export = router
|
||||
|
||||
@@ -30,16 +30,7 @@ router.post('/insert/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/all/', function(req, res, next) {
|
||||
@@ -64,16 +55,7 @@ router.get('/all/', function(req, res, next) {
|
||||
baseApi.data.defaultPushRegistryId = defaultPush
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/delete/', function(req, res, next) {
|
||||
@@ -91,16 +73,7 @@ router.post('/delete/', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/setpush/', function(req, res, next) {
|
||||
@@ -118,16 +91,7 @@ router.post('/setpush/', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
export = router
|
||||
|
||||
@@ -43,14 +43,7 @@ router.post('/changerootdomain/', function(req, res, next) {
|
||||
new BaseApi(ApiStatusCodes.STATUS_OK, 'Root domain changed.')
|
||||
)
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
} else {
|
||||
Logger.e(error)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/enablessl/', function(req, res, next) {
|
||||
@@ -80,14 +73,7 @@ router.post('/enablessl/', function(req, res, next) {
|
||||
.then(function() {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Root SSL Enabled.'))
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
} else {
|
||||
Logger.e(error) //
|
||||
res.sendStatus(500) //
|
||||
}
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/forcessl/', function(req, res, next) {
|
||||
@@ -104,14 +90,7 @@ router.post('/forcessl/', function(req, res, next) {
|
||||
)
|
||||
)
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
} else {
|
||||
Logger.e(error)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/enableregistryssl/', function(req, res, next) {
|
||||
@@ -126,16 +105,7 @@ router.post('/enableregistryssl/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/enableregistry/', function(req, res, next) {
|
||||
@@ -195,16 +165,7 @@ router.post('/enableregistry/', function(req, res, next) {
|
||||
.then(function() {
|
||||
return captainManager.resetSelf()
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/info/', function(req, res, next) {
|
||||
@@ -236,16 +197,7 @@ router.get('/info/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/loadbalancerinfo/', function(req, res, next) {
|
||||
@@ -265,16 +217,7 @@ router.get('/loadbalancerinfo/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/versionInfo/', function(req, res, next) {
|
||||
@@ -329,16 +272,7 @@ router.get('/versionInfo/', function(req, res, next) {
|
||||
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/versionInfo/', function(req, res, next) {
|
||||
@@ -355,16 +289,7 @@ router.post('/versionInfo/', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/netdata/', function(req, res, next) {
|
||||
@@ -387,16 +312,7 @@ router.get('/netdata/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/netdata/', function(req, res, next) {
|
||||
@@ -415,16 +331,7 @@ router.post('/netdata/', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/nginxconfig/', function(req, res, next) {
|
||||
@@ -440,16 +347,7 @@ router.get('/nginxconfig/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/nginxconfig/', function(req, res, next) {
|
||||
@@ -470,16 +368,7 @@ router.post('/nginxconfig/', function(req, res, next) {
|
||||
)
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.get('/nodes/', function(req, res, next) {
|
||||
@@ -495,16 +384,7 @@ router.get('/nodes/', function(req, res, next) {
|
||||
baseApi.data = data
|
||||
res.send(baseApi)
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
router.post('/nodes/', function(req, res, next) {
|
||||
@@ -570,16 +450,7 @@ router.post('/nodes/', function(req, res, next) {
|
||||
Logger.d(msg)
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, msg))
|
||||
})
|
||||
.catch(function(error) {
|
||||
Logger.e(error)
|
||||
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
return
|
||||
}
|
||||
|
||||
res.sendStatus(500)
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
export = router
|
||||
|
||||
@@ -92,14 +92,7 @@ router.post('/changepassword/', function(req, res, next) {
|
||||
.then(function() {
|
||||
res.send(new BaseApi(ApiStatusCodes.STATUS_OK, 'Password changed.'))
|
||||
})
|
||||
.catch(function(error) {
|
||||
if (error && error.captainErrorType) {
|
||||
res.send(new BaseApi(error.captainErrorType, error.apiMessage))
|
||||
} else {
|
||||
Logger.e(error)
|
||||
res.sendStatus(500)
|
||||
}
|
||||
})
|
||||
.catch(ApiStatusCodes.createCatcher(res))
|
||||
})
|
||||
|
||||
// semi-secured end points:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AnyError } from "../models/OtherTypes";
|
||||
import { AnyError } from '../models/OtherTypes'
|
||||
|
||||
/**
|
||||
* Created by kasra on 27/06/17.
|
||||
@@ -22,23 +22,24 @@ function getTime() {
|
||||
)
|
||||
}
|
||||
|
||||
export = {
|
||||
d: function(msg: string) {
|
||||
class Logger {
|
||||
static d(msg: string) {
|
||||
console.log(getTime() + msg + '')
|
||||
},
|
||||
}
|
||||
|
||||
w: function(msg: string) {
|
||||
static w(msg: string) {
|
||||
console.log(getTime() + msg + '')
|
||||
},
|
||||
}
|
||||
|
||||
dev: function(msg: string) {
|
||||
static dev(msg: string) {
|
||||
if (CaptainConstants.isDebug) {
|
||||
console.log(getTime() + '########### ' + msg + '')
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
e: function(msgOrError: AnyError) {
|
||||
static e(msgOrError: AnyError) {
|
||||
let err = errorize(msgOrError)
|
||||
console.error(getTime() + err + '\n' + err.stack)
|
||||
},
|
||||
}
|
||||
}
|
||||
export = Logger
|
||||
|
||||
Reference in New Issue
Block a user