diff --git a/.npmrc b/.npmrc index 9d774d2..e69de29 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +0,0 @@ -public-hoist-pattern[]=* \ No newline at end of file diff --git a/apps/api/app/api/[[...route]]/hello.ts b/apps/api/app/api/[[...route]]/hello.ts deleted file mode 100644 index 9788240..0000000 --- a/apps/api/app/api/[[...route]]/hello.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Hono } from "hono"; -const app = new Hono(); -import { prisma } from "@repo/db"; -app - .get("/", async (c) => { - const user = await prisma.user.findMany(); - return c.json({ - user, - }); - }) - .patch(async (c) => { - const name = await c.req.json(); - const test = await prisma.user.update({ - where: { - id: "123", - }, - data: { - name: name.name, - }, - }); - return c.json({ - test, - }); - }) - .delete(async (c) => { - const test = await prisma.user.delete({ - where: { - id: "2", - }, - }); - return c.json({ - test, - }); - }) - .post(async (c) => { - const body = await c.req.json(); - console.log(body); - const test = await prisma.user.create({ - data: body, - }); - return c.json({ - test, - }); - }); - -export default app; diff --git a/apps/api/app/api/[[...route]]/mail.ts b/apps/api/app/api/[[...route]]/mail.ts deleted file mode 100644 index 1db0248..0000000 --- a/apps/api/app/api/[[...route]]/mail.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Hono } from "hono"; -import { sendBatchEmail, sendEmail } from "@repo/mail"; -import { mailBatchSchema, mailSchema } from "@repo/types"; -import { zValidator } from "@hono/zod-validator"; - -const app = new Hono(); - -app - .post("/send", zValidator("json", mailSchema), async (c) => { - const { email, subject } = c.req.valid("json"); - const { data, error } = await sendEmail(email, subject); - if (error) { - return c.json( - { - message: "Email sent failed", - }, - 400, - ); - } - return c.json( - { - message: "Email sent successfully", - data, - }, - 200, - ); - }) - .get((c) => { - return c.json({ - message: "mail api is alive", - status: 200, - }); - }); - -app - .post("/send-batch", zValidator("json", mailBatchSchema), async (c) => { - const { emails, subject } = c.req.valid("json"); - const { data, error } = await sendBatchEmail(emails, subject); - if (error) { - return c.json( - { - message: "Email sent failed", - }, - 400, - ); - } - return c.json( - { - message: "All Emails sent successfully", - data, - }, - 200, - ); - }) - .get((c) => { - return c.json({ - message: "all mail api is alive", - status: 200, - }); - }); - -export default app; diff --git a/apps/api/app/api/[[...route]]/route.ts b/apps/api/app/api/[[...route]]/route.ts index be4f596..d9ad22f 100644 --- a/apps/api/app/api/[[...route]]/route.ts +++ b/apps/api/app/api/[[...route]]/route.ts @@ -1,70 +1,52 @@ import { prisma } from "@repo/db"; -import { handle } from "hono/vercel"; import { Hono } from "hono"; -import { auth } from "@repo/auth"; -import { cors } from "hono/cors"; -import mail from "./mail"; -import hello from "./hello"; - -const allowedOrigins = [ - "http://localhost:3003", - "https://www.plura.pro", - "http://app.plura.pro", -]; +import { handle } from "hono/vercel"; export const runtime = "nodejs"; -const app = new Hono<{ - Variables: { - user: typeof auth.$Infer.Session.user | null; - session: typeof auth.$Infer.Session.session | null; - }; -}>().basePath("/api"); - -app.use( - "/auth/**", - cors({ - origin: allowedOrigins, - allowHeaders: ["Content-Type", "Authorization"], - allowMethods: ["POST", "GET", "OPTIONS"], - exposeHeaders: ["Content-Length"], - maxAge: 600, - credentials: true, - }), -); -app.options("/auth/**", (c) => { - const origin = c.req.raw.headers.get("origin") ?? ""; +const app = new Hono().basePath("/api"); - if (allowedOrigins.includes(origin)) { - return new Response(null, { - status: 204, - headers: { - "Access-Control-Allow-Origin": origin, - "Access-Control-Allow-Methods": "GET, POST, OPTIONS", - "Access-Control-Allow-Headers": "Content-Type, Authorization", - "Access-Control-Allow-Credentials": "true", - "Access-Control-Max-Age": "600", +app + .get("/hello", async (c) => { + const test = await prisma.user.findMany(); + return c.json({ + test, + }); + }) + .patch(async (c) => { + const name = await c.req.json(); + const test = await prisma.user.update({ + where: { + id: "123", + }, + data: { + name: name.name, }, }); - } - - return new Response("Forbidden", { - status: 403, + return c.json({ + test, + }); + }) + .delete(async (c) => { + const test = await prisma.user.delete({ + where: { + id: "2", + }, + }); + return c.json({ + test, + }); + }) + .post(async (c) => { + const body = await c.req.json(); + console.log(body); + const test = await prisma.user.create({ + data: body, + }); + return c.json({ + test, + }); }); -}); -app.use("*", async (c, next) => { - const session = await auth.api.getSession({ headers: c.req.raw.headers }); - - if (!session) { - c.set("user", null); - c.set("session", null); - return next(); - } - - c.set("user", session.user); - c.set("session", session.session); - return next(); -}); app.get("/health", async (c) => { return c.json({ @@ -72,33 +54,10 @@ app.get("/health", async (c) => { status: 200, }); }); -app.get("/session", async (c) => { - const session = c.get("session"); - const user = c.get("user"); - - if (!user) return c.body(null, 401); - - return c.json({ - session, - user, - }); -}); -app.route("/hello", hello); -app.route("/mail", mail); -app.on(["POST", "GET"], "/auth/**", (c) => { - return auth.handler(c.req.raw); -}); -app.get("/multi-sessions", async (c) => { - const res = await auth.api.listDeviceSessions({ - headers: c.req.raw.headers, - }); - return c.json(res); -}); const GET = handle(app); const POST = handle(app); const PATCH = handle(app); const DELETE = handle(app); -export const OPTIONS = handle(app); export { GET, PATCH, POST, DELETE }; diff --git a/apps/api/package.json b/apps/api/package.json index 50bc7fd..8ef407c 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -13,21 +13,17 @@ "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache" }, "dependencies": { - "@hono/node-server": "^1.13.5", - "@hono/zod-validator": "^0.4.1", - "@repo/auth": "workspace:*", "@repo/db": "workspace:*", + "contentlayer2": "^0.5.3", "hono": "^4.6.9", "next": "15.0.2", "react": "19.0.0-rc-02c0e824-20241028", - "react-dom": "19.0.0-rc-02c0e824-20241028", - "zod": "^3.23.8" + "react-dom": "19.0.0-rc-02c0e824-20241028" }, "devDependencies": { "@types/node": "18.11.18", "@types/react": "18.0.26", "@types/react-dom": "18.0.10", - "dotenv": "^16.4.5", "typescript": "^5" } } \ No newline at end of file diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index 85ea767..f614f33 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -12,8 +12,8 @@ "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, - "module": "ESNext", - "moduleResolution": "Bundler", + "module": "NodeNext", + "moduleResolution": "NodeNext", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", @@ -34,10 +34,8 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".next/types/**/*.ts", - "src/**/*.ts", - "src/**/*.d.ts" -, "../../packages/types/auth.ts" ], + ".next/types/**/*.ts" + ], "exclude": [ "node_modules" ] diff --git a/apps/app/package.json b/apps/app/package.json index cb5d94a..7d1b5ef 100644 --- a/apps/app/package.json +++ b/apps/app/package.json @@ -40,6 +40,7 @@ "next": "15.0.2", "next-themes": "^0.4.3", "react": "19.0.0-rc-02c0e824-20241028", + "react-beautiful-dnd": "^13.1.1", "react-dom": "19.0.0-rc-02c0e824-20241028", "react-hook-form": "^7.53.1", "recharts": "^2.13.3", diff --git a/apps/www/app/(auth)/dashboard/page.tsx b/apps/www/app/(auth)/dashboard/page.tsx deleted file mode 100644 index bb407d0..0000000 --- a/apps/www/app/(auth)/dashboard/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import AccountSwitcher from "@/components/custom/account-switcher"; -import { getMultipleSessions, getSession } from "@/lib/server"; - -export default async function page() { - const session = await getSession(); - const multipleSessions = await getMultipleSessions(); - return ( -
- -
{JSON.stringify(session, null, 1)}
- {/*
{JSON.stringify(multipleSessions,null,2)}
*/} -
- ); -} diff --git a/apps/www/app/(auth)/sign-in/page.tsx b/apps/www/app/(auth)/sign-in/page.tsx deleted file mode 100644 index 45b475f..0000000 --- a/apps/www/app/(auth)/sign-in/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import SignIn from "@/components/custom/Sign-In"; - -export default function page() { - return ( -
- {" "} - -
- ); -} diff --git a/apps/www/app/(auth)/sign-up/page.tsx b/apps/www/app/(auth)/sign-up/page.tsx deleted file mode 100644 index 9354fcb..0000000 --- a/apps/www/app/(auth)/sign-up/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import SignUp from "../../../components/custom/Sign-up"; - -export default function page() { - return ( -
- -
- ); -} diff --git a/apps/www/components/custom/Sign-In.tsx b/apps/www/components/custom/Sign-In.tsx deleted file mode 100644 index 132f323..0000000 --- a/apps/www/components/custom/Sign-In.tsx +++ /dev/null @@ -1,82 +0,0 @@ -"use client"; - -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; - -import { Button } from "@/components/ui/button"; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { authClient } from "@/lib/auth-client"; - -const formSchema = z.object({ - email: z.string().email(), - password: z.string().min(8), -}); - -export default function SignIn() { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - email: "", - password: "", - }, - }); - const onSubmit = async (SignInData: z.infer) => { - const { data, error } = await authClient.signIn.email( - { - email: SignInData.email, - password: SignInData.password, - callbackURL: "/dashboard", - }, - { - onRequest: (ctx) => {}, - onSuccess: (ctx) => {}, - onError: (ctx) => { - alert(ctx.error.message); - }, - }, - ); - }; - - return ( -
- - ( - - email - - - - - - )} - /> - ( - - password - - - - - - )} - /> - - - - ); -} diff --git a/apps/www/components/custom/Sign-up.tsx b/apps/www/components/custom/Sign-up.tsx deleted file mode 100644 index 56729a0..0000000 --- a/apps/www/components/custom/Sign-up.tsx +++ /dev/null @@ -1,97 +0,0 @@ -"use client"; - -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; - -import { Button } from "@/components/ui/button"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { authClient } from "@/lib/auth-client"; - -const formSchema = z.object({ - name: z.string(), - email: z.string().email(), - password: z.string().min(8), -}); - -export default function SignUp() { - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - email: "", - password: "", - }, - }); - const onSubmit = async (SignInData: z.infer) => { - const { data, error } = await authClient.signUp.email( - { - name: SignInData.name, - email: SignInData.email, - password: SignInData.password, - }, - { - onRequest: (ctx) => {}, - onSuccess: (ctx) => {}, - onError: (ctx) => { - alert(ctx.error.message); - }, - }, - ); - }; - - return ( -
- - ( - - name - - - - - - )} - /> - ( - - email - - - - - - )} - /> - ( - - password - - - - - - )} - /> - - - - ); -} diff --git a/apps/www/components/custom/account-switcher.tsx b/apps/www/components/custom/account-switcher.tsx deleted file mode 100644 index be794c9..0000000 --- a/apps/www/components/custom/account-switcher.tsx +++ /dev/null @@ -1,37 +0,0 @@ -"use client"; -import { authClient } from "../../lib/auth-client"; -import { Session } from "@repo/auth"; -import { useRouter } from "next/navigation"; -interface Props { - session: Session[]; - activeSession: Session; -} -export default function AccountSwitcher({ session, activeSession }: Props) { - const router = useRouter(); - const onSelect = async (sessionId: string) => { - console.log(sessionId); - const active = await authClient.multiSession.setActive({ - sessionId: sessionId, - }); - - console.log(active); - router.refresh(); - }; - return ( -
- -
- ); -} diff --git a/apps/www/components/ui/form.tsx b/apps/www/components/ui/form.tsx deleted file mode 100644 index c3daa38..0000000 --- a/apps/www/components/ui/form.tsx +++ /dev/null @@ -1,179 +0,0 @@ -"use client"; - -import * as React from "react"; -import * as LabelPrimitive from "@radix-ui/react-label"; -import { Slot } from "@radix-ui/react-slot"; -import { - Controller, - ControllerProps, - FieldPath, - FieldValues, - FormProvider, - useFormContext, -} from "react-hook-form"; - -import { cn } from "@/lib/utils"; -import { Label } from "@/components/ui/label"; - -const Form = FormProvider; - -type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, -> = { - name: TName; -}; - -const FormFieldContext = React.createContext( - {} as FormFieldContextValue, -); - -const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, ->({ - ...props -}: ControllerProps) => { - return ( - - - - ); -}; - -const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext); - const itemContext = React.useContext(FormItemContext); - const { getFieldState, formState } = useFormContext(); - - const fieldState = getFieldState(fieldContext.name, formState); - - if (!fieldContext) { - throw new Error("useFormField should be used within "); - } - - const { id } = itemContext; - - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - }; -}; - -type FormItemContextValue = { - id: string; -}; - -const FormItemContext = React.createContext( - {} as FormItemContextValue, -); - -const FormItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { - const id = React.useId(); - - return ( - -
- - ); -}); -FormItem.displayName = "FormItem"; - -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField(); - - return ( -