wasp/examples/realworld/main.wasp

189 lines
4.6 KiB
JavaScript
Raw Normal View History

app Conduit {
title: "Conduit"
}
auth {
userEntity: User,
methods: [ EmailAndPassword ]
}
// ----------------- Pages ------------------ //
route "/" -> page Main
page Main {
component: import Main from "@ext/MainPage.js"
}
route "/login" -> page LogIn
page LogIn {
component: import LogIn from "@ext/auth/LoginPage.js"
}
route "/register" -> page SignUp
page SignUp {
component: import SignUp from "@ext/auth/SignupPage.js"
}
route "/settings" -> page UserSettings
page UserSettings {
2020-11-30 20:11:40 +03:00
component: import UserSettings from "@ext/user/components/UserSettingsPage.js"
}
route "/@:username" -> page UserProfile
page UserProfile {
2020-11-30 20:11:40 +03:00
component: import UserProfile from "@ext/user/components/UserProfilePage.js"
}
2020-11-24 23:10:26 +03:00
route "/editor/:articleSlug?" -> page ArticleEditor
2020-11-20 20:22:49 +03:00
page ArticleEditor {
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
}
2020-11-24 23:10:26 +03:00
route "/article/:articleSlug" -> page ArticleView
2020-11-20 20:22:49 +03:00
page ArticleView {
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]
}
// -------------------------------------------- //
2020-11-24 22:39:36 +03:00
dependencies {=json
2020-11-25 00:57:14 +03:00
"prop-types": "15.7.2",
2020-11-24 22:39:36 +03:00
"react-markdown": "5.0.3",
2020-11-24 23:10:26 +03:00
"moment": "2.29.1",
"slug": "4.0.2"
json=}