mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-15 07:17:00 +10:00
refactor: remove dead code, unused exports and redundant dependencies
- drop dotenv (Node 24 process.loadEnvFile) and dompurify (only used by dead code) - delete unused ui components/hooks (card, progress, checkbox, use-confirm, use-prompt) - delete dead sanitizeHtml/sanitizeCss, url-security helpers, patch-resume tool, schema/page, createResumePatches, patch-proposal preview builder, fonts fallback helpers - inline single-caller wrappers (flags service, auth getSession, pdf renderer passthrough) - deduplicate template color helpers into shared/color-helpers - unexport 50+ internal-only symbols, remove dead export-map entries - replace hand-rolled unique()/useIsMobile with Set spread and usehooks-ts
This commit is contained in:
@@ -1 +1 @@
|
||||
export type { FeatureFlags } from "./service";
|
||||
export type { FeatureFlags } from "./router";
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import type { FeatureFlags } from "./service";
|
||||
import z from "zod";
|
||||
import { env } from "@reactive-resume/env/server";
|
||||
import { publicProcedure } from "../../context";
|
||||
import { flagsService } from "./service";
|
||||
|
||||
export type FeatureFlags = {
|
||||
disableSignups: boolean;
|
||||
disableEmailAuth: boolean;
|
||||
showSponsors: boolean;
|
||||
};
|
||||
|
||||
export const flagsRouter = {
|
||||
get: publicProcedure
|
||||
@@ -22,5 +27,11 @@ export const flagsRouter = {
|
||||
showSponsors: z.boolean().describe("Whether sponsor placements are shown on this instance."),
|
||||
}),
|
||||
)
|
||||
.handler((): FeatureFlags => flagsService.getFlags()),
|
||||
.handler(
|
||||
(): FeatureFlags => ({
|
||||
disableSignups: env.FLAG_DISABLE_SIGNUPS,
|
||||
disableEmailAuth: env.FLAG_DISABLE_EMAIL_AUTH,
|
||||
showSponsors: env.FLAG_SHOW_SPONSORS,
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const envMock = vi.hoisted(() => ({
|
||||
FLAG_DISABLE_SIGNUPS: false,
|
||||
FLAG_DISABLE_EMAIL_AUTH: false,
|
||||
FLAG_SHOW_SPONSORS: false,
|
||||
}));
|
||||
|
||||
vi.mock("@reactive-resume/env/server", () => ({ env: envMock }));
|
||||
|
||||
const { flagsService } = await import("./service");
|
||||
|
||||
describe("flagsService.getFlags", () => {
|
||||
it("reads disableSignups + disableEmailAuth from env", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_DISABLE_EMAIL_AUTH = false;
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns disableSignups=true when env flag is set", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = true;
|
||||
envMock.FLAG_DISABLE_EMAIL_AUTH = false;
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: true,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns disableEmailAuth=true when env flag is set", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_DISABLE_EMAIL_AUTH = true;
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: true,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns showSponsors=true when env flag is set", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_DISABLE_EMAIL_AUTH = false;
|
||||
envMock.FLAG_SHOW_SPONSORS = true;
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("reads the latest env values on every call (no stale cache)", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_SHOW_SPONSORS = false;
|
||||
const before = flagsService.getFlags();
|
||||
envMock.FLAG_DISABLE_SIGNUPS = true;
|
||||
envMock.FLAG_SHOW_SPONSORS = true;
|
||||
const after = flagsService.getFlags();
|
||||
|
||||
expect(before.disableSignups).toBe(false);
|
||||
expect(after.disableSignups).toBe(true);
|
||||
expect(before.showSponsors).toBe(false);
|
||||
expect(after.showSponsors).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import { env } from "@reactive-resume/env/server";
|
||||
|
||||
export type FeatureFlags = {
|
||||
disableSignups: boolean;
|
||||
disableEmailAuth: boolean;
|
||||
showSponsors: boolean;
|
||||
};
|
||||
|
||||
export const flagsService = {
|
||||
getFlags: (): FeatureFlags => ({
|
||||
disableSignups: env.FLAG_DISABLE_SIGNUPS,
|
||||
disableEmailAuth: env.FLAG_DISABLE_EMAIL_AUTH,
|
||||
showSponsors: env.FLAG_SHOW_SPONSORS,
|
||||
}),
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
export { downloadResumePdfProcedure } from "./export";
|
||||
export { resumeService } from "./service";
|
||||
Reference in New Issue
Block a user