From 06eb81b1afe52caf62cdc1f9f0f0dba1b2b3934b Mon Sep 17 00:00:00 2001 From: Alessandro Marchioro Date: Wed, 6 Oct 2021 11:17:18 +0200 Subject: [PATCH] feat: added status basic endpoint (#347) --- app/frontend/webserver/handlers/index.js | 2 ++ app/frontend/webserver/handlers/status.js | 24 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 app/frontend/webserver/handlers/status.js diff --git a/app/frontend/webserver/handlers/index.js b/app/frontend/webserver/handlers/index.js index 8758a482..1abe15f1 100644 --- a/app/frontend/webserver/handlers/index.js +++ b/app/frontend/webserver/handlers/index.js @@ -3,12 +3,14 @@ const { handleGridTradeArchiveGet } = require('./grid-trade-archive-get'); const { handleGridTradeArchiveDelete } = require('./grid-trade-archive-delete'); const { handleClosedTradesSetPeriod } = require('./closed-trades-set-period'); const { handle404 } = require('./404'); +const { handleStatus } = require('./status'); const setHandlers = async (logger, app, { loginLimiter }) => { await handleAuth(logger, app, { loginLimiter }); await handleGridTradeArchiveGet(logger, app); await handleGridTradeArchiveDelete(logger, app); await handleClosedTradesSetPeriod(logger, app); + await handleStatus(logger, app); await handle404(logger, app); }; diff --git a/app/frontend/webserver/handlers/status.js b/app/frontend/webserver/handlers/status.js new file mode 100644 index 00000000..686af83c --- /dev/null +++ b/app/frontend/webserver/handlers/status.js @@ -0,0 +1,24 @@ +const requestIp = require('request-ip'); + +const handleStatus = async (funcLogger, app) => { + const logger = funcLogger.child({ endpoint: '/status' }); + + app.route('/status').get(async (req, res) => { + const clientIp = requestIp.getClientIp(req); + + logger.info( + { + clientIp + }, + 'handle status monitoring endpoint' + ); + + return res.send({ + success: true, + status: 200, + message: 'OK' + }); + }); +}; + +module.exports = { handleStatus };