// keystone.ts
import { list, config } from '@keystone-6/core'
import { password, text, relationship } from '@keystone-6/core/fields'
import { withAuth, session } from './auth'
const lists = {
User: list({
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ validation: { isRequired: true }, isIndexed: 'unique' }),
password: password({ validation: { isRequired: true } }),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
Post: list({
fields: {
title: text(),
author: relationship({ ref: 'User.posts' }),
},
}),
}
export default config(
withAuth({
db: {
provider: 'sqlite',
// ... db config
},
lists,
session,
ui: {
// Restrict Admin UI access to authenticated users
isAccessAllowed: context => !!context.session?.data,
},
})
)