diff --git a/README.md b/README.md index e40dc39..b4948c5 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,24 @@ After cloning this repo, you can run it locally by following these steps: 1. Install [Wasp](https://wasp-lang.dev) by running `curl -sSL https://get.wasp-lang.dev/installer.sh | sh` in your terminal. 2. Create a `.env.server` file in the root of the project 3. Copy the `env.example` file contents to `.env.server` and fill in your API keys -4. Run `wasp db migrate-dev` -5. Run `wasp start` -6. Go to `localhost:3000` in your browser (your NodeJS server will be running on port `3001`) -7. Install the Wasp extension for VSCode to get syntax highlighting on the `main.wasp` file and other features -8. Check the files for comments containing specific instructions -9. Enjoy and Have fun. When you create an App with this template, be kind and let me know by tagging me on twitter [@hot_town](https://twitter.com/hot_town) +4. Make sure you have a Database connected and running. Here are two quick options: + - Provision a Postgres database on [Railway](https://railway.app), go to settings and copy the `connection url`. Past it as `DATABASE_URL=` into your `env.server` file. + - or you can spin up a Postgres docker container with this command: + ```shell + docker run \ + --rm \ + --publish 5432:5432 \ + -v my-app-data:/var/lib/postgresql/data \ + --env POSTGRES_PASSWORD=devpass1234 \ + postgres + ``` + and then paste `DATABASE_URL=postgresql://postgres:devpass1234@localhost:5432/postgres` into your `env.server` file +5. Run `wasp db migrate-dev` +6. Run `wasp start` +7. Go to `localhost:3000` in your browser (your NodeJS server will be running on port `3001`) +8. Install the Wasp extension for VSCode to get the best DX +9. Check the files for comments containing specific instructions +10. Enjoy and Have fun. When you create an App with this template, be kind and let me know by tagging me on twitter [@hot_town](https://twitter.com/hot_town) ## How it works diff --git a/main.wasp b/main.wasp index 4cdbb5a..f14c313 100644 --- a/main.wasp +++ b/main.wasp @@ -102,7 +102,6 @@ page LoginPage { route GptRoute { path: "/gpt", to: GptPage } page GptPage { - authRequired: true, component: import GptPage from "@client/GptPage" } diff --git a/src/client/AccountPage.tsx b/src/client/AccountPage.tsx index a49b00c..4fa705e 100644 --- a/src/client/AccountPage.tsx +++ b/src/client/AccountPage.tsx @@ -48,7 +48,7 @@ export default function Example({ user }: { user: User }) {
Most Recent User RelatedObject
- {!!relatedObjects + {!!relatedObjects && relatedObjects.length > 0 ? relatedObjects[relatedObjects.length - 1].content : "You don't have any at this time."}
diff --git a/src/client/GptPage.tsx b/src/client/GptPage.tsx index 6dbe92a..fc9e107 100644 --- a/src/client/GptPage.tsx +++ b/src/client/GptPage.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { RelatedObject } from '@wasp/entities'; import generateGptResponse from '@wasp/actions/generateGptResponse'; +import useAuth from '@wasp/auth/useAuth'; type GptPayload = { instructions: string; @@ -13,7 +14,14 @@ export default function GptPage() { const [temperature, setTemperature] = useState(1); const [response, setResponse] = useState(''); + const { data: user } = useAuth(); + const onSubmit = async ({ instructions, command, temperature }: any) => { + console.log('user, ', !!user) + if (!user) { + alert('You must be logged in to use this feature.'); + return; + } try { const response = (await generateGptResponse({ instructions, command, temperature })) as RelatedObject; if (response) { @@ -56,6 +64,7 @@ export default function GptPage() { })} />
+ {formErrors.instructions && formErrors.instructions.message}
+ {formErrors.command && formErrors.command.message}
diff --git a/src/client/MainPage.tsx b/src/client/MainPage.tsx index 38ca745..67cc9d7 100644 --- a/src/client/MainPage.tsx +++ b/src/client/MainPage.tsx @@ -6,11 +6,14 @@ export default function MainPage() {

SaaS Template

- -

- by Wasp   {'= }'} -

-
+ +

+ for the PERN stack +

+

+ Postgres/Prisma, Express, React, Node +

+

Hey 🧙‍♂️! This template will help you get a SaaS App up and running in no time. It's got:

@@ -21,20 +24,24 @@ export default function MainPage() {
  • Managed Server-Side Routes
  • Tailwind styling
  • Client-side Caching
  • -
  • One-command Deploy 🚀
  • +
  • + One-command{' '} + + Deploy 🚀 + +
  • - Make sure to check out the README.md file before you begin + Make sure to check out the README.md file and add your env variables before + you begin

    + Made with Wasp   {' = }'} - Documentation - - - View on GitHub + Read the Wasp Docs
    diff --git a/src/client/NavBar.tsx b/src/client/NavBar.tsx index c642a26..38a01b5 100644 --- a/src/client/NavBar.tsx +++ b/src/client/NavBar.tsx @@ -6,13 +6,11 @@ import useAuth from '@wasp/auth/useAuth'; const active = 'inline-flex items-center border-b-2 border-indigo-300 px-1 pt-1 text-sm font-medium text-gray-900'; const inactive = 'inline-flex items-center border-b-2 border-transparent px-1 pt-1 text-sm font-medium text-gray-500 hover:border-gray-300 hover:text-gray-700' - const current = window.location.pathname; + export default function NavBar() { const { data: user } = useAuth(); - console.log(current); - return ( {({ open }) => ( @@ -21,7 +19,7 @@ export default function NavBar() {
    diff --git a/src/client/static/gptsaastemplate.png b/src/client/static/gptsaastemplate.png index b63f021..8d7cdc9 100644 Binary files a/src/client/static/gptsaastemplate.png and b/src/client/static/gptsaastemplate.png differ diff --git a/src/server/utils.ts b/src/server/utils.ts deleted file mode 100644 index e69de29..0000000