diff --git a/Readme.md b/Readme.md
index 2bc7220..21e7df0 100644
--- a/Readme.md
+++ b/Readme.md
@@ -2,7 +2,7 @@
[](https://github.com/fastify/fastify-caching/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/@fastify/caching)
-[](https://standardjs.com/)
+[](https://github.com/neostandard/neostandard)
*@fastify/caching* is a plugin for the [Fastify](http://fastify.dev/) framework
that provides server-side caching and mechanisms for manipulating HTTP cache headers according to
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..89fd678
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,6 @@
+'use strict'
+
+module.exports = require('neostandard')({
+ ignores: require('neostandard').resolveIgnoresFromGitignore(),
+ ts: true
+})
diff --git a/package.json b/package.json
index 42f4fb9..1d91cd6 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
- "lint": "standard --verbose | snazzy",
- "lint:fix": "standard --verbose --fix | snazzy",
+ "lint": "eslint",
+ "lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "c8 --100 node --test",
@@ -38,8 +38,7 @@
"@types/node": "^22.0.0",
"c8": "^10.1.2",
"fastify": "^5.0.0",
- "snazzy": "^9.0.0",
- "standard": "^17.1.0",
+ "neostandard": "^0.11.9",
"tsd": "^0.31.0"
},
"dependencies": {
diff --git a/types/index.d.ts b/types/index.d.ts
index 4322933..b202719 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,6 +1,6 @@
///
-import { FastifyPluginCallback } from 'fastify';
+import { FastifyPluginCallback } from 'fastify'
declare module 'fastify' {
interface FastifyInstance {
@@ -33,13 +33,13 @@ declare module 'fastify' {
type FastifyCaching = FastifyPluginCallback & {
privacy: fastifyCaching.Privacy;
-};
+}
type CacheResult = {
item: T,
stored: number,
ttl: number,
-} | null;
+} | null
declare namespace fastifyCaching {
/**
@@ -130,11 +130,11 @@ declare namespace fastifyCaching {
serverExpiresIn?: number;
}
- export const privacy: Privacy;
+ export const privacy: Privacy
- export const fastifyCaching: FastifyCaching;
- export { fastifyCaching as default };
+ export const fastifyCaching: FastifyCaching
+ export { fastifyCaching as default }
}
-declare function fastifyCaching(...params: Parameters): ReturnType
+declare function fastifyCaching (...params: Parameters): ReturnType
export = fastifyCaching
diff --git a/types/index.test-d.ts b/types/index.test-d.ts
index 0fa7f34..805541e 100644
--- a/types/index.test-d.ts
+++ b/types/index.test-d.ts
@@ -1,69 +1,69 @@
-import Fastify, { FastifyReply } from 'fastify';
-import { expectAssignable, expectError, expectType } from 'tsd';
+import Fastify, { FastifyReply } from 'fastify'
+import { expectAssignable, expectError, expectType } from 'tsd'
import fastifyCaching, {
AbstractCacheCompliantObject,
FastifyCachingPluginOptions,
-} from '..';
+} from '..'
-const fastify = Fastify({ logger: true });
+const fastify = Fastify({ logger: true })
const cachingOptions: FastifyCachingPluginOptions = {
privacy: fastifyCaching.privacy.PUBLIC,
expiresIn: 300,
cacheSegment: 'fastify-caching',
-};
-expectAssignable(cachingOptions);
+}
+expectAssignable(cachingOptions)
-fastify.register(fastifyCaching, cachingOptions);
+fastify.register(fastifyCaching, cachingOptions)
-expectType(fastify.cache);
-expectType(fastify.cache.get);
-expectType(fastify.cache.set);
-expectType(fastify.cacheSegment);
+expectType(fastify.cache)
+expectType(fastify.cache.get)
+expectType(fastify.cache.set)
+expectType(fastify.cacheSegment)
// expectType(fastify.etagMaxLife);
fastify.get('/one', async (request, reply) => {
- expectType<(tag?: string, timeToLive?: number) => FastifyReply>(reply.etag);
- expectType<(date?: Date) => FastifyReply>(reply.expires);
+ expectType<(tag?: string, timeToLive?: number) => FastifyReply>(reply.etag)
+ expectType<(date?: Date) => FastifyReply>(reply.expires)
- expectType(reply.etag('hello', 6000));
- expectType(reply.expires(new Date(Date.now() + 6000)));
+ expectType(reply.etag('hello', 6000))
+ expectType(reply.expires(new Date(Date.now() + 6000)))
- return { message: 'one' };
-});
+ return { message: 'one' }
+})
fastify.get('/two', async (request, reply) => {
expectType(
reply.etag('hello', 6000).expires(new Date(Date.now() + 6000))
- );
+ )
- return { message: 'two' };
-});
+ return { message: 'two' }
+})
// We register a new instance that should trigger a typescript error.
-const shouldErrorApp = Fastify({ logger: true });
+const shouldErrorApp = Fastify({ logger: true })
const badCachingOptions = {
privacy: fastifyCaching.privacy.PRIVATE,
expiresIn: 'a string instead of a number of second',
cacheSegment: 'fastify-caching',
-};
+}
-expectError(shouldErrorApp.register(fastifyCaching, badCachingOptions));
+expectError(shouldErrorApp.register(fastifyCaching, badCachingOptions))
fastify.get('/three', async (request, reply) => {
expectAssignable>(
fastify.cache.get('well-known')
- );
+ )
expectAssignable>(
fastify.cache.get('well-known')
- );
+ )
expectType(
fastify.cache.get('well-known', (err, value) => {
- expectType(err);
- expectAssignable<{ item: string; stored: number; ttl: number; } | null>(value);
+ expectType(err)
+ expectAssignable<{ item: string; stored: number; ttl: number; } | null>(value)
})
- );
+ )
- return { message: 'two' };
-});
+ return { message: 'two' }
+})