ARTICLE AD BOX
I am trying to use the apiKey plugin with Better Auth with nestjs. The problem I am facing is that the auth object does not exposes any apiKey related methods. Adding the apiKey plugin breaks the intellisense for the auth object. Please help me to resolve this.
Attached is the package.json file and auth.ts file.
import { apiKey } from "@better-auth/api-key"; import { expo } from "@better-auth/expo"; import { typeormAdapter } from "@hedystia/better-auth-typeorm"; import { BaseUserSession } from "@thallesp/nestjs-better-auth"; import { BetterAuthOptions, betterAuth } from "better-auth"; import { admin, openAPI } from "better-auth/plugins"; import { hashPassword, verifyPassword } from "@/util/utils"; import {...} from "../auth/roles"; import { procuraAuthPlugin } from "../better-auth/plugins/procura-auth"; import { dataSource } from "../datasources/better-auth.datasource"; export const auth = betterAuth({ appName: "...", baseURL: process.env.URL, database: typeormAdapter(dataSource, { outputDir: "./src/typeorm", entitiesDir: "./src/models/better-auth", migrationsDir: "./src/migrations", }), emailAndPassword: { enabled: true, requireEmailVerification: true, sendResetPassword: async (data, request) => {}, }, emailVerification: { autoSignInAfterVerification: true, sendVerificationEmail: async (data, request) => {}, }, user: { additionalFields: { type: { type: "string", required: true } } }, session: { additionalFields: { fcmToken: { type: "string", required: false } }, }, plugins: [ apiKey(), procuraAuthPlugin(dataSource), // custom plugin with no additional types expo(), openAPI(), admin({...}), ], });