Skip to content

Commit 62df885

Browse files
authored
max request size (#222)
1 parent e8b0b7d commit 62df885

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

resources/baseResource.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import axiosStatic, { AxiosInstance, AxiosRequestConfig, AxiosRequestHeaders, responseEncoding } from "axios"
22
import { extractUnitError, UnitConfig } from "../types/common"
33

4+
const MAX_REQUEST_SIZE = 20000000
5+
46
export class BaseResource {
57
private resourcePath: string
68
private headers: AxiosRequestHeaders
@@ -34,6 +36,8 @@ export class BaseResource {
3436
protected async httpPatch<T>(path: string, data: DataPayload | { data: DataPayload; }, config?: { headers?: object; params?: object; }): Promise<T> {
3537
const conf = {
3638
headers: this.mergeHeaders(config?.headers),
39+
maxBodyLength: MAX_REQUEST_SIZE,
40+
maxContentLength: MAX_REQUEST_SIZE,
3741
...(config?.params && { params: (config.params) })
3842
}
3943

@@ -52,6 +56,8 @@ export class BaseResource {
5256
protected async httpPost<T>(path: string, data?: DataPayload | { data: object; }, config?: { headers?: object; params?: object; }): Promise<T> {
5357
const conf = {
5458
headers: this.mergeHeaders(config?.headers),
59+
maxBodyLength: MAX_REQUEST_SIZE,
60+
maxContentLength: MAX_REQUEST_SIZE,
5561
...(config?.params && { params: (config.params) })
5662
}
5763

@@ -63,6 +69,8 @@ export class BaseResource {
6369
protected async httpPut<T>(path: string, data: object | Buffer, config?: { headers?: object; params?: object; }): Promise<T> {
6470
const conf = {
6571
headers: this.mergeHeaders(config?.headers),
72+
maxBodyLength: MAX_REQUEST_SIZE,
73+
maxContentLength: MAX_REQUEST_SIZE,
6674
...(config?.params && { params: (config.params) })
6775
}
6876

0 commit comments

Comments
 (0)