fix: make the dash plugin optional

- fixes #2947
This commit is contained in:
Amruth Pillai
2026-04-29 23:30:07 +02:00
parent dc4830d41b
commit fd892b0e14
3 changed files with 47 additions and 1 deletions
+3 -1
View File
@@ -374,7 +374,6 @@ const getAuthConfig = () => {
genericOAuth({ config: authConfigs }),
twoFactor({ issuer: "Reactive Resume" }),
apiKey({ enableSessionForAPIKeys: true, rateLimit: rateLimitConfig.betterAuth.apiKey }),
dash({ apiKey: env.BETTER_AUTH_API_KEY, activityTracking: { enabled: true } }),
oauthProvider({
loginPage: "/auth/oauth",
consentPage: "/auth/oauth",
@@ -394,6 +393,9 @@ const getAuthConfig = () => {
usernameValidator: (username) => /^[a-z0-9._-]+$/.test(username),
validationOrder: { username: "post-normalization", displayUsername: "post-normalization" },
}),
...(env.BETTER_AUTH_API_KEY
? [dash({ apiKey: env.BETTER_AUTH_API_KEY, activityTracking: { enabled: true } })]
: []),
],
});
};
@@ -0,0 +1,41 @@
import { ORPCError } from "@orpc/client";
import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
type StatisticsRow = {
isPublic: boolean;
views: number | null;
downloads: number | null;
lastViewedAt: Date | null;
lastDownloadedAt: Date | null;
};
const where = vi.fn<() => Promise<StatisticsRow[]>>();
const rightJoin = vi.fn<() => { where: typeof where }>(() => ({ where }));
const from = vi.fn<() => { rightJoin: typeof rightJoin }>(() => ({ rightJoin }));
const select = vi.fn<() => { from: typeof from }>(() => ({ from }));
vi.mock("@/integrations/drizzle/client", () => ({
db: {
select,
},
}));
const { resumeService } = await import("./resume");
describe("resumeService.statistics.getById", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("throws not found when the resume does not exist for the user", async () => {
where.mockResolvedValueOnce([]);
try {
await resumeService.statistics.getById({ id: "resume-1", userId: "user-1" });
throw new Error("Expected statistics lookup to throw");
} catch (error) {
expect(error).toBeInstanceOf(ORPCError);
expect(error).toMatchObject({ code: "NOT_FOUND" });
}
});
});
+3
View File
@@ -50,6 +50,8 @@ const statistics = {
.rightJoin(schema.resume, eq(schema.resumeStatistics.resumeId, schema.resume.id))
.where(and(eq(schema.resume.id, input.id), eq(schema.resume.userId, input.userId)));
if (!statistics) throw new ORPCError("NOT_FOUND");
return {
isPublic: statistics.isPublic,
views: statistics.views ?? 0,
@@ -95,6 +97,7 @@ const analysis = {
.where(and(eq(schema.resume.id, input.id), eq(schema.resume.userId, input.userId)));
if (!result) throw new ORPCError("NOT_FOUND");
return result.analysis ?? null;
},