Moved Cache-Control middleware to separate package

refs https://github.com/TryGhost/Toolbox/issues/363

- this middleware is standalone and I suspect we're going to be touching
  it further when we work on Ghost's caching in the near future
This commit is contained in:
Daniel Lockyer 2022-08-11 14:10:39 +02:00
parent 18cd104510
commit 42e722d627
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD
9 changed files with 69 additions and 3 deletions

View File

@ -8,7 +8,7 @@ module.exports = {
},
get cacheControl() {
return require('./cache-control');
return require('@tryghost/mw-cache-control');
},
get prettyUrls() {

View File

@ -92,6 +92,7 @@
"@tryghost/metrics": "1.0.15",
"@tryghost/minifier": "0.0.0",
"@tryghost/mw-api-version-mismatch": "0.0.0",
"@tryghost/mw-cache-control": "0.0.0",
"@tryghost/mw-error-handler": "0.0.0",
"@tryghost/mw-session-from-token": "0.0.0",
"@tryghost/mw-vhost": "0.0.0",

View File

@ -0,0 +1,6 @@
module.exports = {
plugins: ['ghost'],
extends: [
'plugin:ghost/node'
]
};

View File

@ -0,0 +1,23 @@
# Mw Cache Control
Cache-Control middleware for Ghost
## Usage
## Develop
This is a monorepo package.
Follow the instructions for the top-level repo.
1. `git clone` this repo & `cd` into it as usual
2. Run `yarn` to install top-level dependencies.
## Test
- `yarn lint` run just eslint
- `yarn test` run lint and tests

View File

@ -0,0 +1 @@
module.exports = require('./lib/mw-cache-control');

View File

@ -0,0 +1,28 @@
{
"name": "@tryghost/mw-cache-control",
"version": "0.0.0",
"repository": "https://github.com/TryGhost/Ghost/tree/main/packages/mw-cache-control",
"author": "Ghost Foundation",
"private": true,
"main": "index.js",
"scripts": {
"dev": "echo \"Implement me!\"",
"test": "NODE_ENV=testing c8 --all --check-coverage --reporter text --reporter cobertura mocha './test/**/*.test.js'",
"lint:code": "eslint *.js lib/ --ext .js --cache",
"lint": "yarn lint:code && yarn lint:test",
"lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache"
},
"files": [
"index.js",
"lib"
],
"devDependencies": {
"c8": "7.12.0",
"mocha": "10.0.0",
"should": "13.2.3",
"sinon": "14.0.0"
},
"dependencies": {
"lodash": "4.17.21"
}
}

View File

@ -0,0 +1,6 @@
module.exports = {
plugins: ['ghost'],
extends: [
'plugin:ghost/test'
]
};

View File

@ -1,8 +1,9 @@
const should = require('should');
const sinon = require('sinon');
const cacheControl = require('../../../../../../core/server/web/shared/middleware/cache-control');
describe('Middleware: cacheControl', function () {
const cacheControl = require('../');
describe('Cache-Control middleware', function () {
let res;
beforeEach(function () {