11import axiosStatic , { AxiosInstance , AxiosRequestConfig , AxiosRequestHeaders , responseEncoding } from "axios"
22import { extractUnitError , UnitConfig } from "../types/common"
33
4+ const MAX_REQUEST_SIZE = 20000000
5+
46export 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