diff --git a/README.md b/README.md index ec7af0c..8c97d90 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM version](https://img.shields.io/npm/v/@fastify/restartable.svg?style=flat)](https://www.npmjs.com/package/@fastify/restartable) [![CI](https://github.com/fastify/restartable/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/restartable/actions/workflows/ci.yml) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) +[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard) Restart Fastify without losing a request. 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 ce1b43c..02f3587 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "index.js", "type": "commonjs", "scripts": { - "lint": "standard | snazzy", - "lint:fix": "standard --fix", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:typescript": "tsd", "test:unit": "tap" @@ -31,9 +31,8 @@ "devDependencies": { "@fastify/pre-commit": "^2.1.0", "@types/node": "^22.0.0", - "snazzy": "^9.0.0", + "neostandard": "^0.11.9", "split2": "^4.2.0", - "standard": "^17.1.0", "tap": "^18.7.2", "tsd": "^0.31.0", "undici": "^7.0.0" diff --git a/types/index.d.ts b/types/index.d.ts index 02a2e28..a1fb974 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,4 +1,4 @@ -import { fastify, FastifyInstance } from "fastify"; +import { fastify, FastifyInstance } from 'fastify' import type { FastifyBaseLogger, @@ -13,17 +13,17 @@ import type { RawRequestDefaultExpression, RawServerBase, RawServerDefault, -} from "fastify"; -import * as http from "http"; -import * as http2 from "http2"; -import * as https from "https"; +} from 'fastify' +import * as http from 'http' +import * as http2 from 'http2' +import * as https from 'https' export type RestartHook = ( instance: FastifyInstance, restartOpts?: unknown -) => Promise; +) => Promise -declare module "fastify" { +declare module 'fastify' { interface FastifyInstance { restart: (restartOpts?: unknown) => Promise; addPreRestartHook: (fn: RestartHook) => void; @@ -33,7 +33,7 @@ declare module "fastify" { } } -type Fastify = typeof fastify; +type Fastify = typeof fastify export type ApplicationFactory< Server extends @@ -52,15 +52,15 @@ export type ApplicationFactory< ? S extends http2.Http2SecureServer ? FastifyHttp2SecureOptions : S extends http2.Http2Server - ? FastifyHttp2Options - : S extends https.Server - ? FastifyHttpsOptions - : S extends http.Server - ? FastifyHttpOptions - : FastifyServerOptions + ? FastifyHttp2Options + : S extends https.Server + ? FastifyHttpsOptions + : S extends http.Server + ? FastifyHttpOptions + : FastifyServerOptions : FastifyServerOptions, restartOpts?: unknown -) => Promise>; +) => Promise> // These overloads follow the same overloads for the fastify factory @@ -70,11 +70,11 @@ export declare function restartable< Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger extends FastifyBaseLogger = FastifyBaseLogger, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault ->( +> ( factory: ApplicationFactory, opts?: FastifyHttp2SecureOptions, fastify?: Fastify -): Promise>; +): Promise> export declare function restartable< Server extends http2.Http2Server, @@ -82,11 +82,11 @@ export declare function restartable< Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger extends FastifyBaseLogger = FastifyBaseLogger, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault ->( +> ( factory: ApplicationFactory, opts?: FastifyHttp2Options, fastify?: Fastify -): Promise>; +): Promise> export declare function restartable< Server extends https.Server, @@ -94,11 +94,11 @@ export declare function restartable< Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger extends FastifyBaseLogger = FastifyBaseLogger, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault ->( +> ( factory: ApplicationFactory, opts?: FastifyHttpsOptions, fastify?: Fastify -): Promise>; +): Promise> export declare function restartable< Server extends http.Server, @@ -106,8 +106,8 @@ export declare function restartable< Reply extends RawReplyDefaultExpression = RawReplyDefaultExpression, Logger extends FastifyBaseLogger = FastifyBaseLogger, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault ->( +> ( factory: ApplicationFactory, opts?: FastifyHttpOptions, fastify?: Fastify -): Promise>; +): Promise> diff --git a/types/index.test-d.ts b/types/index.test-d.ts index e5d6475..d62cc21 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -1,7 +1,8 @@ import { fastify, FastifyInstance, FastifyServerOptions } from 'fastify' import { expectAssignable, expectType } from 'tsd' +// eslint-disable-next-line @typescript-eslint/no-unused-vars -- ApplicationFactory is used in commented out test import { restartable, ApplicationFactory } from './index' -import type { Http2Server } from "http2" +import type { Http2Server } from 'http2' type Fastify = typeof fastify