Skip to content

Commit 3fd773e

Browse files
committed
initial commit
0 parents  commit 3fd773e

34 files changed

Lines changed: 1333 additions & 0 deletions

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
jest: true,
6+
},
7+
plugins: [
8+
'@typescript-eslint',
9+
],
10+
extends: [
11+
'airbnb',
12+
'plugin:@typescript-eslint/recommended',
13+
],
14+
parser: '@typescript-eslint/parser',
15+
rules: {
16+
'arrow-body-style': 'off',
17+
'lines-between-class-members': 'off',
18+
'implicit-arrow-linebreak': 'off',
19+
'no-console': 'error',
20+
'no-trailing-spaces': 'error',
21+
'no-restricted-syntax': 'off',
22+
'indent': [
23+
'error',
24+
'tab',
25+
],
26+
'object-curly-newline': [
27+
'error',
28+
{
29+
ImportDeclaration: {
30+
minProperties: 2,
31+
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+
}
76+
],
77+
'@typescript-eslint/indent': [
78+
'error',
79+
'tab'
80+
],
81+
'import/prefer-default-export': 'off',
82+
'import/no-default-export': 'error',
83+
'import/no-unresolved': 'off',
84+
'import/no-useless-path-segments': 'error',
85+
'import/no-cycle': 'error',
86+
// doesn't work for central devDependencies
87+
'import/no-extraneous-dependencies': 'off',
88+
},
89+
overrides: [
90+
{
91+
files: ['**/*.js'],
92+
rules: {
93+
'@typescript-eslint/no-var-requires': 'off',
94+
'@typescript-eslint/explicit-function-return-type': 'off'
95+
},
96+
},
97+
{
98+
files: ['**/__tests__/**'],
99+
rules: {
100+
'@typescript-eslint/explicit-function-return-type': 'off',
101+
}
102+
},
103+
{
104+
files: ['**/*.ts', '**/*.d.ts'],
105+
rules: {
106+
indent: 'off', // ts has own rule: @typescript-eslint/indent
107+
'no-useless-constructor': 'off',
108+
},
109+
},
110+
]
111+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
pnpm-debug.log

.npmignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage/
2+
.eslintignore
3+
.eslintrc.js
4+
.npmignore
5+
.nvmrc
6+
.travis/
7+
.travis.yml
8+
jest.config.js
9+
tsconfig.json
10+
src/
11+
**/__tests__/**
12+
**/examples/**

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
save-exact = true
2+
package-lock = false

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v12.12.0

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: node_js
2+
3+
cache:
4+
npm: false
5+
6+
before_install:
7+
- curl -L https://unpkg.com/@pnpm/self-installer | node
8+
9+
install:
10+
- pnpm install
11+
12+
script:
13+
- |
14+
pnpm run test && pnpm run lint && pnpm run build
15+
16+
deploy:
17+
- provider: npm
18+
edge: true
19+
skip_cleanup: true
20+
api_key:
21+
secure: GuZ4V8x2m2GtduukJh3rpaezIplvjOcsUy14fui1XrC3tQy5w52cQvl/04tqWyWNCdxTTQttENaH4POY6hG/5192BhPFNkzBW8k6luL2ktWt+DWMWMwtdnt9ex0X+LDHKNyoMZ+YgrOwPaV4UcxTDG8K7+0Q3yDrIJaN4VQJNLm1iT4CRJUibHf6fhHXYbCk0Tr1niy1tNPog1kkFUEr3D4hy86WbuuBdp3m4QhEaqKZkbfyjZoSKlCAZtBL5bjbTLA7h5GZQFqsT2vR9quUwFy7Xo/3wFWEfdJyoxgrlnU1QZt1WVfDx6iMRImOA0O9u3mm0FMm4J9yAUdzuZq+47iapJSpyC2ctzEIrLdrgnXUrklLVl10xEMEGHtdPKJ5a31KG3iXfO7ENfLRNXY+1IqTKaLCjMjpCR0TRO5zvL3K5Zn4tHaU343FKowKmnhKWBFveGb66dmSM2QslaULYvB1AWLDsc2fwrbsSocpjmK3Ab5RzU1PG73Yv65i6u70tpTFDAj3+uICEjzbreMhvzl6QSOdFBGrCRn7R6/zaRL4pNX/H2AZlTIDP9D2XaFQC0B02H1+1u34ybFogR624UXFK8i28Cu/ei6tgjrFZjcJBl+LVfBiA0N56cnYpU3yqO/jat89f6vunwMPCYC7kb6cI90Cx3GoUOQtzJvNL/I=
22+
email:
23+
secure: BOupNyUZssjnIvETZoGly9D+LVj9kQhRv89VCzLsFQV2nvZDNhBNGWlLZAqCrbZh6rXuBN0oM3DpfzTb9HehBVDdevr6KdlYwm9jhauL6XXNkgKMbooVikF5OtlU64i3p2KkozSwYkxcn8xLYIp9FwqDIobs/9obzVJRqz+1AKIfAVb6BFjSv6Pp6Y4AawS6PRM9/k/kYYXoQc9ivVrOi+CXUL8/UPS7xURTxDmkWMp4PMRT51hW7Yz3J0EpeUE4nxgQPqHuqv3cz+nlckR+lSI2QPokBVM2+tUc1KJhAKzAjXq0DphnAM/qnZIXBfOukpd6SAzjhRs0UZYfJ/2xroocGZv9yLjrVjiaXYcZmh6X48Lcxdl/3/SJwKfNRG4L+hI04/wEkjBckYnMZ6flmvvlsEWpgt2mVsgqqR/6u39cYggFzhE1km1cf+vWIzNSTTNdKsNSwkanT1r+5SoKsXxxPqQbhWNXh+mUFqWi30vlNbDGyd7O7ckzXgXGp1iq57wjXQcYQSkAsFZhwN4ZAfPMf3seIRU500+j2Ahn+WM1rurowKyoYBeQJ45Ab1cY3ZdsRAo3eGec1EviCWwLfbqJgFP9T3XQoNrj2NbdsFUa1Xrm9Fs5Ge+dxnRHokj4zFJIM0mktPpqe4psRLdtP17LzhkDGPU1K8FmxPXai/E=
24+
on:
25+
repo: Bessonov/node-http-router
26+
tags: true
27+
condition: "$TRAVIS_PULL_REQUEST = false"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Anton Bessonov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Router for Node.js, micro and others
2+
====================================
3+
4+
[![Project is](https://img.shields.io/badge/Project%20is-fantastic-ff69b4.svg)](https://github.com/Bessonov/node-http-router)
5+
[![Build Status](https://api.travis-ci.org/Bessonov/node-http-router.svg?branch=master)](https://travis-ci.org/Bessonov/node-http-router)
6+
[![License](http://img.shields.io/:license-MIT-blue.svg)](https://raw.githubusercontent.com/Bessonov/node-http-router/master/LICENSE)
7+
8+
This router is intended to be used with native node http interface. Features:
9+
- Written in TypeScript with focus on type safety.
10+
- Extensible via [`Matcher`](src/matchers/Matcher.ts) and [`MatchResult`](src/matchers/MatchResult.ts) interfaces.
11+
- Works with [native node http server](https://nodejs.org/api/http.html#http_class_http_server) ([example](src/examples/node.ts)).
12+
- Works with [micro](https://github.com/zeit/micro) ([example](src/examples/micro.ts)).
13+
- Offers a set of matchers:
14+
- `AndMatcher` and `OrMatcher`
15+
- `ExactQueryMatcher`
16+
- Convenient `EndpointMatcher`
17+
- `ExactUrlPathnameMatcher`
18+
- `MethodMatcher`
19+
- Powerful `RegExpUrlMatcher`
20+
- Can be used with [path-to-regexp](https://github.com/pillarjs/path-to-regexp).
21+
- Work with another servers? Tell it me!
22+
23+
License
24+
-------
25+
26+
The MIT License (MIT)
27+
28+
Copyright (c) 2019, Anton Bessonov
29+
30+
Permission is hereby granted, free of charge, to any person obtaining a copy
31+
of this software and associated documentation files (the "Software"), to deal
32+
in the Software without restriction, including without limitation the rights
33+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34+
copies of the Software, and to permit persons to whom the Software is
35+
furnished to do so, subject to the following conditions:
36+
37+
The above copyright notice and this permission notice shall be included in
38+
all copies or substantial portions of the Software.
39+
40+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
46+
THE SOFTWARE.

jest.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { defaults } = require('jest-config')
2+
3+
module.exports = {
4+
roots: ['<rootDir>/src'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest',
7+
},
8+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
9+
testPathIgnorePatterns: ['/node_modules/'],
10+
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
11+
coverageThreshold: {
12+
global: {
13+
statements: 100,
14+
branches: 100,
15+
functions: 100,
16+
lines: 100,
17+
},
18+
},
19+
// https://github.com/kulshekhar/ts-jest/issues/823#issuecomment-515529012
20+
globals: {
21+
'ts-jest': {
22+
packageJson: 'package.json',
23+
},
24+
},
25+
}

0 commit comments

Comments
 (0)