Skip to content

Commit c682069

Browse files
committed
WIP: Big Int support (node,deno)
1 parent ae6a7de commit c682069

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/SDK/Language/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getTypeName($type)
2121
switch ($type) {
2222
case self::TYPE_INTEGER:
2323
case self::TYPE_NUMBER:
24-
return 'number';
24+
return 'number | string';
2525
break;
2626
case self::TYPE_ARRAY:
2727
return 'string[]';

templates/node/lib/client.js.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const URL = require('url').URL;
22
const axios = require('axios');
3+
const JSONbig = require("json-bigint")({ storeAsString: true });
34
const FormData = require('form-data');
45
const {{spec.title | caseUcfirst}}Exception = require('./exception.js');
56

@@ -111,6 +112,8 @@ class Client {
111112
headers: headers,
112113
data: (method.toUpperCase() === 'GET' || contentType.startsWith('multipart/form-data')) ? formData : params,
113114
json: (contentType.startsWith('application/json')),
115+
transformResponse: (data) => JSONbig.parse(data),
116+
transformRequest: method.toUpperCase() === 'GET' || contentType.startsWith('multipart/form-data') ? undefined : (data) => JSONbig.stringify(data),
114117
responseType: responseType
115118
};
116119
try {

templates/node/package.json.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"devDependencies": {},
1414
"dependencies": {
1515
"axios": "^0.26.1",
16-
"form-data": "^4.0.0"
16+
"form-data": "^4.0.0",
17+
"json-bigint": "^1.0.0"
1718
}
1819
}

0 commit comments

Comments
 (0)