refactor(auth): update auth client to use new auth structure and improve type inference

This commit is contained in:
Mauricio Siu
2025-12-07 04:28:35 -06:00
parent 77aff700fd
commit daa54cea8d
2 changed files with 6 additions and 7 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import type { betterAuthInstance } from "@dokploy/server"; import type { auth } from "@dokploy/server";
import { import {
adminClient, adminClient,
apiKeyClient, apiKeyClient,
@@ -15,6 +15,6 @@ export const authClient = createAuthClient({
twoFactorClient(), twoFactorClient(),
apiKeyClient(), apiKeyClient(),
adminClient(), adminClient(),
inferAdditionalFields<typeof betterAuthInstance>(), inferAdditionalFields<typeof auth.api>(),
], ],
}); });
+4 -5
View File
@@ -14,7 +14,7 @@ import { getHubSpotUTK, submitToHubSpot } from "../utils/tracking/hubspot";
import { sendEmail } from "../verification/send-verification-email"; import { sendEmail } from "../verification/send-verification-email";
import { getPublicIpWithFallback } from "../wss/utils"; import { getPublicIpWithFallback } from "../wss/utils";
export const betterAuthInstance = betterAuth({ const { handler, api } = betterAuth({
database: drizzleAdapter(db, { database: drizzleAdapter(db, {
provider: "pg", provider: "pg",
schema: schema, schema: schema,
@@ -272,12 +272,11 @@ export const betterAuthInstance = betterAuth({
}); });
export const auth = { export const auth = {
handler: betterAuthInstance.handler, handler: handler,
createApiKey: betterAuthInstance.api.createApiKey, createApiKey: api.createApiKey,
api: api,
}; };
export const { handler, api } = betterAuthInstance;
export const validateRequest = async (request: IncomingMessage) => { export const validateRequest = async (request: IncomingMessage) => {
const apiKey = request.headers["x-api-key"] as string; const apiKey = request.headers["x-api-key"] as string;
if (apiKey) { if (apiKey) {