-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.wasp
109 lines (95 loc) · 2.5 KB
/
main.wasp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
app Blog {
wasp: {
version: "^0.11.8"
},
title: "Blog",
client: {
rootComponent: import { Layout } from "@client/Layout.jsx",
},
db: {
prisma: {
clientPreviewFeatures: ["extendedWhereUnique"]
}
},
auth: {
userEntity: User,
methods: {
usernameAndPassword: {}
},
onAuthFailedRedirectTo: "/login",
onAuthSucceededRedirectTo: "/"
},
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/pages/auth/Login.jsx"
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/pages/auth/Signup.jsx"
}
entity User {=psl
id Int @id @default(autoincrement())
username String @unique
password String
posts Post[]
comments Comment[]
psl=}
entity Post {=psl
id Int @id @default(autoincrement())
title String
content String
authorId Int
author User @relation(fields: [authorId], references: [id])
comments Comment[]
psl=}
entity Comment {=psl
id Int @id @default(autoincrement())
text String
postId Int
post Post @relation(fields: [postId], references: [id])
authorId Int
author User @relation(fields: [authorId], references: [id])
psl=}
action createPost {
fn: import { createPost } from "@server/actions.js",
entities: [Post]
}
action editPost {
fn: import { editPost } from "@server/actions.js",
entities: [Post]
}
action createComment {
fn: import { createComment } from "@server/actions.js",
entities: [Comment]
}
query getPosts {
fn: import { getPosts } from "@server/queries.js",
entities: [Post, User]
}
query getPost {
fn: import { getPost } from "@server/queries.js",
entities: [Post, Comment]
}
query getPostForEdit {
fn: import { getPostForEdit } from "@server/queries.js",
entities: [Post]
}
route HomeRoute { path: "/", to: HomePage }
page HomePage {
component: import HomePage from "@client/pages/Home.jsx"
}
route NewPostRoute { path: "/new-post", to: NewPostPage }
page NewPostPage {
component: import NewPostPage from "@client/pages/NewPost.jsx",
authRequired: true
}
route EditPostRoute { path: "/edit-post/:postId", to: EditPostPage }
page EditPostPage {
component: import EditPostPage from "@client/pages/EditPost.jsx",
authRequired: true
}
route ViewPostRoute { path: "/post/:postId", to: ViewPostPage }
page ViewPostPage {
component: import ViewPostPage from "@client/pages/ViewPost.jsx"
}