Login
9 | {/** Wasp has built-in auth forms & flows, which you can also opt-out of, if you wish :) */} 10 |12 | 13 | I don't have an account yet (go to signup). 14 | 15 |
├── .gitpod.Dockerfile
├── .gitpod.yml
├── .vscode
├── settings.json
└── wasp-0.1.0.vsix
├── LICENSE
├── MyNewApp
├── .gitignore
├── .waspignore
├── .wasproot
├── main.wasp
├── migrations
│ ├── 20221214130100_init
│ │ └── migration.sql
│ └── migration_lock.toml
└── src
│ ├── client
│ ├── LoginPage.jsx
│ ├── Main.css
│ ├── MainPage.jsx
│ ├── SignupPage.jsx
│ └── waspLogo.png
│ ├── server
│ ├── actions.js
│ └── queries.js
│ └── shared
│ └── .gitkeep
└── README.md
/.gitpod.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:jammy
2 |
3 | RUN apt-get update && apt-get install -yq \
4 | git \
5 | git-lfs \
6 | sudo \
7 | curl
8 |
9 | # Gitpod expects us to have gitpod user with UID 333333, so let's create one.
10 | RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod
11 |
12 | # Set up node (specifically version that Wasp requires).
13 | USER gitpod
14 | ENV NODE_VERSION=18.12.0
15 | RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
16 | ENV NVM_DIR=/home/gitpod/.nvm
17 | RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
18 | && nvm use v${NODE_VERSION} \
19 | && nvm alias default v${NODE_VERSION}
20 | ENV PATH="/home/gitpod/.nvm/versions/node/v${NODE_VERSION}/bin:${PATH}"
21 |
22 | RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s
23 | # Wasp gets installed in $HOME/.local/bin, so we need to add it to PATH.
24 | ENV PATH="/home/gitpod/.local/bin:${PATH}"
25 | # Ensure Wasp's telemetry recognizes Wasp is running on Gitpod.
26 | RUN printf 'export WASP_TELEMETRY_CONTEXT=gitpod\n' >> $HOME/.bashrc \
27 | && printf 'export WASP_TELEMETRY_USER_ID="%s"\n' "$GITPOD_WORKSPACE_ID" >> $HOME/.bashrc
28 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: .gitpod.Dockerfile
3 |
4 | # Learn more about this file at https://www.gitpod.io/docs/references/gitpod-yml
5 | # We grab the dynamically created GITPOD_WORKSPACE_URL, add ports 3000/1, and create
6 | # the .env files necessary for Wasp Routing and CORS
7 | tasks:
8 | - command: |
9 | echo "REACT_APP_API_URL=$(printenv | grep "^GITPOD_WORKSPACE_URL=" | cut -d "=" -f 2 | awk '{gsub("https://","https://3001-")} 1')" >> MyNewApp/.env.client
10 | echo "WASP_WEB_CLIENT_URL=$(printenv | grep "^GITPOD_WORKSPACE_URL=" | cut -d "=" -f 2 | awk '{gsub("https://","https://3000-")} 1')" >> MyNewApp/.env.server
11 | cd MyNewApp
12 | wasp db migrate-dev
13 | wasp start
14 |
15 | ports:
16 | - port: 3000
17 | description: Web app
18 | onOpen: open-preview
19 | - port: 3001
20 | visibility: public
21 | description: Node.js server
22 | onOpen: ignore
23 |
24 | vscode:
25 | extensions:
26 | - wasp-lang.wasp
27 | - prisma.prisma
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*.wasp": "wasp",
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.vscode/wasp-0.1.0.vsix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wasp-lang/gitpod-template/b374c80fe4eb24318ec91c03d0a61be1c6bafdf7/.vscode/wasp-0.1.0.vsix
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Gitpod
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MyNewApp/.gitignore:
--------------------------------------------------------------------------------
1 | /.wasp/
2 | /.env
3 |
--------------------------------------------------------------------------------
/MyNewApp/.waspignore:
--------------------------------------------------------------------------------
1 | # Ignore editor tmp files
2 | **/*~
3 | **/#*#
4 |
--------------------------------------------------------------------------------
/MyNewApp/.wasproot:
--------------------------------------------------------------------------------
1 | File marking the root of Wasp project.
--------------------------------------------------------------------------------
/MyNewApp/main.wasp:
--------------------------------------------------------------------------------
1 | app MyNewApp {
2 |
3 | wasp: {
4 | version: "^0.11.7"
5 | },
6 |
7 | title: "MyNewApp",
8 |
9 | auth: {
10 | userEntity: User,
11 | methods: {
12 | // we also support Google OAuth2, with GitHub and more coming soon!
13 | usernameAndPassword: {},
14 | },
15 | onAuthFailedRedirectTo: "/login",
16 | }
17 | }
18 |
19 | // Use Prisma Schema Language (PSL) to define our entities: https://www.prisma.io/docs/concepts/components/prisma-schema
20 | // Run `wasp db migrate-dev` in the CLI to create the database tables
21 | // Then run `wasp db studio` to open Prisma Studio and view your db models
22 | entity User {=psl
23 | id Int @id @default(autoincrement())
24 | username String @unique
25 | password String
26 | tasks Task[]
27 | psl=}
28 |
29 | entity Task {=psl
30 | id Int @id @default(autoincrement())
31 | description String
32 | isDone Boolean @default(false)
33 | user User? @relation(fields: [userId], references: [id])
34 | userId Int?
35 | psl=}
36 |
37 | route RootRoute { path: "/", to: MainPage }
38 | page MainPage {
39 | authRequired: true, // This page requires user to be authenticated.
40 | component: import Main from "@client/MainPage.jsx"
41 | }
42 |
43 | route LoginRoute { path: "/login", to: LoginPage }
44 | page LoginPage {
45 | component: import Login from "@client/LoginPage.jsx"
46 | }
47 |
48 | route SignupRoute { path: "/signup", to: SignupPage }
49 | page SignupPage {
50 | component: import Signup from "@client/SignupPage.jsx"
51 | }
52 |
53 | query getTasks {
54 | // We specify the JS implementation of our query (which is an async JS function)
55 | // which can be found in `server/queries.js` as a named export `getTasks`.
56 | fn: import { getTasks } from "@server/queries.js",
57 | // We tell Wasp that this query is doing something with the `Task` entity. With that, Wasp will
58 | // automatically refresh the results of this query when tasks change.
59 | entities: [Task]
60 | }
61 |
62 | action createTask {
63 | fn: import { createTask } from "@server/actions.js",
64 | entities: [Task]
65 | }
66 |
67 | action updateTask {
68 | fn: import { updateTask } from "@server/actions.js",
69 | entities: [Task]
70 | }
--------------------------------------------------------------------------------
/MyNewApp/migrations/20221214130100_init/migration.sql:
--------------------------------------------------------------------------------
1 | -- CreateTable
2 | CREATE TABLE "User" (
3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4 | "username" TEXT NOT NULL,
5 | "password" TEXT NOT NULL
6 | );
7 |
8 | -- CreateTable
9 | CREATE TABLE "Task" (
10 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
11 | "description" TEXT NOT NULL,
12 | "isDone" BOOLEAN NOT NULL DEFAULT false,
13 | "userId" INTEGER,
14 | CONSTRAINT "Task_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
15 | );
16 |
17 | -- CreateIndex
18 | CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
19 |
--------------------------------------------------------------------------------
/MyNewApp/migrations/migration_lock.toml:
--------------------------------------------------------------------------------
1 | # Please do not edit this file manually
2 | # It should be added in your version-control system (i.e. Git)
3 | provider = "sqlite"
--------------------------------------------------------------------------------
/MyNewApp/src/client/LoginPage.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Link } from 'react-router-dom';
3 | import { LoginForm } from "@wasp/auth/forms/Login";
4 |
5 | const LoginPage = () => {
6 | return (
7 | Login
9 | {/** Wasp has built-in auth forms & flows, which you can also opt-out of, if you wish :) */}
10 |
12 |
13 | I don't have an account yet (go to signup).
14 |
15 |
25 |
26 | {user.username}
27 | {`'s tasks :)`}
28 |
29 |