diff --git a/src/app.ts b/src/app.ts index 5d2be7d..724f26e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -55,6 +55,7 @@ import { cacheMiddlware } from "./middleware/etag"; import { hostHeader } from "./middleware/hostHeader"; import { getBrandingStats } from "./routes/getBrandingStats"; import { getTopBrandingUsers } from "./routes/getTopBrandingUsers"; +import { getFeatureFlag } from "./routes/getFeatureFlag"; export function createServer(callback: () => void): Server { // Create a service (the app object is just a callback). @@ -210,6 +211,8 @@ function setupRoutes(router: Router) { router.post("/api/feature", addFeature); + router.get("/api/featureFlag/:name", getFeatureFlag); + router.get("/api/generateToken/:type", generateTokenRequest); router.get("/api/verifyToken", verifyTokenRequest); diff --git a/src/config.ts b/src/config.ts index c5dd299..4aa3c8e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -186,7 +186,8 @@ addDefaults(config, { productPermalinks: ["sponsorblock"] }, tokenSeed: "", - minUserIDLength: 30 + minUserIDLength: 30, + deArrowPaywall: false }); loadFromEnv(config); migrate(config); diff --git a/src/routes/getFeatureFlag.ts b/src/routes/getFeatureFlag.ts new file mode 100644 index 0000000..7332d33 --- /dev/null +++ b/src/routes/getFeatureFlag.ts @@ -0,0 +1,13 @@ +import { config } from "../config"; +import { Request, Response } from "express"; + +export function getFeatureFlag(req: Request, res: Response): Response { + const { params: { name } } = req; + + switch (name) { + case "deArrowPaywall": + return res.status(200).json({ + enabled: config.deArrowPaywall, + }); + } +} diff --git a/src/types/config.model.ts b/src/types/config.model.ts index 3d7d40d..092da2d 100644 --- a/src/types/config.model.ts +++ b/src/types/config.model.ts @@ -98,7 +98,8 @@ export interface SBSConfig { productPermalinks: string[], }, tokenSeed: string, - minUserIDLength: number + minUserIDLength: number, + deArrowPaywall: boolean } export interface WebhookConfig {