-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(deps-dev): replace standard with neostandard (#74)
* build(deps-dev): replace standard with neostandard * chore: add eslint.config.js * fix linting --------- Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com>
- Loading branch information
Showing
5 changed files
with
36 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
/// <reference types="node" /> | ||
|
||
import { IncomingMessage } from 'http'; | ||
import { IncomingMessage } from 'http' | ||
|
||
type FastifyProxyAddr = typeof proxyaddr | ||
|
||
declare function proxyaddr(req: IncomingMessage, trust: proxyaddr.Address | proxyaddr.Address[] | ((addr: string, i: number) => boolean)): string; | ||
declare function proxyaddr (req: IncomingMessage, trust: proxyaddr.Address | proxyaddr.Address[] | ((addr: string, i: number) => boolean)): string | ||
|
||
declare namespace proxyaddr { | ||
export function all(req: IncomingMessage, trust?: Address | Address[] | ((addr: string, i: number) => boolean)): string[]; | ||
export function compile(val: Address | Address[]): (addr: string, i: number) => boolean; | ||
export function all (req: IncomingMessage, trust?: Address | Address[] | ((addr: string, i: number) => boolean)): string[] | ||
export function compile (val: Address | Address[]): (addr: string, i: number) => boolean | ||
|
||
export type Address = 'loopback' | 'linklocal' | 'uniquelocal' | string; | ||
export type Address = 'loopback' | 'linklocal' | 'uniquelocal' | string | ||
|
||
export const proxyAddr: FastifyProxyAddr | ||
export { proxyAddr as default } | ||
} | ||
export = proxyaddr; | ||
export = proxyaddr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import proxyaddr from '..'; | ||
import { createServer } from 'http'; | ||
import proxyaddr from '..' | ||
import { createServer } from 'http' | ||
import { expectType } from 'tsd' | ||
|
||
createServer(req => { | ||
// $ExpectType string | ||
proxyaddr(req, addr => addr === '127.0.0.1'); | ||
proxyaddr(req, (addr, i) => i < 1); | ||
expectType<string>(proxyaddr(req, addr => addr === '127.0.0.1')) | ||
expectType<string>(proxyaddr(req, (addr, i) => i < 1)) | ||
|
||
proxyaddr(req, '127.0.0.1'); | ||
proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8']); | ||
proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0']); | ||
expectType<string>(proxyaddr(req, '127.0.0.1')) | ||
expectType<string>(proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8'])) | ||
expectType<string>(proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0'])) | ||
|
||
proxyaddr(req, '::1'); | ||
proxyaddr(req, ['::1/128', 'fe80::/10']); | ||
expectType<string>(proxyaddr(req, '::1')) | ||
expectType<string>(proxyaddr(req, ['::1/128', 'fe80::/10'])) | ||
|
||
proxyaddr(req, 'loopback'); | ||
proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64']); | ||
expectType<string>(proxyaddr(req, 'loopback')) | ||
expectType<string>(proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64'])) | ||
|
||
// $ExpectType string[] | ||
proxyaddr.all(req); | ||
proxyaddr.all(req, 'loopback'); | ||
expectType<string[]>(proxyaddr.all(req)) | ||
expectType<string[]>(proxyaddr.all(req, 'loopback')) | ||
|
||
const trust = proxyaddr.compile('localhost'); | ||
proxyaddr.compile(['localhost']); | ||
trust; // $ExpectType (addr: string, i: number) => boolean | ||
proxyaddr(req, trust); | ||
}); | ||
proxyaddr.compile(['localhost']) | ||
|
||
const trust = proxyaddr.compile('localhost') | ||
expectType<(addr: string, i: number) => boolean>(trust) | ||
proxyaddr(req, trust) | ||
}) |