wasp/examples/todo-typescript/main.wasp

75 lines
2.3 KiB
JavaScript
Raw Normal View History

2022-12-20 13:30:00 +03:00
app TodoTypescript {
2022-12-20 13:11:13 +03:00
wasp: {
version: "^0.11.0"
2022-12-20 13:11:13 +03:00
},
title: "ToDo TypeScript",
auth: {
userEntity: User,
methods: {
usernameAndPassword: {}, // this is a very naive implementation, use 'email' in production instead
//google: {}, //https://wasp-lang.dev/docs/integrations/google
//gitHub: {}, //https://wasp-lang.dev/docs/integrations/github
//email: {} //https://wasp-lang.dev/docs/guides/email-auth
2022-12-20 13:11:13 +03:00
},
onAuthFailedRedirectTo: "/login",
}
}
// Use Prisma Schema Language (PSL) to define our entities: https://www.prisma.io/docs/concepts/components/prisma-schema
// Run `wasp db migrate-dev` in the CLI to create the database tables
// Then run `wasp db studio` to open Prisma Studio and view your db models
entity User {=psl
2022-12-20 13:11:13 +03:00
id Int @id @default(autoincrement())
tasks Task[]
psl=}
entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
user User @relation(fields: [userId], references: [id])
userId Int
2022-12-20 13:11:13 +03:00
psl=}
route RootRoute { path: "/", to: MainPage }
page MainPage {
authRequired: true,
component: import { MainPage } from "@client/MainPage.tsx"
2022-12-20 13:11:13 +03:00
}
route LoginRoute { path: "/login", to: LoginPage }
page LoginPage {
component: import { LoginPage } from "@client/LoginPage.tsx"
2022-12-20 13:11:13 +03:00
}
route SignupRoute { path: "/signup", to: SignupPage }
page SignupPage {
component: import { SignupPage } from "@client/SignupPage.tsx"
2022-12-20 13:11:13 +03:00
}
query getTasks {
// We specify the JS implementation of our query (which is an async JS function)
// Even if you use TS and have a queries.ts file, you will still need to import it using the .js extension.
2022-12-20 13:37:22 +03:00
// see here for more info: https://wasp-lang.dev/docs/tutorials/todo-app/03-listing-tasks#wasp-declaration
2022-12-20 13:11:13 +03:00
fn: import { getTasks } from "@server/queries.js",
// We tell Wasp that this query is doing something with the `Task` entity. With that, Wasp will
// automatically refresh the results of this query when tasks change.
entities: [Task]
}
action createTask {
fn: import { createTask } from "@server/actions.js",
entities: [Task]
}
action updateTask {
fn: import { updateTask } from "@server/actions.js",
entities: [Task]
}
action deleteTasks {
fn: import { deleteTasks } from "@server/actions.js",
entities: [Task],
}