Explicitly set catch parameters to any type (#7654)

This fixes not being able to build the repo due to type issues
introduced by the Typescript 4.4 option "useUnknownInCatchVariables",
which is enabled by default in strict mode.
This commit is contained in:
Nicola Krumschmidt
2021-08-27 16:33:30 +02:00
committed by GitHub
parent 114dd5e3e3
commit d64ca14348
133 changed files with 266 additions and 266 deletions

View File

@@ -28,7 +28,7 @@ const authenticate: RequestHandler = asyncHandler(async (req, res, next) => {
try {
payload = jwt.verify(req.token, env.SECRET as string) as { id: string };
} catch (err) {
} catch (err: any) {
if (err instanceof TokenExpiredError) {
throw new InvalidCredentialsException('Token expired.');
} else if (err instanceof JsonWebTokenError) {

View File

@@ -23,7 +23,7 @@ const checkCacheMiddleware: RequestHandler = asyncHandler(async (req, res, next)
try {
cachedData = await cache.get(key);
} catch (err) {
} catch (err: any) {
logger.warn(err, `[cache] Couldn't read key ${key}. ${err.message}`);
return next();
}
@@ -33,7 +33,7 @@ const checkCacheMiddleware: RequestHandler = asyncHandler(async (req, res, next)
try {
cacheExpiryDate = (await cache.get(`${key}__expires_at`)) as number | null;
} catch (err) {
} catch (err: any) {
logger.warn(err, `[cache] Couldn't read key ${`${key}__expires_at`}. ${err.message}`);
return next();
}

View File

@@ -40,7 +40,7 @@ export const parseGraphQL: RequestHandler = asyncHandler(async (req, res, next)
try {
document = parse(new Source(query));
} catch (err) {
} catch (err: any) {
throw new InvalidPayloadException(`GraphQL schema validation error.`, {
graphqlErrors: [err],
});

View File

@@ -18,7 +18,7 @@ if (env.RATE_LIMITER_ENABLED === true) {
checkRateLimit = asyncHandler(async (req, res, next) => {
try {
await rateLimiter.consume(req.ip, 1);
} catch (rateLimiterRes) {
} catch (rateLimiterRes: any) {
if (rateLimiterRes instanceof Error) throw rateLimiterRes;
res.set('Retry-After', String(rateLimiterRes.msBeforeNext / 1000));

View File

@@ -25,7 +25,7 @@ export const respond: RequestHandler = asyncHandler(async (req, res) => {
try {
await cache.set(key, res.locals.payload, ms(env.CACHE_TTL as string));
await cache.set(`${key}__expires_at`, Date.now() + ms(env.CACHE_TTL as string));
} catch (err) {
} catch (err: any) {
logger.warn(err, `[cache] Couldn't set key ${key}. ${err}`);
}