@@ -6,83 +6,89 @@ const { graphql } = require('@tensei/graphql')
6
6
const { mde, markdown } = require ( '@tensei/mde' )
7
7
8
8
const {
9
- tensei,
10
- welcome,
11
- cors,
12
- resource,
13
- text,
14
- textarea,
15
- dateTime,
16
- slug,
17
- array,
18
- hasMany,
19
- belongsTo,
20
- boolean,
9
+ tensei,
10
+ welcome,
11
+ cors,
12
+ resource,
13
+ text,
14
+ textarea,
15
+ dateTime,
16
+ slug,
17
+ array,
18
+ hasMany,
19
+ belongsTo,
20
+ boolean
21
21
} = require ( '@tensei/core' )
22
22
23
23
module . exports = tensei ( )
24
- . root ( __dirname )
25
- . resources ( [
26
- resource ( 'Post' )
27
- . fields ( [
28
- text ( 'Title' ) . rules ( 'required' ) ,
29
- slug ( 'Slug' ) . creationRules ( 'required' , 'unique:slug' ) . unique ( ) . from ( 'Title' ) ,
30
- markdown ( 'Description' ) . creationRules ( 'required' , 'max:255' ) ,
31
- textarea ( 'Content' ) . nullable ( ) . rules ( 'required' ) ,
32
- dateTime ( 'Published At' ) . creationRules ( 'required' ) ,
33
- belongsTo ( 'Category' ) . alwaysLoad ( ) ,
34
- array ( 'Procedure' )
35
- . of ( 'string' )
36
- . rules ( 'min:3' , 'max:10' )
37
- . creationRules ( 'required' ) ,
38
- array ( 'Prices' )
39
- . nullable ( )
40
- . of ( 'decimal' )
41
- . rules ( 'max:10' , 'min:2' )
42
- . creationRules ( 'required' )
43
- ] )
44
- . icon ( 'library' )
45
- . displayField ( 'Title' ) ,
46
- resource ( 'Category' )
47
- . fields ( [
48
- text ( 'Name' ) . notNullable ( ) . rules ( 'required' ) ,
49
- textarea ( 'Description' ) ,
50
- belongsTo ( 'User' ) . nullable ( ) ,
51
- hasMany ( 'Post' )
52
- ] )
53
- . disableAutoFilters ( )
54
- . displayField ( 'Name' )
55
- ] )
56
- . plugins ( [
57
- welcome ( ) ,
58
- cms ( ) . plugin ( ) ,
59
- auth ( )
60
- . verifyEmails ( )
61
- . twoFactorAuth ( )
62
- . social ( 'google' , {
63
- key : process . env . GOOGLE_KEY ,
64
- secret : process . env . GOOGLE_SECRET ,
65
- clientCallback : 'http://localhost:1234'
66
- } )
67
- . setup ( ( { user } ) => {
68
- user . fields ( [
69
- hasMany ( 'Category' ) ,
70
- boolean ( 'Accepted Terms And Conditions' ) . rules ( 'required' ) . default ( false )
71
- ] )
72
- } )
73
- . configureTokens ( {
74
- accessTokenExpiresIn : 60
75
- } )
76
- . refreshTokens ( )
77
- . plugin ( ) ,
78
- rest ( ) . plugin ( ) ,
79
- graphql ( ) . plugin ( ) ,
80
- cors ( ) ,
81
- mde ( ) . plugin ( )
82
- ] )
83
- // .databaseConfig({
84
- // type: 'sqlite',
85
- // dbName: 'db.sqlite',
86
- // })
87
- . start ( )
88
- . catch ( console . error )
24
+ . root ( __dirname )
25
+ . resources ( [
26
+ resource ( 'Post' )
27
+ . fields ( [
28
+ text ( 'Title' ) . rules ( 'required' ) ,
29
+ slug ( 'Slug' )
30
+ . creationRules ( 'required' , 'unique:slug' )
31
+ . unique ( )
32
+ . from ( 'Title' ) ,
33
+ markdown ( 'Description' ) . creationRules ( 'required' , 'max:255' ) ,
34
+ textarea ( 'Content' ) . nullable ( ) . rules ( 'required' ) ,
35
+ dateTime ( 'Published At' ) . creationRules ( 'required' ) ,
36
+ belongsTo ( 'Category' ) . alwaysLoad ( ) ,
37
+ array ( 'Procedure' )
38
+ . of ( 'string' )
39
+ . rules ( 'min:3' , 'max:10' )
40
+ . creationRules ( 'required' ) ,
41
+ array ( 'Prices' )
42
+ . nullable ( )
43
+ . of ( 'decimal' )
44
+ . rules ( 'max:10' , 'min:2' )
45
+ . creationRules ( 'required' )
46
+ ] )
47
+ . icon ( 'library' )
48
+ . displayField ( 'Title' ) ,
49
+ resource ( 'Category' )
50
+ . fields ( [
51
+ text ( 'Name' ) . notNullable ( ) . rules ( 'required' ) ,
52
+ textarea ( 'Description' ) ,
53
+ belongsTo ( 'User' ) . nullable ( ) ,
54
+ hasMany ( 'Post' )
55
+ ] )
56
+ . displayField ( 'Name' )
57
+ ] )
58
+ . plugins ( [
59
+ welcome ( ) ,
60
+ cms ( ) . plugin ( ) ,
61
+ auth ( )
62
+ . teams ( )
63
+ . verifyEmails ( )
64
+ . twoFactorAuth ( )
65
+ . social ( 'google' , {
66
+ key : process . env . GOOGLE_KEY ,
67
+ secret : process . env . GOOGLE_SECRET ,
68
+ clientCallback : 'http://localhost:1234'
69
+ } )
70
+ . setup ( ( { user } ) => {
71
+ user . fields ( [
72
+ hasMany ( 'Category' ) ,
73
+ boolean ( 'Accepted Terms And Conditions' )
74
+ . creationRules ( 'required' )
75
+ . default ( false )
76
+ ] )
77
+ } )
78
+ . configureTokens ( {
79
+ accessTokenExpiresIn : 60 * 60 * 60 * 60 * 60
80
+ } )
81
+ . refreshTokens ( )
82
+ . plugin ( ) ,
83
+ rest ( ) . plugin ( ) ,
84
+ graphql ( ) . plugin ( ) ,
85
+ cors ( ) ,
86
+ mde ( ) . plugin ( )
87
+ ] )
88
+ . databaseConfig ( {
89
+ type : 'sqlite' ,
90
+ dbName : 'db.sqlite'
91
+ // debug: true
92
+ } )
93
+ . start ( )
94
+ . catch ( console . error )
0 commit comments