From b789cb0155529171adce00c4c8903d6ab0a43c2b Mon Sep 17 00:00:00 2001 From: Divyanshgupta030 <145568562+Divyanshgupta030@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:08:45 +0530 Subject: [PATCH 1/4] add edge to api --- apps/api/app/api/[[...route]]/route.ts | 2 +- packages/database/package.json | 5 +++-- packages/database/prisma/schema.prisma | 1 + packages/database/src/index.ts | 17 +++++++++----- pnpm-lock.yaml | 31 ++++++++++++++++++-------- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/apps/api/app/api/[[...route]]/route.ts b/apps/api/app/api/[[...route]]/route.ts index c5cd4d2..230ee39 100644 --- a/apps/api/app/api/[[...route]]/route.ts +++ b/apps/api/app/api/[[...route]]/route.ts @@ -11,7 +11,7 @@ const allowedOrigins = [ "https://app.plura.pro", ]; -export const runtime = "nodejs"; +export const runtime = "edge"; const app = new Hono<{ Variables: { diff --git a/packages/database/package.json b/packages/database/package.json index 10f8952..8fafd69 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -5,12 +5,13 @@ "exports": { ".": "./src/index.ts" }, - "scripts": { + "scripts": { "db:generate": "prisma generate", "db:push": "prisma db push --skip-generate" }, "dependencies": { - "@prisma/client": "^5.22.0" + "@prisma/client": "^5.22.0", + "@prisma/extension-accelerate": "^1.2.1" }, "devDependencies": { "prisma": "^5.22.0" diff --git a/packages/database/prisma/schema.prisma b/packages/database/prisma/schema.prisma index 897d4f9..b0ff338 100644 --- a/packages/database/prisma/schema.prisma +++ b/packages/database/prisma/schema.prisma @@ -6,6 +6,7 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") + directUrl = env("DIRECT_DATABASE_URL") } model User { diff --git a/packages/database/src/index.ts b/packages/database/src/index.ts index 481d7a9..78a7d85 100644 --- a/packages/database/src/index.ts +++ b/packages/database/src/index.ts @@ -1,11 +1,16 @@ -import { PrismaClient } from "@prisma/client"; +import { PrismaClient } from "@prisma/client/edge"; +import { withAccelerate } from "@prisma/extension-accelerate"; -declare global { - var prisma: PrismaClient | undefined; -} +const prismaClientSingleton = () => { + return new PrismaClient().$extends(withAccelerate()); +}; -export const prisma = global.prisma || new PrismaClient(); +declare const globalThis: { + prismaGlobal: ReturnType; +} & typeof global; -if (process.env.NODE_ENV !== "production") global.prisma = prisma; +export const prisma = globalThis.prismaGlobal ?? prismaClientSingleton(); + +if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma; export * from "@prisma/client"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bdfb564..0ab51d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -457,6 +457,9 @@ importers: '@prisma/client': specifier: ^5.22.0 version: 5.22.0(prisma@5.22.0) + '@prisma/extension-accelerate': + specifier: ^1.2.1 + version: 1.2.1(@prisma/client@5.22.0(prisma@5.22.0)) devDependencies: prisma: specifier: ^5.22.0 @@ -1862,6 +1865,12 @@ packages: '@prisma/engines@5.22.0': resolution: {integrity: sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==} + '@prisma/extension-accelerate@1.2.1': + resolution: {integrity: sha512-QicnMeyqL226ilT3vvRsFAqPeIdqHGKR4c25CoK5zZ1tNIv8egfgpD1gCKqOGmfAz0pIKQnMuJU3eNg9KItC7A==} + engines: {node: '>=16'} + peerDependencies: + '@prisma/client': '>=4.16.1' + '@prisma/fetch-engine@5.22.0': resolution: {integrity: sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==} @@ -8264,6 +8273,10 @@ snapshots: '@prisma/fetch-engine': 5.22.0 '@prisma/get-platform': 5.22.0 + '@prisma/extension-accelerate@1.2.1(@prisma/client@5.22.0(prisma@5.22.0))': + dependencies: + '@prisma/client': 5.22.0(prisma@5.22.0) + '@prisma/fetch-engine@5.22.0': dependencies: '@prisma/debug': 5.22.0 @@ -10819,8 +10832,8 @@ snapshots: '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1) eslint-plugin-react: 7.37.2(eslint@8.57.1) eslint-plugin-react-hooks: 5.0.0(eslint@8.57.1) @@ -10871,19 +10884,19 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1): + eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 is-glob: 4.0.3 optionalDependencies: - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1) transitivePeerDependencies: - '@typescript-eslint/parser' - eslint-import-resolver-node @@ -10910,14 +10923,14 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): + eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): dependencies: debug: 3.2.7 optionalDependencies: '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1) transitivePeerDependencies: - supports-color @@ -10956,7 +10969,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): + eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 @@ -10967,7 +10980,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 From 833de7a4966578957332bcdb2453e276a9440cff Mon Sep 17 00:00:00 2001 From: Divyanshgupta030 <145568562+Divyanshgupta030@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:26:13 +0530 Subject: [PATCH 2/4] fix lockfile --- pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 819485b..21d6f3f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11264,13 +11264,13 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1): + eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.3.7 enhanced-resolve: 5.17.1 eslint: 8.57.1 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) fast-glob: 3.3.2 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 @@ -11303,14 +11303,14 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): + eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): dependencies: debug: 3.2.7 optionalDependencies: '@typescript-eslint/parser': 7.18.0(eslint@8.57.1)(typescript@5.6.3) eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@8.57.1) + eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - supports-color @@ -11360,7 +11360,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 From 012bb029f18884ec7d848649cd7a3386f3262a85 Mon Sep 17 00:00:00 2001 From: Divyanshgupta030 <145568562+Divyanshgupta030@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:02:38 +0530 Subject: [PATCH 3/4] refactor api --- apps/api/app/api/[[...route]]/auth.ts | 11 ++++++++ apps/api/app/api/[[...route]]/route.ts | 34 +++++++----------------- apps/api/app/api/[[...route]]/session.ts | 22 +++++++++++++++ apps/www/app/auth/page.tsx | 26 +++++++++--------- packages/auth/package.json | 2 +- pnpm-lock.yaml | 18 ++++++------- 6 files changed, 66 insertions(+), 47 deletions(-) create mode 100644 apps/api/app/api/[[...route]]/auth.ts create mode 100644 apps/api/app/api/[[...route]]/session.ts diff --git a/apps/api/app/api/[[...route]]/auth.ts b/apps/api/app/api/[[...route]]/auth.ts new file mode 100644 index 0000000..d40bdf7 --- /dev/null +++ b/apps/api/app/api/[[...route]]/auth.ts @@ -0,0 +1,11 @@ +import { auth } from "@repo/auth"; +import { Hono } from "hono"; + +const app = new Hono(); + + +app.on(["POST", "GET"], "/**", (c) => { + return auth.handler(c.req.raw); +}); + +export default app \ No newline at end of file diff --git a/apps/api/app/api/[[...route]]/route.ts b/apps/api/app/api/[[...route]]/route.ts index 230ee39..df54523 100644 --- a/apps/api/app/api/[[...route]]/route.ts +++ b/apps/api/app/api/[[...route]]/route.ts @@ -1,9 +1,11 @@ import { handle } from "hono/vercel"; import { Hono } from "hono"; -import { auth } from "@repo/auth"; +import { auth as Auth } from "@repo/auth"; import { cors } from "hono/cors"; import mail from "./mail"; import hello from "./hello"; +import session from "./session"; +import auth from "./auth"; const allowedOrigins = [ "http://localhost:3003", @@ -13,10 +15,10 @@ const allowedOrigins = [ export const runtime = "edge"; -const app = new Hono<{ + const app = new Hono<{ Variables: { - user: typeof auth.$Infer.Session.user | null; - session: typeof auth.$Infer.Session.session | null; + user: typeof Auth.$Infer.Session.user | null; + session: typeof Auth.$Infer.Session.session | null; }; }>().basePath("/api"); @@ -32,7 +34,7 @@ app.use( }), ); app.use("*", async (c, next) => { - const session = await auth.api.getSession({ headers: c.req.raw.headers }); + const session = await Auth.api.getSession({ headers: c.req.raw.headers }); if (!session) { c.set("user", null); @@ -52,29 +54,12 @@ app.get("/health", async (c) => { }); }); -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("/session", session); app.route("/hello", hello); app.route("/mail", mail); +app.route("/auth", auth); -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); @@ -83,3 +68,4 @@ const DELETE = handle(app); const OPTIONS = handle(app); export { GET, PATCH, POST, DELETE, OPTIONS }; + diff --git a/apps/api/app/api/[[...route]]/session.ts b/apps/api/app/api/[[...route]]/session.ts new file mode 100644 index 0000000..1645e83 --- /dev/null +++ b/apps/api/app/api/[[...route]]/session.ts @@ -0,0 +1,22 @@ +import { Hono } from "hono"; +import { auth } from "@repo/auth"; +const app = new Hono() +app.get("/", async (c) => { + const session = await auth.api.getSession({ headers: c.req.raw.headers }); + + if (!session) return c.json({ message: "no session found" }, 401); + + return c.json({ + session, + }); +}); + +app.get("/all", async (c) => { + const res = await auth.api.listDeviceSessions({ + headers: c.req.raw.headers, + }); + return c.json(res); +}); + + +export default app; diff --git a/apps/www/app/auth/page.tsx b/apps/www/app/auth/page.tsx index 0099fe9..87223e7 100644 --- a/apps/www/app/auth/page.tsx +++ b/apps/www/app/auth/page.tsx @@ -287,21 +287,21 @@ export default function Auth() { +
+ + + +
-
- - - -
diff --git a/packages/auth/package.json b/packages/auth/package.json index b36af5a..38aa855 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -12,7 +12,7 @@ "dependencies": { "@repo/typescript-config": "workspace:*", "@repo/db": "workspace:*", - "better-auth": "0.8.5-beta.2", + "better-auth": "0.8.6-beta.3", "better-call": "0.2.14-beta.3", "oslo": "^1.2.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 21d6f3f..5512a0e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -507,8 +507,8 @@ importers: specifier: workspace:* version: link:../typescript-config better-auth: - specifier: 0.8.5-beta.2 - version: 0.8.5-beta.2 + specifier: 0.8.6-beta.3 + version: 0.8.6-beta.3 better-call: specifier: 0.2.14-beta.3 version: 0.2.14-beta.3 @@ -3550,8 +3550,8 @@ packages: better-auth@0.8.1-beta.1: resolution: {integrity: sha512-IFBOPOoRooZoJ883UTA5AjpEiTcFCQNecKj5LJytYTv1E+g/F1AibwGMp7jLq2DJJSfuBdtcCn32Fc0qHroSZQ==} - better-auth@0.8.5-beta.2: - resolution: {integrity: sha512-KsyiRmibj15en4wo1tnLe1LbMka6OmGpSPrxjVJSWlcfHI34VmuVuN7CpmcOf5HFeWxGLkUK3ijQj0yhSc6m3Q==} + better-auth@0.8.6-beta.3: + resolution: {integrity: sha512-9V8JB0Sg+Xv/st/zRqyZfXRnc05Ic+7K1v5inlg3KKNuajBUVWsBjAKzBlqhU57qP1EYOIBxMjZ/6JriWvqawQ==} better-call@0.2.14-beta.3: resolution: {integrity: sha512-lA54ETanzM0xUZnQt6lm3BdTr4gVDyAe1DNpCQSTYUnwnGGOmQG8ob0FYivVd0XHsHQK68r01GB5c6cUuu4llQ==} @@ -10398,7 +10398,7 @@ snapshots: transitivePeerDependencies: - encoding - better-auth@0.8.5-beta.2: + better-auth@0.8.6-beta.3: dependencies: '@better-fetch/fetch': 1.1.12 '@noble/ciphers': 0.6.0 @@ -11193,7 +11193,7 @@ snapshots: eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1) eslint-plugin-react: 7.37.2(eslint@8.57.1) eslint-plugin-react-hooks: 5.0.0(eslint@8.57.1) @@ -11213,7 +11213,7 @@ snapshots: eslint: 8.57.1 eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1) eslint-plugin-react: 7.37.2(eslint@8.57.1) eslint-plugin-react-hooks: 5.0.0(eslint@8.57.1) @@ -11276,7 +11276,7 @@ snapshots: is-bun-module: 1.2.1 is-glob: 4.0.3 optionalDependencies: - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1) + eslint-plugin-import: 2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1) transitivePeerDependencies: - '@typescript-eslint/parser' - eslint-import-resolver-node @@ -11349,7 +11349,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1): + eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 From fc0537d8736c6d13f25f64f62466ed1d88ca09b9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 16 Nov 2024 18:33:22 +0000 Subject: [PATCH 4/4] chore: format code with Prettier --- apps/api/app/api/[[...route]]/auth.ts | 3 +-- apps/api/app/api/[[...route]]/route.ts | 5 +---- apps/api/app/api/[[...route]]/session.ts | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/api/app/api/[[...route]]/auth.ts b/apps/api/app/api/[[...route]]/auth.ts index d40bdf7..b1f1886 100644 --- a/apps/api/app/api/[[...route]]/auth.ts +++ b/apps/api/app/api/[[...route]]/auth.ts @@ -3,9 +3,8 @@ import { Hono } from "hono"; const app = new Hono(); - app.on(["POST", "GET"], "/**", (c) => { return auth.handler(c.req.raw); }); -export default app \ No newline at end of file +export default app; diff --git a/apps/api/app/api/[[...route]]/route.ts b/apps/api/app/api/[[...route]]/route.ts index df54523..483b2ab 100644 --- a/apps/api/app/api/[[...route]]/route.ts +++ b/apps/api/app/api/[[...route]]/route.ts @@ -15,7 +15,7 @@ const allowedOrigins = [ export const runtime = "edge"; - const app = new Hono<{ +const app = new Hono<{ Variables: { user: typeof Auth.$Infer.Session.user | null; session: typeof Auth.$Infer.Session.session | null; @@ -54,13 +54,11 @@ app.get("/health", async (c) => { }); }); - app.route("/session", session); app.route("/hello", hello); app.route("/mail", mail); app.route("/auth", auth); - const GET = handle(app); const POST = handle(app); const PATCH = handle(app); @@ -68,4 +66,3 @@ const DELETE = handle(app); const OPTIONS = handle(app); export { GET, PATCH, POST, DELETE, OPTIONS }; - diff --git a/apps/api/app/api/[[...route]]/session.ts b/apps/api/app/api/[[...route]]/session.ts index 1645e83..f478e1e 100644 --- a/apps/api/app/api/[[...route]]/session.ts +++ b/apps/api/app/api/[[...route]]/session.ts @@ -1,8 +1,8 @@ import { Hono } from "hono"; import { auth } from "@repo/auth"; -const app = new Hono() +const app = new Hono(); app.get("/", async (c) => { - const session = await auth.api.getSession({ headers: c.req.raw.headers }); + const session = await auth.api.getSession({ headers: c.req.raw.headers }); if (!session) return c.json({ message: "no session found" }, 401); @@ -18,5 +18,4 @@ app.get("/all", async (c) => { return c.json(res); }); - export default app;