Răsfoiți Sursa

Make an explicit lean healthcheck

Johannes Zellner 11 ani în urmă
părinte
comite
eccb2e1439
3 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 1 1
      CloudronManifest.json
  2. 2 0
      app.js
  3. 6 1
      src/routes.js

+ 1 - 1
CloudronManifest.json

@@ -5,7 +5,7 @@
   "description": "file://DESCRIPTION.md",
   "tagline": "Your personal notes",
   "version": "0.1.0",
-  "healthCheckPath": "/",
+  "healthCheckPath": "/api/healthcheck",
   "httpPort": 3000,
   "addons": {
     "mongodb": {},

+ 2 - 0
app.js

@@ -36,6 +36,8 @@ router.post('/api/import', routes.auth, multer().any(), routes.importThings);
 router.post('/api/login', routes.login);
 router.get ('/api/logout', routes.auth, routes.logout);
 
+router.get ('/api/healthcheck', routes.healthcheck);
+
 app.use(morgan('dev', { immediate: false, stream: { write: function (str) { console.log(str.slice(0, -1)); } } }));
 app.use(serveStatic(__dirname + '/public'));
 app.use(cors());

+ 6 - 1
src/routes.js

@@ -27,7 +27,8 @@ exports = module.exports = {
     settingsSave: settingsSave,
     settingsGet: settingsGet,
     exportThings: exportThings,
-    importThings: importThings
+    importThings: importThings,
+    healthcheck: healthcheck
 };
 
 function init(callback) {
@@ -39,6 +40,10 @@ function init(callback) {
     ], callback);
 }
 
+function healthcheck(req, res, next) {
+    next(new HttpSuccess(200, {}));
+}
+
 function auth(req, res, next) {
     if (!req.query.token) return res.status(401).send('missing token');