wasp/examples/thoughts/main.wasp
2023-06-14 21:56:26 +02:00

89 lines
2.0 KiB
JavaScript

app Thoughts {
wasp: {
version: "^0.11.0"
},
title: "Thoughts",
db: {
system: PostgreSQL,
seeds: [ import { devSeedBasic } from "@server/seeds.js" ]
},
auth: {
userEntity: User,
methods: { usernameAndPassword: {} },
onAuthFailedRedirectTo: "/login"
},
dependencies: [
("react-markdown", "6.0.1"),
("color-hash", "2.0.1")
],
}
route MainRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage.jsx",
authRequired: true
}
route ThoughtsRoute { path: "/thoughts", to: ThoughtsPage }
page ThoughtsPage {
component: import Thoughts from "@client/ThoughtsPage.jsx",
authRequired: true
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/LoginPage.jsx"
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/SignupPage.jsx"
}
action createThought {
fn: import { createThought } from "@server/actions.js",
entities: [Thought, Tag]
}
query getThoughts {
fn: import { getThoughts } from "@server/queries.js",
entities: [Thought]
}
query getTags {
fn: import { getTags } from "@server/queries.js",
entities: [Tag]
}
entity Thought {=psl
id Int @id @default(autoincrement())
textMarkdown String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tags Tag[]
user User @relation(fields: [userId], references: [id])
userId Int
psl=}
entity Tag {=psl
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
thoughts Thought[]
user User @relation(fields: [userId], references: [id])
userId Int
@@unique([name, userId])
psl=}
entity User {=psl
id Int @id @default(autoincrement())
username String @unique
password String
thoughts Thought[]
tags Tag[]
psl=}