wasp/examples/realworld/main.wasp

202 lines
5.1 KiB
JavaScript
Raw Normal View History

app Conduit {
2021-02-05 12:57:26 +03:00
title: "Conduit",
head: [
"<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap\" />"
],
auth: {
userEntity: User,
methods: [ EmailAndPassword ],
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")
2021-02-05 12:57:26 +03:00
]
}
// ----------------- Pages ------------------ //
route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@ext/MainPage.js"
}
route LogInRoute { path: "/login", to: LogInPage }
page LogInPage {
component: import LogIn from "@ext/auth/LoginPage.js"
}
route RegisterRoute { path: "/register", to: SignUpPage }
page SignUpPage {
component: import SignUp from "@ext/auth/SignupPage.js"
}
route UserSettingsRoute { path: "/settings", to: UserSettingsPage }
page UserSettingsPage {
authRequired: true,
2020-11-30 20:11:40 +03:00
component: import UserSettings from "@ext/user/components/UserSettingsPage.js"
}
route UserProfileRoute { path: "/@:username", to: UserProfilePage }
page UserProfilePage {
2020-11-30 20:11:40 +03:00
component: import UserProfile from "@ext/user/components/UserProfilePage.js"
}
route ArticleEditorRoute { path: "/editor/:articleSlug?", to: ArticleEditorPage }
page ArticleEditorPage {
authRequired: true,
2020-11-30 20:11:40 +03:00
component: import ArticleEditor from "@ext/article/components/ArticleEditorPage.js"
2020-11-20 20:22:49 +03:00
}
route ArticleViewRoute { path: "/article/:articleSlug", to: ArticleViewPage }
page ArticleViewPage {
2020-11-30 20:11:40 +03:00
component: import ArticleView from "@ext/article/components/ArticleViewPage.js"
2020-11-20 20:22:49 +03:00
}
// ----------------- Entities ------------------ //
entity User {=psl
2020-11-25 00:57:14 +03:00
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
profilePictureUrl String?
2020-11-25 00:57:14 +03:00
articles Article[]
comments Comment[]
2020-11-27 00:48:35 +03:00
favoriteArticles Article[] @relation("FavoritedArticles")
2020-11-27 18:10:02 +03:00
followedBy User[] @relation("FollowedUser", references: [id])
following User[] @relation("FollowedUser", references: [id])
2020-11-20 20:22:49 +03:00
psl=}
entity Article {=psl
2020-11-24 22:39:36 +03:00
id Int @id @default(autoincrement())
2020-11-24 23:10:26 +03:00
slug String @unique
2020-11-24 22:39:36 +03:00
createdAt DateTime @default(now())
2020-11-24 23:10:26 +03:00
updatedAt DateTime @updatedAt
2020-11-24 22:39:36 +03:00
title String
description String
markdownContent String
2020-11-25 00:57:14 +03:00
2020-11-24 22:39:36 +03:00
user User @relation(fields: [userId], references: [id])
userId Int
2020-11-25 00:57:14 +03:00
comments Comment[]
2020-11-25 18:25:26 +03:00
tags ArticleTag[]
2020-11-27 00:48:35 +03:00
favoritedBy User[] @relation("FavoritedArticles")
2020-11-25 00:57:14 +03:00
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])
articleId Int
psl=}
2020-11-25 18:25:26 +03:00
entity ArticleTag {=psl
name String @id
articles Article[]
psl=}
// ----------------- User operations ------------------ //
query getUser {
fn: import { getUser } from "@ext/user/queries.js",
entities: [User]
}
action updateUser {
fn: import { updateUser } from "@ext/user/actions.js",
entities: [User]
2020-11-20 20:22:49 +03:00
}
2020-11-27 18:10:02 +03:00
action followUser {
fn: import { followUser } from "@ext/user/actions.js",
2020-11-27 18:10:02 +03:00
entities: [User]
}
// ----------------- Article operations ------------------ //
2020-11-20 20:22:49 +03:00
query getArticlesByUser {
fn: import { getArticlesByUser } from "@ext/article/queries.js",
2020-11-20 20:22:49 +03:00
entities: [Article]
}
2020-11-27 00:48:35 +03:00
query getFavoritedArticles {
fn: import { getFavoritedArticles } from "@ext/article/queries.js",
2020-11-27 00:48:35 +03:00
entities: [Article]
}
query getFollowedArticles {
fn: import { getFollowedArticles } from "@ext/article/queries.js",
entities: [Article, User]
}
query getAllArticles {
fn: import { getAllArticles } from "@ext/article/queries.js",
entities: [Article]
}
2020-11-20 20:22:49 +03:00
query getArticle {
fn: import { getArticle } from "@ext/article/queries.js",
2020-11-20 20:22:49 +03:00
entities: [Article]
}
2020-11-25 00:57:14 +03:00
query getArticleComments {
fn: import { getArticleComments } from "@ext/article/queries.js",
2020-11-25 00:57:14 +03:00
entities: [Comment]
}
2020-11-20 20:22:49 +03:00
action createArticle {
fn: import { createArticle } from "@ext/article/actions.js",
2020-11-20 20:22:49 +03:00
entities: [Article]
}
action updateArticle {
fn: import { updateArticle } from "@ext/article/actions.js",
2020-11-20 20:22:49 +03:00
entities: [Article]
}
action deleteArticle {
fn: import { deleteArticle } from "@ext/article/actions.js",
2020-11-20 20:22:49 +03:00
entities: [Article]
2020-11-24 22:39:36 +03:00
}
2020-11-27 00:48:35 +03:00
action setArticleFavorited {
fn: import { setArticleFavorited } from "@ext/article/actions.js",
2020-11-27 00:48:35 +03:00
entities: [Article]
}
2020-11-25 00:57:14 +03:00
action createComment {
fn: import { createComment } from "@ext/article/actions.js",
2020-11-25 00:57:14 +03:00
entities: [Comment]
}
action deleteComment {
fn: import { deleteComment } from "@ext/article/actions.js",
2020-11-25 00:57:14 +03:00
entities: [Comment]
}
2020-11-26 18:35:38 +03:00
query getTags {
fn: import { getTags } from "@ext/article/queries.js",
2020-11-26 18:35:38 +03:00
entities: [ArticleTag, Article]
}
// -------------------------------------------- //