mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Add feature flag endpoint
This commit is contained in:
parent
ecfc2c14c8
commit
48fa55cc7a
4 changed files with 20 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -186,7 +186,8 @@ addDefaults(config, {
|
|||
productPermalinks: ["sponsorblock"]
|
||||
},
|
||||
tokenSeed: "",
|
||||
minUserIDLength: 30
|
||||
minUserIDLength: 30,
|
||||
deArrowPaywall: false
|
||||
});
|
||||
loadFromEnv(config);
|
||||
migrate(config);
|
||||
|
|
13
src/routes/getFeatureFlag.ts
Normal file
13
src/routes/getFeatureFlag.ts
Normal 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,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -98,7 +98,8 @@ export interface SBSConfig {
|
|||
productPermalinks: string[],
|
||||
},
|
||||
tokenSeed: string,
|
||||
minUserIDLength: number
|
||||
minUserIDLength: number,
|
||||
deArrowPaywall: boolean
|
||||
}
|
||||
|
||||
export interface WebhookConfig {
|
||||
|
|
Loading…
Reference in a new issue