Skip to content

Node.js based forum software built for the modern web

Moved ping to its own controller

Julian Lama4939d78fecb
diff --git a/config.json.bk b/config.json.bk
new file mode 100644
index 0000000000..05adb022c6
--- /dev/null
+++ b/config.json.bk
@@ -0,0 +1,11 @@
+{
+ "url": "http://127.0.0.1:4567",
+ "secret": "catsRkool",
+ "database": "redis",
+ "port": 4567,
+ "redis": {
+ "host": "127.0.0.1",
+ "port": "6379",
+ "database": "0"
+ }
+}
diff --git a/src/controllers/index.js b/src/controllers/index.js
index bddab21a11..6e82dbf4a2 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -11,6 +11,7 @@ var helpers = require('./helpers');
var Controllers = module.exports;
+Controllers.ping = require('./ping');
Controllers.home = require('./home');
Controllers.topics = require('./topics');
Controllers.posts = require('./posts');
diff --git a/src/controllers/ping.js b/src/controllers/ping.js
new file mode 100644
index 0000000000..d43beca298
--- /dev/null
+++ b/src/controllers/ping.js
@@ -0,0 +1,15 @@
+'use strict';
+
+var async = require('async');
+var db = require('../database');
+
+module.exports.ping = function (req, res, next) {
+ async.waterfall([
+ function (next) {
+ db.getObject('config', next);
+ },
+ function () {
+ res.status(200).send(req.path === '/sping' ? 'healthy' : '200');
+ },
+ ], next);
+};
diff --git a/src/webserver.js b/src/webserver.js
index dc7c70770c..57904f8dd0 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -116,6 +116,7 @@ function initializeNodeBB(callback) {
function setupExpressApp(app, callback) {
var middleware = require('./middleware');
+ var pingController = require('./controllers/ping');
var relativePath = nconf.get('relative_path');
var viewsDir = nconf.get('views_dir');
@@ -147,8 +148,8 @@ function setupExpressApp(app, callback) {
app.use(compression());
- app.get(relativePath + '/ping', ping);
- app.get(relativePath + '/sping', ping);
+ app.get(relativePath + '/ping', pingController.ping);
+ app.get(relativePath + '/sping', pingController.ping);
setupFavicon(app);
@@ -179,17 +180,6 @@ function setupExpressApp(app, callback) {
setupAutoLocale(app, callback);
}
-function ping(req, res, next) {
- async.waterfall([
- function (next) {
- db.getObject('config', next);
- },
- function () {
- res.status(200).send(req.path === '/sping' ? 'healthy' : '200');
- },
- ], next);
-}
-
function setupFavicon(app) {
var faviconPath = meta.config['brand:favicon'] || 'favicon.ico';
faviconPath = path.join(nconf.get('base_dir'), 'public', faviconPath.replace(/assets\/uploads/, 'uploads'));