UNPKG

@lygos/nestjs-better-auth

Version:
40 lines 1.83 kB
import { createParamDecorator } from "@nestjs/common"; import type { CustomDecorator } from "@nestjs/common"; import type { createAuthMiddleware } from "better-auth/api"; /** * Marks a route or a controller as public, allowing unauthenticated access. * When applied, the AuthGuard will skip authentication checks. */ export declare const Public: () => CustomDecorator<string>; /** * Marks a route or a controller as having optional authentication. * When applied, the AuthGuard will allow the request to proceed * even if no session is present. */ export declare const Optional: () => CustomDecorator<string>; /** * Parameter decorator that extracts the user session from the request. * Provides easy access to the authenticated user's session data in controller methods. */ export declare const Session: ReturnType<typeof createParamDecorator>; /** * Represents the context object passed to hooks. * This type is derived from the parameters of the createAuthMiddleware function. */ export type AuthHookContext = Parameters<Parameters<typeof createAuthMiddleware>[0]>[0]; /** * Registers a method to be executed before a specific auth route is processed. * @param path - The auth route path that triggers this hook (must start with '/') */ export declare const BeforeHook: (path: `/${string}`) => CustomDecorator<symbol>; /** * Registers a method to be executed after a specific auth route is processed. * @param path - The auth route path that triggers this hook (must start with '/') */ export declare const AfterHook: (path: `/${string}`) => CustomDecorator<symbol>; /** * Class decorator that marks a provider as containing hook methods. * Must be applied to classes that use BeforeHook or AfterHook decorators. */ export declare const Hook: () => ClassDecorator; //# sourceMappingURL=decorators.d.ts.map