Skip to content

Commit 92906de

Browse files
authored
Merge pull request #279 from anzharip/dev
build: bump busboy and @types/busboy
2 parents 78c380a + c962530 commit 92906de

File tree

7 files changed

+82
-68
lines changed

7 files changed

+82
-68
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Node.js Build & Test
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
pull_request:
7+
branches: [dev]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [14.x, 16.x, 17.x ]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm ci
24+
- run: npm run build --if-present
25+
- run: npm run test:cov
26+
- name: Upload coverage to Codecov
27+
uses: codecov/codecov-action@v1
28+
with:
29+
token: ${{ secrets.CODECOV_TOKEN }}
30+
directory: ./coverage/
31+
flags: unittests
32+
name: codecov-umbrella
33+
fail_ci_if_error: true
34+
path_to_write_report: ./coverage/codecov_report.txt
35+
verbose: true

.github/workflows/build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [14.x, 15.x]
15+
node-version: [14.x, 16.x, 17.x ]
1616

1717
steps:
1818
- uses: actions/checkout@v2

package-lock.json

Lines changed: 24 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
},
5454
"dependencies": {
5555
"@azure/functions": "^3.0.0",
56-
"@types/busboy": "^0.3.1",
56+
"@types/busboy": "^1.3.0",
5757
"@types/node": "^17.0.0",
58-
"busboy": "^0.3.1"
58+
"busboy": "^1.4.0"
5959
}
6060
}

src/index.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ParsedField } from "./types/parsed-field.type";
44
import { ParsedFile } from "./types/parsed-file.type";
55
import { ParsedMultipartFormData } from "./types/parsed-multipart-form-data.type";
66
import { Config } from "./types/config.type";
7+
import { IncomingHttpHeaders } from "http";
78

89
export default async function parseMultipartFormData(
910
request: HttpRequest,
@@ -16,34 +17,34 @@ export default async function parseMultipartFormData(
1617

1718
let busboy;
1819
if (options) {
19-
busboy = new Busboy({
20-
headers: (request.headers as unknown) as Busboy.BusboyHeaders,
20+
busboy = Busboy({
21+
headers: (request.headers as unknown) as IncomingHttpHeaders,
2122
...options,
2223
});
2324
} else {
24-
busboy = new Busboy({
25-
headers: (request.headers as unknown) as Busboy.BusboyHeaders,
25+
busboy = Busboy({
26+
headers: (request.headers as unknown) as IncomingHttpHeaders,
2627
});
2728
}
2829

2930
busboy.on(
3031
"file",
31-
function (fieldname, file, filename, encoding, mimetype) {
32+
function (name, stream, { filename, encoding, mimeType }) {
3233
const arrayBuffer: Buffer[] = [];
33-
file.on("data", function (data) {
34+
stream.on("data", function (data) {
3435
arrayBuffer.push(data);
3536
});
3637

37-
file.on("end", function () {
38+
stream.on("end", function () {
3839
const bufferFile = Buffer.concat(arrayBuffer);
3940
files.push(
4041
new Promise((resolve) => {
4142
resolve({
42-
fieldname,
43+
name,
4344
bufferFile,
4445
filename,
4546
encoding,
46-
mimetype,
47+
mimeType,
4748
});
4849
})
4950
);
@@ -54,22 +55,19 @@ export default async function parseMultipartFormData(
5455
busboy.on(
5556
"field",
5657
function (
57-
fieldname,
58+
name,
5859
value,
59-
fieldnameTruncated,
60-
valueTruncated,
61-
encoding,
62-
mimetype
60+
{ nameTruncated, valueTruncated, encoding, mimeType }
6361
) {
6462
fields.push(
6563
new Promise((resolve) => {
6664
resolve({
67-
fieldname,
65+
name,
6866
value,
69-
fieldnameTruncated,
67+
nameTruncated,
7068
valueTruncated,
7169
encoding,
72-
mimetype,
70+
mimeType,
7371
});
7472
})
7573
);

src/types/parsed-field.type.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export type ParsedField = {
2-
fieldname: string;
2+
name: string;
33
value: any;
4-
fieldnameTruncated: boolean;
4+
nameTruncated: boolean;
55
valueTruncated: boolean;
66
encoding: string;
7-
mimetype: string;
7+
mimeType: string;
88
};

src/types/parsed-file.type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export type ParsedFile = {
2-
fieldname: string;
2+
name: string;
33
bufferFile: Buffer;
44
filename: string;
55
encoding: string;
6-
mimetype: string;
6+
mimeType: string;
77
};

0 commit comments

Comments
 (0)