From 33b3f130c1856b11deedda1ed3bc0d56cc85568b Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Mon, 12 Jan 2026 19:55:23 +0000 Subject: [PATCH] chore: type cast a couple of cases which should never happen --- src/controller/ConfigureController.ts | 2 +- src/controller/ManifestController.ts | 2 +- src/controller/StreamController.ts | 2 +- src/utils/context.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controller/ConfigureController.ts b/src/controller/ConfigureController.ts index f6918e3..6d3d77b 100644 --- a/src/controller/ConfigureController.ts +++ b/src/controller/ConfigureController.ts @@ -22,7 +22,7 @@ export class ConfigureController { } private getConfigure(req: Request, res: Response) { - const config: Config = JSON.parse(req.params['config'] || JSON.stringify(getDefaultConfig())); + const config: Config = JSON.parse(req.params['config'] as string || JSON.stringify(getDefaultConfig())); // Convenience preset for ElfHosted WebStreamr bundle including Media Flow Proxy if (!req.params['config'] && isElfHostedInstance(req)) { diff --git a/src/controller/ManifestController.ts b/src/controller/ManifestController.ts index fd37f00..5437a9c 100644 --- a/src/controller/ManifestController.ts +++ b/src/controller/ManifestController.ts @@ -21,7 +21,7 @@ export class ManifestController { } private getManifest(req: Request, res: Response) { - const config: Config = JSON.parse(req.params['config'] || JSON.stringify(getDefaultConfig())); + const config: Config = JSON.parse(req.params['config'] as string || JSON.stringify(getDefaultConfig())); const manifest = buildManifest(this.sources, this.extractors, config); diff --git a/src/controller/StreamController.ts b/src/controller/StreamController.ts index 6d69549..d81ca71 100644 --- a/src/controller/StreamController.ts +++ b/src/controller/StreamController.ts @@ -27,7 +27,7 @@ export class StreamController { private async getStream(req: Request, res: Response) { const type: ContentType = (req.params['type'] || '') as ContentType; - const rawId: string = req.params['id'] || ''; + const rawId: string = req.params['id'] as string || ''; let id: Id; if (rawId.startsWith('tmdb:')) { diff --git a/src/utils/context.ts b/src/utils/context.ts index eb73125..3f21db1 100644 --- a/src/utils/context.ts +++ b/src/utils/context.ts @@ -7,6 +7,6 @@ export const contextFromRequestAndResponse = (req: Request, res: Response): Cont hostUrl: new URL(`${req.protocol}://${req.host}`), id: res.getHeader('X-Request-ID') as string, ...(req.ip && { ip: req.ip }), - config: req.params['config'] ? JSON.parse(req.params['config']) : getDefaultConfig(), + config: req.params['config'] ? JSON.parse(req.params['config'] as string) : getDefaultConfig(), }; };