ipfs-http-response
Advanced tools
Comparing version 4.0.2-dfc43d4e.0 to 5.0.0-5f73ecad
{ | ||
"name": "ipfs-http-response", | ||
"version": "4.0.2-dfc43d4e.0", | ||
"version": "5.0.0-5f73ecad", | ||
"description": "Creates an HTTP response from an IPFS Hash", | ||
@@ -71,7 +71,5 @@ "author": "Vasco Santos <vasco.santos@moxy.studio>", | ||
"ejs": "^3.1.6", | ||
"file-type": "^17.1.1", | ||
"filesize": "^9.0.11", | ||
"it-buffer": "^0.1.1", | ||
"it-concat": "^2.0.0", | ||
"it-map": "^1.0.6", | ||
"file-type": "^18.0.0", | ||
"filesize": "^10.0.5", | ||
"it-map": "^2.0.0", | ||
"it-reader": "^6.0.1", | ||
@@ -85,8 +83,8 @@ "it-to-stream": "^1.0.0", | ||
"@types/mime-types": "^2.1.1", | ||
"aegir": "^37.0.11", | ||
"aegir": "^37.11.0", | ||
"get-stream": "^6.0.0", | ||
"ipfs-core": "^0.16.2-dfc43d4e.0", | ||
"ipfs-core": "0.17.0-5f73ecad", | ||
"ipfsd-ctl": "^12.0.3", | ||
"it-all": "^1.0.4", | ||
"uint8arrays": "^3.0.0" | ||
"it-all": "^2.0.0", | ||
"uint8arrays": "^4.0.2" | ||
}, | ||
@@ -96,4 +94,3 @@ "browser": { | ||
"fs": false | ||
}, | ||
"gitHead": "4eac92ae987d3ba6007c4742456913c865a06857" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import filesize from 'filesize' | ||
import { filesize } from 'filesize' | ||
import style from './style.js' | ||
@@ -3,0 +3,0 @@ import { cidArray } from '../utils/path.js' |
@@ -1,8 +0,5 @@ | ||
/* global Response, Blob */ | ||
/* global Response */ | ||
// @ts-expect-error no types | ||
import toStream from 'it-to-stream' | ||
import concat from 'it-concat' | ||
// @ts-expect-error no types | ||
import toBuffer from 'it-buffer' | ||
import { logger } from '@libp2p/logger' | ||
@@ -74,21 +71,7 @@ import * as ipfsResolver from './resolver.js' | ||
const { source, contentType } = await detectContentType(ipfsPath, ipfsNode.cat(resolvedData.cid)) | ||
const responseStream = toStream.readable(source) | ||
if (typeof Blob === 'undefined') { | ||
const responseStream = toStream.readable(toBuffer(source)) | ||
return contentType | ||
? new Response(responseStream, getHeader(200, 'OK', { 'Content-Type': contentType })) | ||
: new Response(responseStream, getHeader()) | ||
} | ||
try { | ||
const data = await concat(source) | ||
const blob = new Blob([data.slice()]) | ||
return contentType | ||
? new Response(blob, getHeader(200, 'OK', { 'Content-Type': contentType })) | ||
: new Response(blob, getHeader()) | ||
} catch (/** @type {any} */ err) { | ||
return new Response(err.toString(), getHeader(500, 'Error fetching the file')) | ||
} | ||
return contentType | ||
? new Response(responseStream, getHeader(200, 'OK', { 'Content-Type': contentType })) | ||
: new Response(responseStream, getHeader()) | ||
} catch (/** @type {any} */ error) { | ||
@@ -95,0 +78,0 @@ log(error) |
@@ -42,3 +42,5 @@ import { fileTypeFromBuffer } from 'file-type' | ||
} catch (/** @type {any} */ err) { | ||
if (err.code !== 'ERR_UNDER_READ') throw err | ||
if (err.code !== 'ERR_UNDER_READ') { | ||
throw err | ||
} | ||
@@ -45,0 +47,0 @@ // not enough bytes for sniffing, just yield the data |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9
226824
1215
+ Addedfile-type@18.7.0(transitive)
+ Addedfilesize@10.1.4(transitive)
+ Addedit-map@2.0.1(transitive)
- Removedit-buffer@^0.1.1
- Removedit-concat@^2.0.0
- Removedbl@5.1.0(transitive)
- Removedfile-type@17.1.6(transitive)
- Removedfilesize@9.0.11(transitive)
- Removedit-buffer@0.1.3(transitive)
- Removedit-concat@2.0.0(transitive)
- Removedit-map@1.0.6(transitive)
Updatedfile-type@^18.0.0
Updatedfilesize@^10.0.5
Updatedit-map@^2.0.0