Skip to content

Commit

Permalink
Remove legacy keystone.prepare() method
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Mar 25, 2021
1 parent 78b83dd commit bf3775e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 79 deletions.
2 changes: 0 additions & 2 deletions packages/access-control/.npmignore

This file was deleted.

23 changes: 0 additions & 23 deletions packages/app-graphql/package.json

This file was deleted.

47 changes: 0 additions & 47 deletions packages/keystone/lib/Keystone/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const { ApolloServer, gql } = require('apollo-server-express');
const flattenDeep = require('lodash.flattendeep');
const memoize = require('micro-memoize');
const falsey = require('falsey');
const createCorsMiddleware = require('cors');
const { execute } = require('graphql');
const { GraphQLUpload } = require('graphql-upload');
const { objMerge, flatten, unique, filterValues } = require('@keystone-next/utils-legacy');
Expand Down Expand Up @@ -453,48 +450,4 @@ module.exports = class Keystone {
o => Object.entries(o).length > 0
);
}

async _prepareMiddlewares({ dev, apps, distDir, pinoOptions, cors }) {
return flattenDeep([
// Used by other middlewares such as authentication strategies. Important
// to be first so the methods added to `req` are available further down
// the request pipeline.
// TODO: set up a session test rig (maybe by wrapping an in-memory store)
falsey(process.env.DISABLE_LOGGING) && require('express-pino-logger')(pinoOptions),
cors && createCorsMiddleware(cors),
...(await Promise.all(
[
// Inject any field middlewares (eg; WYSIWIG's static assets)
// We do this first to avoid it conflicting with any catch-all routes the
// user may have specified
...this.registeredTypes,
...flattenDeep(
Object.values(this.auth).map(authStrategies => Object.values(authStrategies))
),
...apps,
]
.filter(({ prepareMiddleware } = {}) => !!prepareMiddleware)
.map(app => app.prepareMiddleware({ keystone: this, dev, distDir: distDir || 'dist' }))
)),
]).filter(middleware => !!middleware);
}

async prepare({
dev = false,
apps = [],
distDir,
pinoOptions,
cors = { origin: true, credentials: true },
} = {}) {
this.createApolloServer({ schemaName: 'internal' });
const middlewares = await this._prepareMiddlewares({ dev, apps, distDir, pinoOptions, cors });
// These function can't be called after prepare(), so make them throw an error from now on.
['createList'].forEach(f => {
this[f] = () => {
throw new Error(`keystone.${f} must be called before keystone.prepare()`);
};
});

return { middlewares };
}
};
2 changes: 0 additions & 2 deletions packages/keystone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@keystone-next/utils-legacy": "^7.0.0",
"apollo-errors": "^1.9.0",
"apollo-server-express": "^2.21.2",
"cors": "^2.8.5",
"cuid": "^2.1.8",
"ensure-error": "^3.0.1",
"express": "^4.17.1",
Expand All @@ -21,7 +20,6 @@
"graphql": "^15.5.0",
"graphql-type-json": "^0.3.2",
"graphql-upload": "^11.0.0",
"lodash.flattendeep": "^4.4.0",
"micro-memoize": "^4.0.9",
"p-waterfall": "^2.1.1",
"pino": "^6.11.2",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9152,11 +9152,6 @@ lodash.flatten@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=

lodash.flattendeep@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=

[email protected]:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
Expand Down

0 comments on commit bf3775e

Please sign in to comment.