diff --git a/package-lock.json b/package-lock.json index a5272b4..f94319e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "SEE LICENSE IN LICENSE", "dependencies": { "@azure/functions": "^1.2.3", - "@types/busboy": "^0.2.3", + "@types/busboy": "^0.3.1", "@types/node": "^16.0.0", "busboy": "^0.3.1" }, @@ -1060,9 +1060,9 @@ } }, "node_modules/@types/busboy": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-0.2.4.tgz", - "integrity": "sha512-f+ZCVjlcN8JW/zf3iR0GqO4gjOUlltMTtZjn+YR1mlK+MVu6esTiIecO0/GQlmYQPQLdBnc7+5vG3Xb+SkvFLw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-8BPLNy4x+7lbTOGkAyUIZrrPEZ7WzbO7YlVGMf9EZi9J9mqILEkYbt/kgVWQ7fizOISo1hM/7cAsWVTa7EhQDg==", "dependencies": { "@types/node": "*" } @@ -6886,9 +6886,9 @@ } }, "@types/busboy": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-0.2.4.tgz", - "integrity": "sha512-f+ZCVjlcN8JW/zf3iR0GqO4gjOUlltMTtZjn+YR1mlK+MVu6esTiIecO0/GQlmYQPQLdBnc7+5vG3Xb+SkvFLw==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-8BPLNy4x+7lbTOGkAyUIZrrPEZ7WzbO7YlVGMf9EZi9J9mqILEkYbt/kgVWQ7fizOISo1hM/7cAsWVTa7EhQDg==", "requires": { "@types/node": "*" } diff --git a/package.json b/package.json index 489f32f..5d22dd7 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ }, "dependencies": { "@azure/functions": "^1.2.3", - "@types/busboy": "^0.2.3", + "@types/busboy": "^0.3.1", "@types/node": "^16.0.0", "busboy": "^0.3.1" } diff --git a/src/index.ts b/src/index.ts index ac9fbb1..c2ca860 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import { ParsedMultipartFormData } from "./types/parsed-multipart-form-data.type import { Config } from "./types/config.type"; export default async function parseMultipartFormData( - request: HttpRequest, + request: HttpRequest & { headers: { "content-type": string } }, options?: Config ): Promise { return new Promise((resolve, reject) => { diff --git a/test/index.spec.ts b/test/index.spec.ts index 1e4c4fd..f12ac78 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -4,7 +4,7 @@ import fs from "fs"; import parseMultipartFormData from "../src/index"; describe("index.js", () => { - let request: HttpRequest; + let request: HttpRequest & { headers: { "content-type": string } }; beforeEach(async () => { const file1 = fs.readFileSync("test/fixture/dummy-data.json"); @@ -18,7 +18,7 @@ describe("index.js", () => { method: "POST", url: "http://localhost:7071/api/script/mongo-replace-collection", headers: { - ...body.getHeaders(), + ...(body.getHeaders() as FormData.Headers & { "content-type": string }), }, body: body.getBuffer(), query: {}, @@ -44,7 +44,7 @@ describe("index.js", () => { }); it("should reject the promise due to missing headers", async () => { - request.headers = {}; + request.headers = {} as FormData.Headers & { "content-type": string }; expect(async () => { await parseMultipartFormData(request); }).rejects.toThrow();