Skip to content

Commit 2e5ca30

Browse files
authored
Merge pull request #1 from Bessonov/update-dependencies
update dependencies
2 parents ce9cc55 + dc1be6f commit 2e5ca30

File tree

10 files changed

+67
-94
lines changed

10 files changed

+67
-94
lines changed

.eslintrc.js

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,97 +8,63 @@ module.exports = {
88
'@typescript-eslint',
99
],
1010
extends: [
11-
'airbnb',
11+
'airbnb-base',
1212
'plugin:@typescript-eslint/recommended',
13+
'@bessonovs/eslint-config',
14+
'@bessonovs/eslint-config/typescript',
1315
],
1416
parser: '@typescript-eslint/parser',
1517
rules: {
1618
'arrow-body-style': 'off',
1719
'lines-between-class-members': 'off',
1820
'implicit-arrow-linebreak': 'off',
19-
'no-console': 'error',
20-
'no-trailing-spaces': 'error',
2121
'no-restricted-syntax': 'off',
22-
'indent': [
23-
'error',
24-
'tab',
25-
],
2622
'object-curly-newline': [
2723
'error',
2824
{
2925
ImportDeclaration: {
3026
minProperties: 2,
3127
multiline: true,
32-
}
33-
}
34-
],
35-
semi: [
36-
'error',
37-
'never',
38-
],
39-
quotes: [
40-
'error',
41-
'single',
42-
{
43-
avoidEscape: true,
44-
allowTemplateLiterals: true
45-
}
46-
],
47-
'comma-dangle': [
48-
'error',
49-
'always-multiline'
50-
],
51-
'no-tabs': [
52-
'error',
53-
{
54-
'allowIndentationTabs': true
55-
}
56-
],
57-
'sort-imports': [
58-
'error',
59-
{
60-
ignoreDeclarationSort: true,
61-
}
62-
],
63-
'@typescript-eslint/explicit-function-return-type': 'error',
64-
'@typescript-eslint/explicit-member-accessibility': 'off',
65-
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
66-
'@typescript-eslint/no-object-literal-type-assertion': 'off',
67-
'@typescript-eslint/no-explicit-any': 'error',
68-
'@typescript-eslint/no-extra-parens': 'error',
69-
'@typescript-eslint/member-delimiter-style': [
70-
'error',
71-
{
72-
multiline: {
73-
delimiter: 'none'
74-
}
75-
}
28+
},
29+
},
7630
],
7731
'@typescript-eslint/indent': [
7832
'error',
79-
'tab'
33+
'tab',
8034
],
81-
'import/prefer-default-export': 'off',
82-
'import/no-default-export': 'error',
83-
'import/no-unresolved': 'off',
8435
'import/no-useless-path-segments': 'error',
8536
'import/no-cycle': 'error',
8637
// doesn't work for central devDependencies
8738
'import/no-extraneous-dependencies': 'off',
39+
'import/extensions': [
40+
'error',
41+
'ignorePackages',
42+
{
43+
ts: 'never',
44+
tsx: 'never',
45+
},
46+
],
47+
},
48+
settings: {
49+
'import/resolver': {
50+
node: {
51+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
52+
},
53+
},
8854
},
8955
overrides: [
9056
{
9157
files: ['**/*.js'],
9258
rules: {
9359
'@typescript-eslint/no-var-requires': 'off',
94-
'@typescript-eslint/explicit-function-return-type': 'off'
60+
'@typescript-eslint/explicit-function-return-type': 'off',
9561
},
9662
},
9763
{
9864
files: ['**/__tests__/**'],
9965
rules: {
10066
'@typescript-eslint/explicit-function-return-type': 'off',
101-
}
67+
},
10268
},
10369
{
10470
files: ['**/*.ts', '**/*.d.ts'],
@@ -107,5 +73,5 @@ module.exports = {
10773
'no-useless-constructor': 'off',
10874
},
10975
},
110-
]
76+
],
11177
}

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"http",
1717
"server"
1818
],
19-
"version": "0.0.4",
19+
"version": "0.0.5",
2020
"author": "Anton Bessonov",
2121
"license": "MIT",
2222
"repository": "bessonov/node-http-router",
@@ -34,25 +34,26 @@
3434
},
3535
"dependencies": {
3636
"fast-url-parser": "1.1.3",
37-
"ts-toolbelt": "4.8.19"
37+
"ts-toolbelt": "6.7.7"
3838
},
3939
"devDependencies": {
40-
"@types/express": "4.17.1",
41-
"@types/jest": "24.0.19",
42-
"@types/node": "12.11.1",
43-
"@typescript-eslint/eslint-plugin": "2.4.0",
44-
"@typescript-eslint/parser": "2.4.0",
45-
"eslint": "6.5.1",
46-
"eslint-config-airbnb": "18.0.1",
47-
"eslint-plugin-import": "2.18.2",
40+
"@bessonovs/eslint-config": "0.0.6",
41+
"@types/express": "4.17.6",
42+
"@types/jest": "25.2.2",
43+
"@types/node": "14.0.1",
44+
"@typescript-eslint/eslint-plugin": "2.33.0",
45+
"@typescript-eslint/parser": "2.33.0",
46+
"eslint": "7.0.0",
47+
"eslint-config-airbnb": "18.1.0",
48+
"eslint-plugin-import": "2.20.2",
4849
"eslint-plugin-jsx-a11y": "6.2.3",
49-
"eslint-plugin-react": "7.16.0",
50-
"jest": "24.9.0",
50+
"eslint-plugin-react": "7.20.0",
51+
"jest": "26.0.1",
5152
"micro": "9.3.5-canary.3",
52-
"node-mocks-http": "1.8.0",
53-
"path-to-regexp": "3.1.0",
54-
"ts-jest": "24.1.0",
55-
"typescript": "3.6.4"
53+
"node-mocks-http": "1.8.1",
54+
"path-to-regexp": "6.1.0",
55+
"ts-jest": "26.0.0",
56+
"typescript": "3.9.2"
5657
},
5758
"publishConfig": {
5859
"access": "public"

src/__tests__/router.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import {
44
import {
55
createRequest, createResponse,
66
} from 'node-mocks-http'
7-
import pathToRegexp from 'path-to-regexp'
7+
import {
8+
compile, pathToRegexp,
9+
} from 'path-to-regexp'
810
import {
911
MatchedHandler, Router,
1012
} from '../router'
1113
import {
12-
AndMatcher, ExactUrlPathnameMatcher, MethodMatcher,
14+
AndMatcher, EndpointMatcher, ExactUrlPathnameMatcher,
15+
MethodMatcher,
1316
} from '../matchers'
14-
import { EndpointMatcher } from '../matchers/EndpointMatcher'
17+
1518

1619
let router: Router
1720

@@ -58,7 +61,7 @@ it('match POST /test route', () => {
5861
const handler = (
5962
req: IncomingMessage,
6063
res: ServerResponse,
61-
match: {and: [{method: string}, {pathname: string}]}
64+
match: {and: [{method: string}, {pathname: string}]},
6265
) => {
6366
const [{ method }, { pathname }] = match.and
6467
return `matched ${method} ${pathname}`
@@ -94,7 +97,7 @@ it('match POST /group/123 endpoint', () => {
9497
// define an endpoint
9598
const endpoint = ((pattern: string) => ({
9699
pattern: pathToRegexp(pattern),
97-
path: pathToRegexp.compile<{groupId: number}>(pattern),
100+
path: compile<{groupId: number}>(pattern),
98101
}))('/group/:groupId')
99102

100103
router.addRoute({

src/examples/micro.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import http from 'http'
22
import micro, { sendError } from 'micro'
33
import { Router } from '../router'
4-
import { EndpointMatcher } from '../matchers/EndpointMatcher'
5-
import { ExactUrlPathnameMatcher } from '../matchers'
4+
import {
5+
EndpointMatcher, ExactUrlPathnameMatcher,
6+
} from '../matchers'
67

78
/*
89

src/examples/node.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import http from 'http'
22
import { Router } from '../router'
3-
import { EndpointMatcher } from '../matchers/EndpointMatcher'
4-
import { ExactUrlPathnameMatcher } from '../matchers'
3+
import {
4+
EndpointMatcher, ExactUrlPathnameMatcher,
5+
} from '../matchers'
56

67
/*
78

src/matchers/AndMatcher.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import {
22
IncomingMessage, ServerResponse,
33
} from 'http'
44
import {
5-
MatchResult, Matched, isMatched,
6-
} from './MatchResult'
7-
import { Matcher } from './Matcher'
5+
MatchResult, Matched, Matcher, isMatched,
6+
} from '.'
87

98
export type AndMatcherResult<MR1 extends MatchResult, MR2 extends MatchResult> = MatchResult<{
109
and: [Matched<MR1>, Matched<MR2>]

src/matchers/ExactUrlPathnameMatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ implements Matcher<ExactUrlPathnameMatchResult<U>> {
1919
/* istanbul ignore else */
2020
if (req.url !== undefined) {
2121
const { pathname } = Url.parse(req.url)
22-
if (pathname !== undefined && this.urls.indexOf(pathname) >= 0) {
22+
if (pathname !== null && this.urls.indexOf(pathname) >= 0) {
2323
return {
2424
matched: true,
2525
pathname,

src/matchers/Matcher.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
} from 'http'
44
import { MatchResult } from './MatchResult'
55

6+
export type ExtractMatchResult<M> = M extends Matcher<infer MR> ? MR : never
7+
68
export interface Matcher<T extends MatchResult = MatchResult> {
79
match(req: IncomingMessage, res: ServerResponse): T
810
}

src/matchers/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export { OrMatcher, OrMatcherResult } from './OrMatcher'
21
export { AndMatcher, AndMatcherResult } from './AndMatcher'
2+
export { EndpointMatcher } from './EndpointMatcher'
3+
export { ExactQueryMatcher } from './ExactQueryMatcher'
34
export { ExactUrlPathnameMatcher, ExactUrlPathnameMatchResult } from './ExactUrlPathnameMatcher'
4-
export { MatchResult, isMatched, Matched } from './MatchResult'
5-
export { Matcher } from './Matcher'
6-
export { MethodMatcher, MethodMatchResult, Method } from './MethodMatcher'
5+
export type { ExtractMatchResult, Matcher } from './Matcher'
6+
export { isMatched, Matched, MatchResult } from './MatchResult'
7+
export { Method, MethodMatcher, MethodMatchResult } from './MethodMatcher'
8+
export { OrMatcher, OrMatcherResult } from './OrMatcher'
79
export { RegExpUrlMatcher, RegExpUrlMatchResult } from './RegExpUrlMatcher'
8-
export { ExactQueryMatcher } from './ExactQueryMatcher'
9-
export { EndpointMatcher } from './EndpointMatcher'

src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MatchResult, Matched, Matcher, isMatched,
66
} from './matchers'
77

8-
type Handler<MR extends MatchResult> = (
8+
export type Handler<MR extends MatchResult> = (
99
req: IncomingMessage,
1010
res: ServerResponse,
1111
matchResult: Matched<MR>) => any // eslint-disable-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)