This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
/
main.wasp
224 lines (196 loc) Β· 6.88 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
app SaaSTemplate {
wasp: {
version: "^0.11.6"
},
title: "My SaaS App",
head: [
"<meta property='og:type' content='website' />",
"<meta property='og:url' content='https://mySaaSapp.com' />",
"<meta property='og:description' content='I made a SaaS App. Buy my stuff.' />",
"<meta property='og:image' content='src/client/static/image.png' />",
// you can put your google analytics script here, too!
],
// π Auth out of the box! https://wasp-lang.dev/docs/auth/overview
auth: {
userEntity: User,
externalAuthEntity: SocialLogin,
methods: {
email: {
fromField: {
name: "SaaS App",
// make sure this address is the same you registered your SendGrid or MailGun account with!
email: "vince@wasp-lang.dev"
},
emailVerification: {
clientRoute: EmailVerificationRoute,
getEmailContentFn: import { getVerificationEmailContent } from "@server/auth/email.js",
},
passwordReset: {
clientRoute: PasswordResetRoute,
getEmailContentFn: import { getPasswordResetEmailContent } from "@server/auth/email.js",
},
},
google: { // Guide for setting up Auth via Google https://wasp-lang.dev/docs/auth/social-auth/overview
getUserFieldsFn: import { getUserFields } from "@server/auth/google.js",
configFn: import { config } from "@server/auth/google.js",
},
},
onAuthFailedRedirectTo: "/",
},
db: {
system: PostgreSQL
},
client: {
rootComponent: import App from "@client/App",
},
emailSender: {
provider: SendGrid,
defaultFrom: {
name: "SaaS App",
// make sure this address is the same you registered your SendGrid or MailGun account with!
email: "vince@wasp-lang.dev"
},
},
dependencies: [
("@headlessui/react", "1.7.13"),
("@tailwindcss/forms", "^0.5.3"),
("@tailwindcss/typography", "^0.5.7"),
("react-hook-form", "7.43.1"),
("react-icons", "4.8.0"),
("request-ip", "3.3.0"),
("@types/request-ip", "0.0.37"),
("node-fetch", "3.3.0"),
("react-hook-form", "^7.45.4"),
("stripe", "11.15.0"),
],
}
/* π½ Wasp defines DB entities via Prisma Database Models:
* https://wasp-lang.dev/docs/data-model/entities
*/
entity User {=psl
id Int @id @default(autoincrement())
email String? @unique
password String?
isEmailVerified Boolean @default(false)
emailVerificationSentAt DateTime?
passwordResetSentAt DateTime?
stripeId String?
checkoutSessionId String?
hasPaid Boolean @default(false)
sendEmail Boolean @default(false)
subscriptionStatus String?
datePaid DateTime?
credits Int @default(3)
relatedObject RelatedObject[]
externalAuthAssociations SocialLogin[]
psl=}
entity SocialLogin {=psl
id String @id @default(uuid())
provider String
providerId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
createdAt DateTime @default(now())
@@unique([provider, providerId, userId])
psl=}
// This can be anything. In most cases, this will be your product
entity RelatedObject {=psl
id String @id @default(uuid())
content String
user User @relation(fields: [userId], references: [id])
userId Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
psl=}
/* π‘ These are the Wasp Routes (You can protect them easily w/ 'authRequired: true');
* https://wasp-lang.dev/docs/tutorial/pages
*/
route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage"
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/auth/LoginPage"
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import { Signup } from "@client/auth/SignupPage"
}
route RequestPasswordResetRoute { path: "/request-password-reset", to: RequestPasswordResetPage }
page RequestPasswordResetPage {
component: import { RequestPasswordReset } from "@client/auth/RequestPasswordReset",
}
route PasswordResetRoute { path: "/password-reset", to: PasswordResetPage }
page PasswordResetPage {
component: import { PasswordReset } from "@client/auth/PasswordReset",
}
route EmailVerificationRoute { path: "/email-verification", to: EmailVerificationPage }
page EmailVerificationPage {
component: import { EmailVerification } from "@client/auth/EmailVerification",
}
route GptRoute { path: "/gpt", to: GptPage }
page GptPage {
component: import GptPage from "@client/GptPage"
}
route PricingRoute { path: "/pricing", to: PricingPage }
page PricingPage {
component: import Pricing from "@client/PricingPage"
}
route AccountRoute { path: "/account", to: AccountPage }
page AccountPage {
authRequired: true,
component: import Account from "@client/AccountPage"
}
route CheckoutRoute { path: "/checkout", to: CheckoutPage }
page CheckoutPage {
authRequired: true,
component: import Checkout from "@client/CheckoutPage"
}
/* β These are the Wasp Operations, which allow the client and server to interact:
* https://wasp-lang.dev/docs/data-model/operations/overview
*/
// π Actions aka Mutations
action generateGptResponse {
fn: import { generateGptResponse } from "@server/actions.js",
entities: [User, RelatedObject]
}
action stripePayment {
fn: import { stripePayment } from "@server/actions.js",
entities: [User]
}
// action stripeCreditsPayment {
// fn: import { stripeCreditsPayment } from "@server/actions.js",
// entities: [User]
// }
// action updateUser {
// fn: import { updateUser } from "@server/actions.js",
// entities: [User]
// }
// π Queries
query getRelatedObjects {
fn: import { getRelatedObjects } from "@server/queries.js",
entities: [User, RelatedObject]
}
/*
* π‘ These are custom Wasp API Endpoints. Use them for callbacks, webhooks, etc.
* https://wasp-lang.dev/docs/advanced/apis
*/
api stripeWebhook {
fn: import { stripeWebhook } from "@server/webhooks.js",
entities: [User],
httpRoute: (POST, "/stripe-webhook")
}
/* π΅οΈββοΈ These are the Wasp Cron Jobs. Use them to set up recurring tasks and/or queues:
* https://wasp-lang.dev/docs/advanced/jobs
*/
job emailChecker {
executor: PgBoss,
perform: {
fn: import { checkAndQueueEmails } from "@server/workers/checkAndQueueEmails.js"
},
schedule: {
cron: "0 7 * * 1" // at 7:00 am every Monday
},
entities: [User]
}