Skip to content

Commit

Permalink
Fix deprecation warning for using fastify request.routerPath
Browse files Browse the repository at this point in the history
  • Loading branch information
biwano committed Dec 18, 2023
1 parent a8748aa commit 4548c66
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable import/prefer-default-export */
import type { FastifyRequest } from 'fastify';
import type {
RequestMethod,
ICacheOptions,
ICachePluginOptions,
RequestMethod,
} from './types/lcache';

const getMilliseconds = (min: number): number => min * 60000;
Expand All @@ -22,12 +22,11 @@ export const shouldBeCached = (
statusCode: number
): boolean => {
const { methodsToCache, statusesToCache, excludeRoutes } = opts;
// TODO use routeOptions.url - test compatibility
const { routerPath, method } = request;
const { routeOptions, method } = request;

Check failure on line 25 in lib/helpers.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Property 'routeOptions' does not exist on type 'FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, unknown, FastifyLoggerInstance>'.

Check failure on line 25 in lib/helpers.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'routeOptions' does not exist on type 'FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, unknown, FastifyLoggerInstance>'.

Check failure on line 25 in lib/helpers.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'routeOptions' does not exist on type 'FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, unknown, FastifyLoggerInstance>'.

return (
methodsToCache.has(method as RequestMethod) &&
statusesToCache.has(statusCode) &&
!excludeRoutes.has(routerPath)
!excludeRoutes.has(routeOptions.url)
);
};

0 comments on commit 4548c66

Please sign in to comment.