-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathkeystone.ts
52 lines (47 loc) · 1.17 KB
/
keystone.ts
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
import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import { createAuth } from '@keystone-6/auth';
import { lists, extendGraphqlSchema } from './schema';
import { rules } from './schema/access';
const dbUrl =
process.env.DATABASE_URL ||
`postgres://${process.env.USER}@localhost/prisma-day-workshop`;
const sessionSecret =
process.env.SESSION_SECERT ||
'iLqbHhm7qwiBNc8KgL4NQ8tD8fFVhNhNqZ2nRdprgnKNjgJHgvitWx6DPoZJpYHa';
const auth = createAuth({
identityField: 'email',
secretField: 'password',
listKey: 'User',
sessionData: `id name role {
canManageContent
canManageUsers
}`,
initFirstItem: {
fields: ['name', 'email', 'password'],
itemData: {
role: {
create: {
name: 'Super User',
canManageContent: true,
canManageUsers: true,
},
},
},
},
});
export default auth.withAuth(
config({
db: {
url: dbUrl,
provider: 'postgresql',
useMigrations: true,
},
ui: { isAccessAllowed: rules.canUseAdminUI },
lists,
session: statelessSessions({
secret: sessionSecret,
}),
extendGraphqlSchema,
})
);