Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard (#81)
Browse files Browse the repository at this point in the history
* build(deps-dev): replace standard with neostandard

* chore: add eslint.config.js

* test(types): ignore unused import
  • Loading branch information
Fdawgs authored Dec 12, 2024
1 parent 0969daa commit ea3e704
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
46 changes: 23 additions & 23 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fastify, FastifyInstance } from "fastify";
import { fastify, FastifyInstance } from 'fastify'

import type {
FastifyBaseLogger,
Expand All @@ -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<unknown>;
) => Promise<unknown>

declare module "fastify" {
declare module 'fastify' {
interface FastifyInstance {
restart: (restartOpts?: unknown) => Promise<void>;
addPreRestartHook: (fn: RestartHook) => void;
Expand All @@ -33,7 +33,7 @@ declare module "fastify" {
}
}

type Fastify = typeof fastify;
type Fastify = typeof fastify

export type ApplicationFactory<
Server extends
Expand All @@ -52,15 +52,15 @@ export type ApplicationFactory<
? S extends http2.Http2SecureServer
? FastifyHttp2SecureOptions<S, Logger>
: S extends http2.Http2Server
? FastifyHttp2Options<S, Logger>
: S extends https.Server
? FastifyHttpsOptions<S, Logger>
: S extends http.Server
? FastifyHttpOptions<S, Logger>
: FastifyServerOptions<Server>
? FastifyHttp2Options<S, Logger>
: S extends https.Server
? FastifyHttpsOptions<S, Logger>
: S extends http.Server
? FastifyHttpOptions<S, Logger>
: FastifyServerOptions<Server>
: FastifyServerOptions<Server>,
restartOpts?: unknown
) => Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>;
) => Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>

// These overloads follow the same overloads for the fastify factory

Expand All @@ -70,44 +70,44 @@ export declare function restartable<
Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
>(
> (
factory: ApplicationFactory<Server, Request, Reply, Logger, TypeProvider>,
opts?: FastifyHttp2SecureOptions<Server, Logger>,
fastify?: Fastify
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>;
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>

export declare function restartable<
Server extends http2.Http2Server,
Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
>(
> (
factory: ApplicationFactory<Server, Request, Reply, Logger, TypeProvider>,
opts?: FastifyHttp2Options<Server, Logger>,
fastify?: Fastify
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>;
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>

export declare function restartable<
Server extends https.Server,
Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
>(
> (
factory: ApplicationFactory<Server, Request, Reply, Logger, TypeProvider>,
opts?: FastifyHttpsOptions<Server, Logger>,
fastify?: Fastify
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>;
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>

export declare function restartable<
Server extends http.Server,
Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
Logger extends FastifyBaseLogger = FastifyBaseLogger,
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
>(
> (
factory: ApplicationFactory<Server, Request, Reply, Logger, TypeProvider>,
opts?: FastifyHttpOptions<Server, Logger>,
fastify?: Fastify
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>;
): Promise<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
3 changes: 2 additions & 1 deletion types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit ea3e704

Please sign in to comment.