feat: update pinCid function to include response type and body size limits; bump version to 1.4.2

This commit is contained in:
besoeasy
2026-01-05 21:36:00 +05:30
parent d183aa51b4
commit 6cfbbd8a17
3 changed files with 11 additions and 8 deletions

View File

@@ -59,11 +59,14 @@ const pinCid = async (cid) => {
console.log(`[IPFS] Trying to fetch CID ${cid.slice(0, 12)}..., using ${peerCount} peers`);
// Fire-and-forget: Start pin in background without waiting
const endpoint = `${IPFS_API}/api/v0/pin/add?arg=${encodeURIComponent(cid)}&recursive=true&progress=true`;
// Start the pin operation but don't await it
axios.post(endpoint, null, {
timeout: 3 * 60 * 60 * 1000 // 3 hours
const endpoint = `${IPFS_API}/api/v0/pin/add?arg=${encodeURIComponent(cid)}&recursive=true`;
// Start the pin operation but don't await it (cap body size to avoid buffer growth)
axios.post(endpoint, null, {
timeout: 3 * 60 * 60 * 1000, // 3 hours
responseType: "json",
maxContentLength: 1024 * 1024, // 1 MB safety cap
maxBodyLength: 1024 * 1024,
}).then((pinResponse) => {
if (pinResponse.data && pinResponse.data.Pins) {
console.log(`[IPFS-API] PIN_COMPLETED cid=${cid}`);

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "file-drop",
"version": "1.4.1",
"version": "1.4.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "file-drop",
"version": "1.4.1",
"version": "1.4.2",
"license": "ISC",
"dependencies": {
"axios": "^1.8.4",

View File

@@ -1,6 +1,6 @@
{
"name": "file-drop",
"version": "1.4.1",
"version": "1.4.2",
"description": "file drop",
"main": "app.js",
"scripts": {