Add feature flag endpoint

This commit is contained in:
Ajay 2023-08-05 23:01:24 -04:00
parent ecfc2c14c8
commit 48fa55cc7a
4 changed files with 20 additions and 2 deletions

View file

@ -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);

View file

@ -186,7 +186,8 @@ addDefaults(config, {
productPermalinks: ["sponsorblock"]
},
tokenSeed: "",
minUserIDLength: 30
minUserIDLength: 30,
deArrowPaywall: false
});
loadFromEnv(config);
migrate(config);

View file

@ -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,
});
}
}

View file

@ -98,7 +98,8 @@ export interface SBSConfig {
productPermalinks: string[],
},
tokenSeed: string,
minUserIDLength: number
minUserIDLength: number,
deArrowPaywall: boolean
}
export interface WebhookConfig {