From c3fe03fae513bb1ee68aca28efe91ba085133aca Mon Sep 17 00:00:00 2001 From: Frankie Roberto Date: Fri, 13 Dec 2024 14:39:24 +0000 Subject: [PATCH] Move middleware into lib folder (#440) This moves the `middleware` folder into the `lib` folder and updates file references to them. This is to enable easier updates to the kit, as the instructions could be simplified to downloading the new version and replacing the `lib` folder, plus a few manual changes to files outside `lib` (which we can hopefully further reduce). Part of #393. --- app.js | 6 +++--- {middleware => lib/middleware}/authentication.js | 2 +- {middleware => lib/middleware}/auto-routing.js | 0 {middleware => lib/middleware}/prototype-admin-routes.js | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename {middleware => lib/middleware}/authentication.js (96%) rename {middleware => lib/middleware}/auto-routing.js (100%) rename {middleware => lib/middleware}/prototype-admin-routes.js (94%) diff --git a/app.js b/app.js index 0f36af36..15e298b7 100755 --- a/app.js +++ b/app.js @@ -16,14 +16,14 @@ dotenv.config(); // Local dependencies const packageInfo = require('./package.json'); -const authentication = require('./middleware/authentication'); -const automaticRouting = require('./middleware/auto-routing'); +const authentication = require('./lib/middleware/authentication'); +const automaticRouting = require('./lib/middleware/auto-routing'); const config = require('./app/config'); const locals = require('./app/locals'); const routes = require('./app/routes'); const utils = require('./lib/utils'); -const prototypeAdminRoutes = require('./middleware/prototype-admin-routes'); +const prototypeAdminRoutes = require('./lib/middleware/prototype-admin-routes'); const exampleTemplatesRoutes = require('./lib/example_templates_routes'); // Set configuration variables diff --git a/middleware/authentication.js b/lib/middleware/authentication.js similarity index 96% rename from middleware/authentication.js rename to lib/middleware/authentication.js index f5f7c6de..1412526f 100644 --- a/middleware/authentication.js +++ b/lib/middleware/authentication.js @@ -1,5 +1,5 @@ const url = require('url'); -const { encryptPassword } = require('../lib/utils'); +const { encryptPassword } = require('../utils'); const allowedPathsWhenUnauthenticated = [ '/prototype-admin/password', diff --git a/middleware/auto-routing.js b/lib/middleware/auto-routing.js similarity index 100% rename from middleware/auto-routing.js rename to lib/middleware/auto-routing.js diff --git a/middleware/prototype-admin-routes.js b/lib/middleware/prototype-admin-routes.js similarity index 94% rename from middleware/prototype-admin-routes.js rename to lib/middleware/prototype-admin-routes.js index c4de31ed..b46a67ff 100644 --- a/middleware/prototype-admin-routes.js +++ b/lib/middleware/prototype-admin-routes.js @@ -4,7 +4,7 @@ const router = express.Router(); const password = process.env.PROTOTYPE_PASSWORD; -const { encryptPassword } = require('../lib/utils'); +const { encryptPassword } = require('../utils'); router.get('/password', (req, res) => { const returnURL = req.query.returnURL || '/'; diff --git a/package.json b/package.json index 35f14c52..e1328584 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test:ci": "jest --ci", "prewatch": "gulp build", "watch": "gulp", - "lint:js": "eslint -c ./linters/.eslintrc.js app.js middleware/**/*.js lib/**/*.js app/*.js" + "lint:js": "eslint -c ./linters/.eslintrc.js app.js lib/**/*.js app/*.js" }, "author": "https://github.com/nhsuk/", "license": "MIT",