list-fetch
Advanced tools
Comparing version 30.0.2 to 30.0.3
36
index.js
@@ -127,4 +127,3 @@ module.exports = async function makeBTFetch (opts = {}) { | ||
if(reqHeaders.has('x-data') || searchParams.has('x-data')){ | ||
const parseTheData = JSON.parse(reqHeaders.get('x-data') || searchParams.get('x-data')) | ||
const torrentData = await app.torrentData(parseTheData) | ||
const torrentData = await app.torrentData(JSON.parse(reqHeaders.get('x-data') || searchParams.get('x-data'))) | ||
const useHeaders = {} | ||
@@ -156,9 +155,3 @@ const useCount = torrentData.length | ||
} else { | ||
const checkMain = await app.checkUserData(mid.mainPath) | ||
const useHeaders = {} | ||
if(checkMain.stat.type === 'folder'){ | ||
useHeaders['X-Count'] = checkMain.folder.length | ||
} | ||
useHeaders['X-Length'] = checkMain.stat.size | ||
return sendTheData(signal, {status: 200, headers: useHeaders, body: ''}) | ||
return sendTheData(signal, {status: 400, headers: {'X-Status': 'can not have a path'}, body: ''}) | ||
} | ||
@@ -227,18 +220,3 @@ } else { | ||
} else { | ||
const checkMain = await app.checkUserData(mid.mainPath) | ||
const useHeaders = {} | ||
if(checkMain.stat.type === 'folder'){ | ||
useHeaders['X-length'] = checkMain.stat.size | ||
useHeaders['X-Count'] = checkMain.folder.length | ||
return sendTheData(signal, {status: 200, headers: useHeaders, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div><h1>Directory</h1><p><a href='../'>..</a></p>${checkMain.folder.map((data) => {return `<p>${data}</p>`})}</div></body></html>` : JSON.stringify(checkMain.folder)}) | ||
} else if(checkMain.stat.type === 'file'){ | ||
useHeaders['X-length'] = checkMain.stat.size | ||
useHeaders['Content-Type'] = getMimeType(mid.mainPath) | ||
useHeaders['X-Link'] = `bt://${mid.mainHost}${mid.mainPath}` | ||
useHeaders['Link'] = `<bt://${mid.mainHost}${mid.mainPath}>; rel="canonical"` | ||
useHeaders['Content-Length'] = useHeaders['X-length'] | ||
return sendTheData(signal, {status: 200, headers: useHeaders, body: fs.createReadStream(checkMain.file)}) | ||
} else { | ||
return sendTheData(signal, {status: 400, headers: mainRes, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div><p>could not find the data</p></div></body></html>` : JSON.stringify('could not find the data')}) | ||
} | ||
return sendTheData(signal, { status: 400, headers: mainRes, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div><p>can not have a path</p></div></body></html>` : JSON.stringify('can not have a path') }) | ||
} | ||
@@ -358,9 +336,3 @@ } else { | ||
if (mid.mainQuery) { | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { | ||
...useOpt, | ||
count: reqHeaders.has('x-version') || searchParams.has('x-version') ? Number(reqHeaders.get('x-version') || searchParams.get('x-version')) : null | ||
} | ||
const torrentData = await app.trashUserData(mid.mainPath) | ||
return sendTheData(signal, { status: 200, headers: { 'Status': useOpts.count ? 'true': 'false', 'Content-Type': mainRes }, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div><p>${torrentData}</p></div></body></html>` : JSON.stringify(torrentData) }) | ||
return sendTheData(signal, { status: 400, headers: mainRes, body: mainReq ? `<html><head><title>${mid.mainLink}</title></head><body><div><p>can not have a path</p></div></body></html>` : JSON.stringify('can not have a path') }) | ||
} else { | ||
@@ -367,0 +339,0 @@ const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} |
{ | ||
"name": "list-fetch", | ||
"version": "30.0.2", | ||
"version": "30.0.3", | ||
"description": "coming soon", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"range-parser": "^1.2.1", | ||
"torrentz": "^11.0.0" | ||
"torrentz": "^11.0.1" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
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
26697
356
Updatedtorrentz@^11.0.1