This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
52 lines (46 loc) · 1.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require("dotenv").config();
const { Keystone } = require("@keystonejs/keystone");
const { PasswordAuthStrategy } = require("@keystonejs/auth-password");
const { KnexAdapter } = require("@keystonejs/adapter-knex");
const { GraphQLApp } = require("@keystonejs/app-graphql");
const { StaticApp } = require("@keystonejs/app-static");
const { AdminUIApp } = require("@keystonejs/app-admin-ui");
const { User } = require("./schema/user");
const { Comment } = require("./schema/comment");
const { Page } = require("./schema/page");
const { customMutations } = require("./schema/custom-mutations");
const knexAdapter = new KnexAdapter();
const keystone = new Keystone({
name: "keystone_blog_enrichment",
adapter: knexAdapter,
secureCookies: false // We're setting this to false so it works cross-domain and with non-https - You might want to set it to true.
});
keystone.createList("User", User);
keystone.createList("Comment", Comment);
keystone.createList("Page", Page);
const adminAuthStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: "User"
});
keystone.extendGraphQLSchema({
mutations: customMutations(keystone)
});
module.exports = {
keystone,
apps: [
new GraphQLApp(),
new AdminUIApp({
authStrategy: adminAuthStrategy,
isAccessAllowed: ({ authentication: { item } }) => {
return item && item.isAdmin; // Only allow admin to access the UI
}
}),
new StaticApp({ path: "/", src: "static" })
],
configureExpress: app => {
if (process.env.NODE_ENV !== "development") {
app.set("trust proxy", "1"); // This setting is needed for Heroku
}
},
knexAdapter
};