Skip to content

Commit

Permalink
Merge pull request #279 from anzharip/dev
Browse files Browse the repository at this point in the history
build: bump busboy and @types/busboy
  • Loading branch information
anzharip authored Feb 1, 2022
2 parents 78c380a + c962530 commit 92906de
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 68 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-and-test-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Node.js Build & Test

on:
push:
branches: [dev]
pull_request:
branches: [dev]

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 17.x ]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm run test:cov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 15.x]
node-version: [14.x, 16.x, 17.x ]

steps:
- uses: actions/checkout@v2
Expand Down
67 changes: 24 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
},
"dependencies": {
"@azure/functions": "^3.0.0",
"@types/busboy": "^0.3.1",
"@types/busboy": "^1.3.0",
"@types/node": "^17.0.0",
"busboy": "^0.3.1"
"busboy": "^1.4.0"
}
}
32 changes: 15 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ParsedField } from "./types/parsed-field.type";
import { ParsedFile } from "./types/parsed-file.type";
import { ParsedMultipartFormData } from "./types/parsed-multipart-form-data.type";
import { Config } from "./types/config.type";
import { IncomingHttpHeaders } from "http";

export default async function parseMultipartFormData(
request: HttpRequest,
Expand All @@ -16,34 +17,34 @@ export default async function parseMultipartFormData(

let busboy;
if (options) {
busboy = new Busboy({
headers: (request.headers as unknown) as Busboy.BusboyHeaders,
busboy = Busboy({
headers: (request.headers as unknown) as IncomingHttpHeaders,
...options,
});
} else {
busboy = new Busboy({
headers: (request.headers as unknown) as Busboy.BusboyHeaders,
busboy = Busboy({
headers: (request.headers as unknown) as IncomingHttpHeaders,
});
}

busboy.on(
"file",
function (fieldname, file, filename, encoding, mimetype) {
function (name, stream, { filename, encoding, mimeType }) {
const arrayBuffer: Buffer[] = [];
file.on("data", function (data) {
stream.on("data", function (data) {
arrayBuffer.push(data);
});

file.on("end", function () {
stream.on("end", function () {
const bufferFile = Buffer.concat(arrayBuffer);
files.push(
new Promise((resolve) => {
resolve({
fieldname,
name,
bufferFile,
filename,
encoding,
mimetype,
mimeType,
});
})
);
Expand All @@ -54,22 +55,19 @@ export default async function parseMultipartFormData(
busboy.on(
"field",
function (
fieldname,
name,
value,
fieldnameTruncated,
valueTruncated,
encoding,
mimetype
{ nameTruncated, valueTruncated, encoding, mimeType }
) {
fields.push(
new Promise((resolve) => {
resolve({
fieldname,
name,
value,
fieldnameTruncated,
nameTruncated,
valueTruncated,
encoding,
mimetype,
mimeType,
});
})
);
Expand Down
6 changes: 3 additions & 3 deletions src/types/parsed-field.type.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type ParsedField = {
fieldname: string;
name: string;
value: any;
fieldnameTruncated: boolean;
nameTruncated: boolean;
valueTruncated: boolean;
encoding: string;
mimetype: string;
mimeType: string;
};
4 changes: 2 additions & 2 deletions src/types/parsed-file.type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type ParsedFile = {
fieldname: string;
name: string;
bufferFile: Buffer;
filename: string;
encoding: string;
mimetype: string;
mimeType: string;
};

0 comments on commit 92906de

Please sign in to comment.