From 17e26fc87fe742d5f3df2447fefa9fad2d1e066c Mon Sep 17 00:00:00 2001 From: jamesratcliffe101 Date: Fri, 3 Apr 2026 18:25:54 +0100 Subject: [PATCH] initial commit --- README.md | 36 + app/api/uploadthing/core.ts | 41 + app/api/uploadthing/route.ts | 11 + app/create_post/layout.tsx | 5 + app/create_post/page.tsx | 57 + app/favicon.ico | Bin 0 -> 25931 bytes app/globals.css | 56 + app/layout.tsx | 69 + app/login/page.tsx | 3 + app/manage_pet_account/page.tsx | 6 + app/menu.tsx | 22 + app/page.tsx | 19 + app/post.tsx | 19 + app/settings/layout.tsx | 9 + app/settings/page.tsx | 22 + biome.json | 39 + docker-compose.yml | 15 + lib/prisma.ts | 19 + lib/uploadthing.ts | 9 + middleware.ts | 24 + next.config.ts | 7 + package-lock.json | 3967 +++++++++++++++++ package.json | 36 + postcss.config.mjs | 7 + prisma.config.ts | 15 + .../20260211171220_init/migration.sql | 23 + prisma/migrations/migration_lock.toml | 3 + prisma/schema.prisma | 43 + prisma/seed.ts | 95 + public/file.svg | 1 + public/globe.svg | 1 + public/next.svg | 1 + public/vercel.svg | 1 + public/window.svg | 1 + tsconfig.json | 34 + 35 files changed, 4716 insertions(+) create mode 100644 README.md create mode 100644 app/api/uploadthing/core.ts create mode 100644 app/api/uploadthing/route.ts create mode 100644 app/create_post/layout.tsx create mode 100644 app/create_post/page.tsx create mode 100644 app/favicon.ico create mode 100644 app/globals.css create mode 100644 app/layout.tsx create mode 100644 app/login/page.tsx create mode 100644 app/manage_pet_account/page.tsx create mode 100644 app/menu.tsx create mode 100644 app/page.tsx create mode 100644 app/post.tsx create mode 100644 app/settings/layout.tsx create mode 100644 app/settings/page.tsx create mode 100644 biome.json create mode 100644 docker-compose.yml create mode 100644 lib/prisma.ts create mode 100644 lib/uploadthing.ts create mode 100644 middleware.ts create mode 100644 next.config.ts create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 postcss.config.mjs create mode 100644 prisma.config.ts create mode 100644 prisma/migrations/20260211171220_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml create mode 100644 prisma/schema.prisma create mode 100644 prisma/seed.ts create mode 100644 public/file.svg create mode 100644 public/globe.svg create mode 100644 public/next.svg create mode 100644 public/vercel.svg create mode 100644 public/window.svg create mode 100644 tsconfig.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..e215bc4 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +# or +pnpm dev +# or +bun dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. + +This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/app/api/uploadthing/core.ts b/app/api/uploadthing/core.ts new file mode 100644 index 0000000..00d5383 --- /dev/null +++ b/app/api/uploadthing/core.ts @@ -0,0 +1,41 @@ +import { clerkClient, auth } from "@clerk/nextjs/server"; +import { createUploadthing, type FileRouter } from "uploadthing/next"; +import { UploadThingError } from "uploadthing/server"; +const f = createUploadthing(); + +// FileRouter for your app, can contain multiple FileRoutes +export const ourFileRouter = { + // Define as many FileRoutes as you like, each with a unique routeSlug + imageUploader: f({ + image: { + /** + * For full list of options and defaults, see the File Route API reference + * @see https://docs.uploadthing.com/file-routes#route-config + */ + maxFileSize: "4MB", + maxFileCount: 1, + }, + }) + // Set permissions and file types for this FileRoute + .middleware(async () => { + // This code runs on your server before upload + const user = await auth(); + + // If you throw, the user will not be able to upload + if (!user) throw new UploadThingError("Unauthorized"); + + // Whatever is returned here is accessible in onUploadComplete as `metadata` + return { userId: user.userId }; + }) + .onUploadComplete(async ({ metadata, file }) => { + // This code RUNS ON YOUR SERVER after upload + console.log("Upload complete for userId:", metadata.userId); + + console.log("file url", file.ufsUrl); + + // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback + return { uploadedBy: metadata.userId }; + }), +} satisfies FileRouter; + +export type OurFileRouter = typeof ourFileRouter; diff --git a/app/api/uploadthing/route.ts b/app/api/uploadthing/route.ts new file mode 100644 index 0000000..f659c0e --- /dev/null +++ b/app/api/uploadthing/route.ts @@ -0,0 +1,11 @@ +import { createRouteHandler } from "uploadthing/next"; + +import { ourFileRouter } from "./core"; + +// Export routes for Next App Router +export const { GET, POST } = createRouteHandler({ + router: ourFileRouter, + + // Apply an (optional) custom config: + // config: { ... }, +}); \ No newline at end of file diff --git a/app/create_post/layout.tsx b/app/create_post/layout.tsx new file mode 100644 index 0000000..ba7fcbc --- /dev/null +++ b/app/create_post/layout.tsx @@ -0,0 +1,5 @@ +export default function layout({ children }: { children: React.ReactNode}){ + return <> + {children} + +} \ No newline at end of file diff --git a/app/create_post/page.tsx b/app/create_post/page.tsx new file mode 100644 index 0000000..e7e3f02 --- /dev/null +++ b/app/create_post/page.tsx @@ -0,0 +1,57 @@ +import Form from 'next/form' +import { auth } from '@clerk/nextjs/server'; +import { prisma } from "@/lib/prisma"; +import { revalidatePath } from "next/cache"; +import { redirect } from "next/navigation"; + +export default async function Page() { + async function createPost(formData: FormData) { + "use server"; + + const { userId } = await auth(); // + if (!userId) { + throw new Error("You must be logged in to post!"); + } + + const first_name = formData.get("fname") as string; + const last_name = formData.get("lname") as string; + const post_text = formData.get("post-text") as string; + const pet_species = formData.get("pet_species") as string; + + console.log(first_name, last_name, post_text, pet_species); + + await prisma.post.create({ + data: { + content: post_text, + petId: 3, + }, + }); + + revalidatePath("/"); + redirect("/"); + } + + return <> +

This is create post content

+
+
+
+
+
+
+