Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: make the dash plugin optional

Amruth Pillaifd892b0e142e
diff --git a/src/integrations/auth/config.ts b/src/integrations/auth/config.ts
index 6a442379c..383b75b59 100644
--- a/src/integrations/auth/config.ts
+++ b/src/integrations/auth/config.ts
@@ -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 } })]
+ : []),
],
});
};
diff --git a/src/integrations/orpc/services/resume.test.ts b/src/integrations/orpc/services/resume.test.ts
new file mode 100644
index 000000000..5f4d3b061
--- /dev/null
+++ b/src/integrations/orpc/services/resume.test.ts
@@ -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" });
+ }
+ });
+});
diff --git a/src/integrations/orpc/services/resume.ts b/src/integrations/orpc/services/resume.ts
index 20ea04e7f..9ea193772 100644
--- a/src/integrations/orpc/services/resume.ts
+++ b/src/integrations/orpc/services/resume.ts
@@ -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;
},