wasp/examples/realworld/main.wasp
2023-01-02 12:11:39 -05:00

208 lines
5.2 KiB
JavaScript

app Conduit {
wasp: {
version: "^0.8.0"
},
title: "Conduit",
head: [
"<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap\" />"
],
auth: {
userEntity: User,
methods: {
usernameAndPassword: {}
},
onAuthFailedRedirectTo: "/login"
},
db: { system: PostgreSQL },
dependencies: [
("prop-types", "15.7.2"),
("react-markdown", "5.0.3"),
("moment", "2.29.1"),
("@material-ui/core", "4.11.3"),
("@material-ui/icons", "4.11.2"),
("slug", "4.0.2")
]
}
// ----------------- Pages ------------------ //
route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage.js"
}
route LogInRoute { path: "/login", to: LogInPage }
page LogInPage {
component: import LogIn from "@client/auth/LoginPage.js"
}
route RegisterRoute { path: "/register", to: SignUpPage }
page SignUpPage {
component: import SignUp from "@client/auth/SignupPage.js"
}
route UserSettingsRoute { path: "/settings", to: UserSettingsPage }
page UserSettingsPage {
authRequired: true,
component: import UserSettings from "@client/user/components/UserSettingsPage.js"
}
route UserProfileRoute { path: "/@:username", to: UserProfilePage }
page UserProfilePage {
component: import UserProfile from "@client/user/components/UserProfilePage.js"
}
route ArticleEditorRoute { path: "/editor/:articleSlug?", to: ArticleEditorPage }
page ArticleEditorPage {
authRequired: true,
component: import ArticleEditor from "@client/article/components/ArticleEditorPage.js"
}
route ArticleViewRoute { path: "/article/:articleSlug", to: ArticleViewPage }
page ArticleViewPage {
component: import ArticleView from "@client/article/components/ArticleViewPage.js"
}
// ----------------- Entities ------------------ //
entity User {=psl
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
articles Article[]
comments Comment[]
favoriteArticles Article[] @relation("FavoritedArticles")
followedBy User[] @relation("FollowedUser")
following User[] @relation("FollowedUser")
psl=}
entity Article {=psl
id Int @id @default(autoincrement())
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
description String
markdownContent String
user User @relation(fields: [userId], references: [id])
userId Int
comments Comment[]
tags ArticleTag[]
favoritedBy User[] @relation("FavoritedArticles")
psl=}
entity Comment {=psl
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
content String
user User @relation(fields: [userId], references: [id])
userId Int
article Article @relation(fields: [articleId], references: [id], onDelete: Cascade)
articleId Int
psl=}
entity ArticleTag {=psl
name String @id
articles Article[]
psl=}
// ----------------- User operations ------------------ //
query getUser {
fn: import { getUser } from "@server/user/queries.js",
entities: [User]
}
action updateUser {
fn: import { updateUser } from "@server/user/actions.js",
entities: [User]
}
action followUser {
fn: import { followUser } from "@server/user/actions.js",
entities: [User]
}
// ----------------- Article operations ------------------ //
query getArticlesByUser {
fn: import { getArticlesByUser } from "@server/article/queries.js",
entities: [Article]
}
query getFavoritedArticles {
fn: import { getFavoritedArticles } from "@server/article/queries.js",
entities: [Article]
}
query getFollowedArticles {
fn: import { getFollowedArticles } from "@server/article/queries.js",
entities: [Article, User]
}
query getAllArticles {
fn: import { getAllArticles } from "@server/article/queries.js",
entities: [Article]
}
query getArticle {
fn: import { getArticle } from "@server/article/queries.js",
entities: [Article]
}
query getArticleComments {
fn: import { getArticleComments } from "@server/article/queries.js",
entities: [Comment]
}
action createArticle {
fn: import { createArticle } from "@server/article/actions.js",
entities: [Article]
}
action updateArticle {
fn: import { updateArticle } from "@server/article/actions.js",
entities: [Article]
}
action deleteArticle {
fn: import { deleteArticle } from "@server/article/actions.js",
entities: [Article]
}
action setArticleFavorited {
fn: import { setArticleFavorited } from "@server/article/actions.js",
entities: [Article]
}
action createComment {
fn: import { createComment } from "@server/article/actions.js",
entities: [Comment]
}
action deleteComment {
fn: import { deleteComment } from "@server/article/actions.js",
entities: [Comment]
}
query getTags {
fn: import { getTags } from "@server/article/queries.js",
entities: [ArticleTag, Article]
}
// -------------------------------------------- //