Skip to content

build(deps-dev): replace standard with neostandard #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/fastify/fastify-http-proxy/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-http-proxy/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/@fastify/http-proxy.svg?style=flat)](https://www.npmjs.com/package/@fastify/http-proxy)
[![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)

Proxy your HTTP requests to another server, with hooks.
This [`fastify`](https://fastify.dev) plugin forwards all requests
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
})
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
"lint": "eslint",
"lint:fix": "eslint --fix",
"lint:typescript": "npm run lint:fix - --parser @typescript-eslint/parser --plugin typescript \"test/types/*.ts\"",
"test": "npm run lint && tap \"test/*.js\" && npm run typescript",
"typescript": "tsd"
Expand All @@ -32,20 +32,17 @@
"@fastify/websocket": "^11.0.1",
"@types/node": "^22.0.0",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"express": "^4.19.2",
"express-http-proxy": "^2.0.0",
"fast-proxy": "^2.1.0",
"fastify": "^5.0.0",
"got": "^11.8.6",
"http-errors": "^2.0.0",
"http-proxy": "^1.18.1",
"neostandard": "^0.11.9",
"simple-get": "^4.0.1",
"snazzy": "^9.0.0",
"socket.io": "^4.7.5",
"socket.io-client": "^4.7.5",
"standard": "^17.1.0",
"tap": "^18.7.2",
"tsd": "^0.31.0",
"typescript": "~5.7.2",
Expand Down
12 changes: 6 additions & 6 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
preValidationHookHandler,
RawServerBase,
RequestGenericInterface,
} from 'fastify';
} from 'fastify'

import {
FastifyReplyFromOptions,
FastifyReplyFromHooks,
} from '@fastify/reply-from';
} from '@fastify/reply-from'

import { ClientOptions, ServerOptions } from 'ws';
import { ClientOptions, ServerOptions } from 'ws'

interface FastifyHttpProxyWebsocketOptionsEnabled {
websocket: true;
Expand All @@ -28,14 +28,14 @@ interface FastifyHttpProxyWebsocketOptionsDisabled {
type FastifyHttpProxy = FastifyPluginCallback<
fastifyHttpProxy.FastifyHttpProxyOptions
& (FastifyHttpProxyWebsocketOptionsEnabled | FastifyHttpProxyWebsocketOptionsDisabled)
>;
>

declare namespace fastifyHttpProxy {
type QueryStringFunction = (
search: string | undefined,
reqUrl: string,
request: FastifyRequest<RequestGenericInterface, RawServerBase>
) => string;
) => string

export interface FastifyHttpProxyOptions extends FastifyReplyFromOptions {
upstream: string;
Expand All @@ -58,5 +58,5 @@ declare namespace fastifyHttpProxy {
export { fastifyHttpProxy as default }
}

declare function fastifyHttpProxy(...params: Parameters<FastifyHttpProxy>): ReturnType<FastifyHttpProxy>
declare function fastifyHttpProxy (...params: Parameters<FastifyHttpProxy>): ReturnType<FastifyHttpProxy>
export = fastifyHttpProxy
42 changes: 21 additions & 21 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import fastify, {
type FastifyRequest,
type RawServerBase,
type RequestGenericInterface,
} from 'fastify';
import { expectError, expectType } from 'tsd';
import fastifyHttpProxy from '..';
} from 'fastify'
import { expectError, expectType } from 'tsd'
import fastifyHttpProxy from '..'

const app = fastify();
const app = fastify()

app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
});
})

app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
Expand All @@ -23,16 +23,16 @@ app.register(fastifyHttpProxy, {
replyOptions: { contentType: 'application/json' },
httpMethods: ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT', 'OPTIONS'],
preHandler: (request, reply) => {
expectType<RawRequestDefaultExpression>(request.raw);
expectType<RawReplyDefaultExpression>(reply.raw);
expectType<RawRequestDefaultExpression>(request.raw)
expectType<RawReplyDefaultExpression>(reply.raw)
},
beforeHandler: (request, reply) => {
expectType<RawRequestDefaultExpression>(request.raw);
expectType<RawReplyDefaultExpression>(reply.raw);
expectType<RawRequestDefaultExpression>(request.raw)
expectType<RawReplyDefaultExpression>(reply.raw)
},
preValidation: (request, reply) => {
expectType<RawRequestDefaultExpression>(request.raw);
expectType<RawReplyDefaultExpression>(reply.raw);
expectType<RawRequestDefaultExpression>(request.raw)
expectType<RawReplyDefaultExpression>(reply.raw)
},
base: 'whatever',
cacheURLs: 10,
Expand All @@ -56,41 +56,41 @@ app.register(fastifyHttpProxy, {
websocket: true,
wsUpstream: 'ws://origin.asd/connection',
wsClientOptions: {
queryString(search, reqUrl, request) {
expectType<string | undefined>(search);
expectType<string>(reqUrl);
expectType<FastifyRequest<RequestGenericInterface, RawServerBase>>(request);
return '';
queryString (search, reqUrl, request) {
expectType<string | undefined>(search)
expectType<string>(reqUrl)
expectType<FastifyRequest<RequestGenericInterface, RawServerBase>>(request)
return ''
},
},
internalRewriteLocationHeader: true,
});
})

expectError(
app.register(fastifyHttpProxy, {
thisOptionDoesNotExist: 'triggers a typescript error',
})
);
)

expectError(
app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
wsUpstream: 'ws://origin.asd',
})
);
)

expectError(
app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
websocket: false,
wsUpstream: 'asdf',
})
);
)

expectError(
app.register(fastifyHttpProxy, {
upstream: 'http://origin.asd',
websocket: false,
internalRewriteLocationHeader: 'NON_BOOLEAN_VALUE'
})
);
)
Loading