mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
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:
committed by
GitHub
parent
114dd5e3e3
commit
d64ca14348
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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],
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user