-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeystone.ts
More file actions
58 lines (57 loc) · 2.13 KB
/
keystone.ts
File metadata and controls
58 lines (57 loc) · 2.13 KB
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
53
54
55
56
57
58
import { config, list } from '@keystone-6/core';
import {text, integer, password} from '@keystone-6/core/fields';
import {withAuth, session} from './auth';
export default withAuth(
config({
server: {
cors: {
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS'
}
},
db: {
provider: 'sqlite',
url: 'file:./keystone.db',
useMigrations: true
},
ui: {
// We check that someone has session data before letting them see the Admin UI.
isAccessAllowed: (context) => !!context.session?.data,
},
lists: {
Player: list({
fields: {
name: text({validation: {isRequired: true}, isFilterable: true}),
seed: text({validation: {isRequired: true}, isIndexed: 'unique'}),
rooms_cleared: integer({
defaultValue: 0,
validation: {
isRequired: true,
},
})
},
}),
User: list({
// Here are the fields that `User` will have. We want an email and password so they can log in
// a name so we can refer to them, and a way to connect users to posts.
fields: {
name: text({validation: {isRequired: true}}),
email: text({
validation: {isRequired: true},
isIndexed: 'unique',
isFilterable: true,
}),
// The password field takes care of hiding details and hashing values
password: password({validation: {isRequired: true}}),
},
// Here we can configure the Admin UI. We want to show a user's name and posts in the Admin UI
ui: {
listView: {
initialColumns: ['name'],
},
},
}),
},
session,
})
);