Skip to content

Commit

Permalink
refactor of endpoints to classes
Browse files Browse the repository at this point in the history
  • Loading branch information
rcruzper committed Sep 13, 2019
1 parent 7578d03 commit 31013b1
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 400 deletions.
11 changes: 11 additions & 0 deletions lib/endpoints/health.js
@@ -0,0 +1,11 @@
'use strict';

class Health {
route(req, res) {
res.status(200).json({
status: "UP"
});
}
}

module.exports = Health;
File renamed without changes.
11 changes: 11 additions & 0 deletions lib/endpoints/metrics.js
@@ -0,0 +1,11 @@
'use strict';

class Metrics {
route(req, res) {
res.status(200).json({
mem: process.memoryUsage(),
uptime: process.uptime()
});
}
}
module.exports = Metrics;
7 changes: 0 additions & 7 deletions lib/healthRoute.js

This file was deleted.

10 changes: 5 additions & 5 deletions lib/actuatorMiddleware.js → lib/index.js
@@ -1,9 +1,9 @@
'use strict';

const express = require('express');
const Info = require('./infoRoute');
const metricsRoute = require('./metricsRoute');
const healthRoute = require('./healthRoute');
const Info = require('./endpoints/info');
const Metrics = require('./endpoints/metrics');
const Health = require('./endpoints/health');

const defaults = {
basePath: '',
Expand All @@ -16,8 +16,8 @@ module.exports = function actuatorMiddleware(options) {
const opts = sanitize(options);

router.get(opts.basePath + '/info', new Info(opts.infoGitMode).route);
router.get(opts.basePath + '/metrics', metricsRoute);
router.get(opts.basePath + '/health', healthRoute);
router.get(opts.basePath + '/metrics', new Metrics().route);
router.get(opts.basePath + '/health', new Health().route);

return router;
};
Expand Down
8 changes: 0 additions & 8 deletions lib/metricsRoute.js

This file was deleted.

0 comments on commit 31013b1

Please sign in to comment.