Skip to content

Commit ee70132

Browse files
authored
Refactor package to TypeScript (#93)
1 parent 21a5f04 commit ee70132

File tree

16 files changed

+498
-682
lines changed

16 files changed

+498
-682
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
quote_type = single

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 17 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -1,241 +1,26 @@
1-
name: ci
2-
1+
name: CI
32
on:
4-
- pull_request
5-
- push
6-
3+
- push
4+
- pull_request
75
permissions:
86
contents: read
9-
107
jobs:
118
test:
12-
permissions:
13-
checks: write # for coverallsapp/github-action to create new checks
14-
contents: read # for actions/checkout to fetch code
9+
name: Node.js ${{ matrix.node-version }}
1510
runs-on: ubuntu-latest
1611
strategy:
1712
matrix:
18-
name:
19-
- Node.js 0.8
20-
- Node.js 0.10
21-
- Node.js 0.12
22-
- io.js 1.x
23-
- io.js 2.x
24-
- io.js 3.x
25-
- Node.js 4.x
26-
- Node.js 5.x
27-
- Node.js 6.x
28-
- Node.js 7.x
29-
- Node.js 8.x
30-
- Node.js 9.x
31-
- Node.js 10.x
32-
- Node.js 11.x
33-
- Node.js 12.x
34-
- Node.js 13.x
35-
- Node.js 14.x
36-
- Node.js 15.x
37-
- Node.js 16.x
38-
- Node.js 17.x
39-
- Node.js 18.x
40-
- Node.js 19.x
41-
- Node.js 20.x
42-
- Node.js 21.x
43-
- Node.js 22.x
44-
- Node.js 23.x
45-
- Node.js 24.x
46-
- Node.js 25.x
47-
48-
include:
49-
- name: Node.js 0.8
50-
node-version: "0.8"
51-
npm-i: mocha@2.5.3
52-
npm-rm: nyc
53-
54-
- name: Node.js 0.10
55-
node-version: "0.10"
56-
npm-i: mocha@3.5.3 nyc@10.3.2
57-
58-
- name: Node.js 0.12
59-
node-version: "0.12"
60-
npm-i: mocha@3.5.3 nyc@10.3.2
61-
62-
- name: io.js 1.x
63-
node-version: "1.8"
64-
npm-i: mocha@3.5.3 nyc@10.3.2
65-
66-
- name: io.js 2.x
67-
node-version: "2.5"
68-
npm-i: mocha@3.5.3 nyc@10.3.2
69-
70-
- name: io.js 3.x
71-
node-version: "3.3"
72-
npm-i: mocha@3.5.3 nyc@10.3.2
73-
74-
- name: Node.js 4.x
75-
node-version: "4.9"
76-
npm-i: mocha@5.2.0 nyc@11.9.0
77-
78-
- name: Node.js 5.x
79-
node-version: "5.12"
80-
npm-i: mocha@5.2.0 nyc@11.9.0
81-
82-
- name: Node.js 6.x
83-
node-version: "6.17"
84-
npm-i: mocha@6.2.2 nyc@14.1.1
85-
86-
- name: Node.js 7.x
87-
node-version: "7.10"
88-
npm-i: mocha@6.2.2 nyc@14.1.1
89-
90-
- name: Node.js 8.x
91-
node-version: "8.17"
92-
npm-i: mocha@7.1.2 nyc@14.1.1
93-
94-
- name: Node.js 9.x
95-
node-version: "9.11"
96-
npm-i: mocha@7.1.2 nyc@14.1.1
97-
98-
- name: Node.js 10.x
99-
node-version: "10.24"
100-
npm-i: mocha@8.4.0
101-
102-
- name: Node.js 11.x
103-
node-version: "11.15"
104-
npm-i: mocha@8.4.0
105-
106-
- name: Node.js 12.x
107-
node-version: "12.22"
108-
npm-i: mocha@9.2.2
109-
110-
- name: Node.js 13.x
111-
node-version: "13.14"
112-
npm-i: mocha@9.2.2
113-
114-
- name: Node.js 14.x
115-
node-version: "14.21"
116-
117-
- name: Node.js 15.x
118-
node-version: "15.14"
119-
120-
- name: Node.js 16.x
121-
node-version: "16.20"
122-
123-
- name: Node.js 17.x
124-
node-version: "17.9"
125-
126-
- name: Node.js 18.x
127-
node-version: "18.20"
128-
129-
- name: Node.js 19.x
130-
node-version: "19.9"
131-
132-
- name: Node.js 20.x
133-
node-version: "20.13"
134-
135-
- name: Node.js 21.x
136-
node-version: "21.7"
137-
138-
- name: Node.js 22.x
139-
node-version: "22.1"
140-
141-
- name: Node.js 23.x
142-
node-version: "23"
143-
144-
- name: Node.js 24.x
145-
node-version: "24"
146-
147-
- name: Node.js 25.x
148-
node-version: "25"
149-
13+
node-version:
14+
- 18
15+
- '*'
15016
steps:
151-
- uses: actions/checkout@v6
152-
153-
- name: Install Node.js ${{ matrix.node-version }}
154-
shell: bash -eo pipefail -l {0}
155-
run: |
156-
nvm install --default ${{ matrix.node-version }}
157-
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
158-
nvm install --alias=npm 0.10
159-
nvm use ${{ matrix.node-version }}
160-
if [[ "$(npm -v)" == 1.1.* ]]; then
161-
nvm exec npm npm install -g npm@1.1
162-
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
163-
else
164-
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
165-
fi
166-
npm config set strict-ssl false
167-
fi
168-
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
169-
170-
- name: Configure npm
171-
run: |
172-
if [[ "$(npm config get package-lock)" == "true" ]]; then
173-
npm config set package-lock false
174-
else
175-
npm config set shrinkwrap false
176-
fi
177-
178-
- name: Remove npm module(s) ${{ matrix.npm-rm }}
179-
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
180-
if: matrix.npm-rm != ''
181-
182-
- name: Install npm module(s) ${{ matrix.npm-i }}
183-
run: npm install --save-dev ${{ matrix.npm-i }}
184-
if: matrix.npm-i != ''
185-
186-
- name: Setup Node.js version-specific dependencies
187-
shell: bash
188-
run: |
189-
# eslint for linting
190-
# - remove on Node.js < 12
191-
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
192-
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
193-
grep -E '^eslint(-|$)' | \
194-
sort -r | \
195-
xargs -n1 npm rm --silent --save-dev
196-
fi
197-
198-
- name: Install Node.js dependencies
199-
run: npm install
200-
201-
- name: List environment
202-
id: list_env
203-
shell: bash
204-
run: |
205-
echo "node@$(node -v)"
206-
echo "npm@$(npm -v)"
207-
npm -s ls ||:
208-
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
209-
210-
- name: Run tests
211-
shell: bash
212-
run: |
213-
if npm -ps ls nyc | grep -q nyc; then
214-
npm run test-ci
215-
else
216-
npm test
217-
fi
218-
219-
- name: Lint code
220-
if: steps.list_env.outputs.eslint != ''
221-
run: npm run lint
222-
223-
- name: Collect code coverage
224-
uses: coverallsapp/github-action@master
225-
if: steps.list_env.outputs.nyc != ''
226-
with:
227-
github-token: ${{ secrets.GITHUB_TOKEN }}
228-
flag-name: run-${{ matrix.test_number }}
229-
parallel: true
230-
231-
coverage:
232-
permissions:
233-
checks: write # for coverallsapp/github-action to create new checks
234-
needs: test
235-
runs-on: ubuntu-latest
236-
steps:
237-
- name: Upload code coverage
238-
uses: coverallsapp/github-action@master
239-
with:
240-
github-token: ${{ secrets.GITHUB_TOKEN }}
241-
parallel-finished: true
17+
- uses: actions/checkout@v6
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- run: npm install
22+
- run: npm test
23+
- uses: codecov/codecov-action@v5
24+
with:
25+
name: Node.js ${{ matrix.node-version }}
26+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ coverage
22
node_modules
33
npm-debug.log
44
package-lock.json
5+
dist/
6+
*.tsbuildinfo

HISTORY.md

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,43 @@
1-
2.0.1 / 2018-09-19
2-
==================
1+
# 2.0.1 / 2018-09-19
32

4-
* deps: safe-buffer@5.1.2
3+
- deps: safe-buffer@5.1.2
54

6-
2.0.0 / 2017-09-12
7-
==================
5+
# 2.0.0 / 2017-09-12
86

9-
* Drop support for Node.js below 0.8
10-
* Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)`
11-
* Use `safe-buffer` for improved Buffer API
7+
- Drop support for Node.js below 0.8
8+
- Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)`
9+
- Use `safe-buffer` for improved Buffer API
1210

13-
1.1.0 / 2016-11-18
14-
==================
11+
# 1.1.0 / 2016-11-18
1512

16-
* Add `auth.parse` for low-level string parsing
13+
- Add `auth.parse` for low-level string parsing
1714

18-
1.0.4 / 2016-05-10
19-
==================
15+
# 1.0.4 / 2016-05-10
2016

21-
* Improve error message when `req` argument is not an object
22-
* Improve error message when `req` missing `headers` property
17+
- Improve error message when `req` argument is not an object
18+
- Improve error message when `req` missing `headers` property
2319

24-
1.0.3 / 2015-07-01
25-
==================
20+
# 1.0.3 / 2015-07-01
2621

27-
* Fix regression accepting a Koa context
22+
- Fix regression accepting a Koa context
2823

29-
1.0.2 / 2015-06-12
30-
==================
24+
# 1.0.2 / 2015-06-12
3125

32-
* Improve error message when `req` argument missing
33-
* perf: enable strict mode
34-
* perf: hoist regular expression
35-
* perf: parse with regular expressions
36-
* perf: remove argument reassignment
26+
- Improve error message when `req` argument missing
27+
- perf: enable strict mode
28+
- perf: hoist regular expression
29+
- perf: parse with regular expressions
30+
- perf: remove argument reassignment
3731

38-
1.0.1 / 2015-05-04
39-
==================
32+
# 1.0.1 / 2015-05-04
4033

41-
* Update readme
34+
- Update readme
4235

43-
1.0.0 / 2014-07-01
44-
==================
36+
# 1.0.0 / 2014-07-01
4537

46-
* Support empty password
47-
* Support empty username
38+
- Support empty password
39+
- Support empty username
4840

49-
0.0.1 / 2013-11-30
50-
==================
41+
# 0.0.1 / 2013-11-30
5142

52-
* Initial release
43+
- Initial release

0 commit comments

Comments
 (0)