wasp/examples/thoughts/main.wasp
2022-11-25 18:21:10 +01:00

88 lines
1.9 KiB
JavaScript

app Thoughts {
wasp: {
version: "^0.7.0"
},
title: "Thoughts",
db: { system: PostgreSQL },
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.js",
authRequired: true
}
route ThoughtsRoute { path: "/thoughts", to: ThoughtsPage }
page ThoughtsPage {
component: import Thoughts from "@client/ThoughtsPage.js",
authRequired: true
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import Login from "@client/LoginPage.js"
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import Signup from "@client/SignupPage"
}
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=}