Skip to content

Commit

Permalink
initial implement for configureExpress
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed Feb 20, 2021
1 parent c8f6a77 commit adf4a03
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples-next/basic/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ export default auth.withAuth(
// // store: redisSessionStore({ client: redis.createClient() }),
// secret: sessionSecret,
// }),
server: {
configureServer(app) {
app.set('trust proxy', true);
}
}
})
);
3 changes: 3 additions & 0 deletions packages-next/keystone/src/lib/createExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const createExpressServer = async (
server.use(cors(corsConfig));
}

if (config.server?.configureServer) {
config.server.configureServer(server);
}
const sessionStrategy = config.session ? config.session() : undefined;

console.log('✨ Preparing GraphQL Server');
Expand Down
1 change: 1 addition & 0 deletions packages-next/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"graphql": "^15.5.0"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/packages-next/types"
Expand Down
3 changes: 3 additions & 0 deletions packages-next/types/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ConnectOptions } from 'mongoose';
import type { Express } from 'express';
import { CorsOptions } from 'cors';
import type { GraphQLSchema } from 'graphql';
import { IncomingMessage } from 'http';
Expand Down Expand Up @@ -98,6 +99,8 @@ export type ServerConfig = {
cors?: CorsOptions | true;
/** Port number to start the server on. Defaults to process.env.PORT || 3000 */
port?: number;
/** Function to configure express, similar to configureExpress from production */
configureServer?: (app: Express) => void;
};

// config.graphql
Expand Down

0 comments on commit adf4a03

Please sign in to comment.