qarpeo 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.mjs
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("nuxt/server").EventHandler<Promise<Response>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
1
|
+
import { defineEventHandler, getRequestURL, getRequestHeaders, readBody } from "nuxt/server";
|
|
2
2
|
import { serverAuth } from "../../utils/auth.mjs";
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
const auth = serverAuth(event);
|
|
5
|
-
const req = event.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const req = event.web?.request || event.req;
|
|
6
|
+
if (req instanceof Request) {
|
|
7
|
+
return auth.handler(req);
|
|
8
|
+
}
|
|
9
|
+
const url = getRequestURL(event);
|
|
10
|
+
const headers = getRequestHeaders(event);
|
|
11
|
+
const method = event.method || "GET";
|
|
12
|
+
const body = ["POST", "PUT", "PATCH"].includes(method) ? await readBody(event).catch(() => void 0) : void 0;
|
|
13
|
+
const request = new Request(url.toString(), {
|
|
14
|
+
method,
|
|
15
|
+
headers,
|
|
16
|
+
body: body ? typeof body === "string" ? body : JSON.stringify(body) : void 0
|
|
9
17
|
});
|
|
10
|
-
return auth.handler(
|
|
18
|
+
return auth.handler(request);
|
|
11
19
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { betterAuth } from "better-auth";
|
|
2
2
|
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
|
|
3
|
-
import { createError } from "
|
|
3
|
+
import { createError } from "nuxt/server";
|
|
4
4
|
import { useDrizzle } from "./drizzle.mjs";
|
|
5
5
|
import * as authSchema from "#qarpeo/auth/schema";
|
|
6
6
|
export function serverAuth(event) {
|