From a762928e971d0a21799cd15818647518da36db93 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 24 Jun 2018 13:59:18 +0200
Subject: [PATCH] Do final internal renameing

A little minor change, by moving the CodiMD version header in its own
middleware. Should simplify to determine the version number of the
Backend in future.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
---
 app.js                              |  1 +
 lib/response.js                     |  4 ++--
 lib/web/middleware/codiMDVersion.js | 10 ++++++++++
 lib/web/statusRouter.js             |  6 ++----
 4 files changed, 15 insertions(+), 6 deletions(-)
 create mode 100644 lib/web/middleware/codiMDVersion.js

diff --git a/app.js b/app.js
index a9bd2ec..e247913 100644
--- a/app.js
+++ b/app.js
@@ -163,6 +163,7 @@ app.use(passport.session())
 app.use(require('./lib/web/middleware/checkURIValid'))
 // redirect url without trailing slashes
 app.use(require('./lib/web/middleware/redirectWithoutTrailingSlashes'))
+app.use(require('./lib/web/middleware/codiMDVersion'))
 
 // routes need sessions
 // template files
diff --git a/lib/response.js b/lib/response.js
index e256d47..252208b 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -109,7 +109,7 @@ function showIndex (req, res, next) {
   }
 }
 
-function responseHackMD (res, note) {
+function responseCodiMD (res, note) {
   var body = note.content
   var extracted = models.Note.extractMeta(body)
   var meta = models.Note.parseMeta(extracted.meta)
@@ -214,7 +214,7 @@ function showNote (req, res, next) {
     var noteId = req.params.noteId
     var id = models.Note.encodeNoteId(note.id)
     if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) { return res.redirect(config.serverURL + '/' + (note.alias || id)) }
-    return responseHackMD(res, note)
+    return responseCodiMD(res, note)
   })
 }
 
diff --git a/lib/web/middleware/codiMDVersion.js b/lib/web/middleware/codiMDVersion.js
new file mode 100644
index 0000000..e777587
--- /dev/null
+++ b/lib/web/middleware/codiMDVersion.js
@@ -0,0 +1,10 @@
+'use strict'
+
+const config = require('../../config')
+
+module.exports = function (req, res, next) {
+  res.set({
+    'CodiMD-Version': config.version
+  })
+  return next()
+}
diff --git a/lib/web/statusRouter.js b/lib/web/statusRouter.js
index 4495a28..256fead 100644
--- a/lib/web/statusRouter.js
+++ b/lib/web/statusRouter.js
@@ -17,8 +17,7 @@ statusRouter.get('/status', function (req, res, next) {
   realtime.getStatus(function (data) {
     res.set({
       'Cache-Control': 'private', // only cache by client
-      'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
-      'HackMD-Version': config.version
+      'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
     })
     res.send(data)
   })
@@ -102,8 +101,7 @@ statusRouter.get('/config', function (req, res) {
   }
   res.set({
     'Cache-Control': 'private', // only cache by client
-    'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
-    'HackMD-Version': config.version
+    'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
   })
   res.render(config.constantsPath, data)
 })