From a37577bb35b17a6d4b02f7582087430d3276bbd2 Mon Sep 17 00:00:00 2001 From: tycrek Date: Mon, 14 Mar 2022 19:38:05 -0600 Subject: [PATCH] Fix ordering to resolve DeepSource JS-0357 --- src/utils.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 0ab3589..9ad9579 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -75,24 +75,22 @@ export function verify(req: Request, users: JSON) { return req.headers.authorization && Object.prototype.hasOwnProperty.call(users, req.headers.authorization); } -export function generateId(mode: string, length: number, gfyLength: number, originalName: string) { - return (GENERATORS.has(mode) ? GENERATORS.get(mode)({ length, gfyLength }) : originalName); -} - -// Set up pathing -export const path = (...paths: string[]) => Path.join(process.cwd(), ...paths); - const idModes = { zws: 'zws', // Zero-width spaces (see: https://zws.im/) og: 'original', // Use original uploaded filename r: 'random', // Use a randomly generated ID with a mixed-case alphanumeric character set gfy: 'gfycat' // Gfycat-style ID's (https://gfycat.com/unsungdiscretegrub) }; - const GENERATORS = new Map(); GENERATORS.set(idModes.zws, zwsGen); GENERATORS.set(idModes.r, randomGen); GENERATORS.set(idModes.gfy, gfyGen); +export function generateId(mode: string, length: number, gfyLength: number, originalName: string) { + return (GENERATORS.has(mode) ? GENERATORS.get(mode)({ length, gfyLength }) : originalName); +} + +// Set up pathing +export const path = (...paths: string[]) => Path.join(process.cwd(), ...paths); export const isProd = require('@tycrek/isprod')(); module.exports = {