list-fetch
Advanced tools
Comparing version 29.0.8 to 30.0.0
33
index.js
@@ -164,3 +164,4 @@ module.exports = async function makeBTFetch (opts = {}) { | ||
} else { | ||
const useOpts = { timeout: reqHeaders.has('x-timer') || searchParams.has('x-timer') ? reqHeaders.get('x-timer') !== '0' || searchParams.get('x-timer') !== '0' ? Number(reqHeaders.get('x-timer') || searchParams.get('x-timer')) * 1000 : undefined : btTimeout } | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { ...useOpt, timeout: reqHeaders.has('x-timer') || searchParams.has('x-timer') ? reqHeaders.get('x-timer') !== '0' || searchParams.get('x-timer') !== '0' ? Number(reqHeaders.get('x-timer') || searchParams.get('x-timer')) * 1000 : undefined : btTimeout } | ||
if (reqHeaders.has('x-copy') || searchParams.has('x-copy')) { | ||
@@ -243,3 +244,4 @@ const torrentData = await app.userTorrent(mid.mainId, mid.mainPath, { ...useOpts, id: JSON.parse(reqHeaders.get('x-copy') || searchParams.get('x-copy')) }) | ||
} else { | ||
const useOpts = { timeout: reqHeaders.has('x-timer') || searchParams.has('x-timer') ? reqHeaders.get('x-timer') !== '0' || searchParams.get('x-timer') !== '0' ? Number(reqHeaders.get('x-timer') || searchParams.get('x-timer')) * 1000 : undefined : btTimeout } | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { ...useOpt, timeout: reqHeaders.has('x-timer') || searchParams.has('x-timer') ? reqHeaders.get('x-timer') !== '0' || searchParams.get('x-timer') !== '0' ? Number(reqHeaders.get('x-timer') || searchParams.get('x-timer')) * 1000 : undefined : btTimeout } | ||
const torrentData = await app.loadTorrent(mid.mainId, mid.mainPath, useOpts) | ||
@@ -282,3 +284,3 @@ if(torrentData){ | ||
async function handlePost(request) { | ||
async function handlePost(request) { | ||
const { url, method, headers: reqHeaders, body, signal } = request | ||
@@ -298,8 +300,12 @@ | ||
if (mid.mainQuery) { | ||
if (!reqHeaders.has('x-update') && !searchParams.has('x-update')) { | ||
return sendTheData(signal, {status: 400, headers: {'Content-Type': mainRes}, body: mainReq ? `<html><head><title>${mid.mainHost}</title></head><body><div><p>X-Update header is needed</p></div></body></html>` : JSON.stringify('X-Update header is needed')}) | ||
} | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { | ||
count: reqHeaders.has('x-version') || searchParams.has('x-version') ? Number(reqHeaders.get('x-version') || searchParams.get('x-version')) : null, | ||
opt: reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : null | ||
opt: useOpt | ||
} | ||
const useBody = reqHeaders.has('content-type') && reqHeaders.get('content-type').includes('multipart/form-data') ? handleFormData(await request.formData()) : body | ||
const torrentData = (reqHeaders.has('x-update') && JSON.parse(reqHeaders.get('x-update'))) || (searchParams.has('x-update') && JSON.parse(searchParams.get('x-update'))) ? await app.publishTorrent({ address: null, secret: null }, mid.mainPath, useBody, useOpts) : await app.publishTorrent({ infohash: null }, mid.mainPath, useBody, useOpts) | ||
const torrentData = JSON.parse(reqHeaders.get('x-update')) || JSON.parse(searchParams.get('x-update')) ? await app.publishTorrent({ address: null, secret: null }, mid.mainPath, useBody, useOpts) : await app.publishTorrent({ infohash: null }, mid.mainPath, useBody, useOpts) | ||
const useHeaders = {} | ||
@@ -317,5 +323,6 @@ for (const test of ['sequence', 'name', 'infohash', 'dir', 'pair', 'secret', 'address']) { | ||
} else { | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { | ||
count: reqHeaders.has('x-version') || searchParams.has('x-version') ? Number(reqHeaders.get('x-version') || searchParams.get('x-version')) : null, | ||
opt: reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : null | ||
opt: useOpt | ||
} | ||
@@ -353,6 +360,16 @@ const useBody = reqHeaders.has('content-type') && reqHeaders.get('content-type').includes('multipart/form-data') ? handleFormData(await request.formData()) : body | ||
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 = { | ||
count: reqHeaders.has('x-version') || searchParams.has('x-version') ? Number(reqHeaders.get('x-version') || searchParams.get('x-version')) : null, | ||
opt: useOpt | ||
} | ||
const torrentData = await app.trashUserData(mid.mainPath) | ||
return sendTheData(signal, { status: 200, headers: { '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: 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) }) | ||
} else { | ||
const torrentData = await app.shredTorrent(mid.mainId, mid.mainPath, {}) | ||
const useOpt = reqHeaders.has('x-opt') || searchParams.has('x-opt') ? JSON.parse(reqHeaders.get('x-opt') || decodeURIComponent(searchParams.get('x-opt'))) : {} | ||
const useOpts = { | ||
count: reqHeaders.has('x-version') || searchParams.has('x-version') ? Number(reqHeaders.get('x-version') || searchParams.get('x-version')) : null, | ||
opt: useOpt | ||
} | ||
const torrentData = await app.shredTorrent(mid.mainId, mid.mainPath, useOpts) | ||
const useHead = {} | ||
@@ -359,0 +376,0 @@ for (const test of ['id', 'path', 'infohash', 'dir', 'name', 'sequence', 'pair', 'address', 'secret']) { |
{ | ||
"name": "list-fetch", | ||
"version": "29.0.8", | ||
"version": "30.0.0", | ||
"description": "coming soon", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,59 +0,70 @@ | ||
# list-Fetch | ||
# list-fetch | ||
`_` - does different things depending on the http method | ||
`address` - a public key that is 64 characters that is used as an address | ||
`infohash` - a identifier for torrents that is 40 characters | ||
method: `HEAD` - does not return a body, only returns headers<br> | ||
hostname: | ||
* `_` - user's own data<br> | ||
path: | ||
* `/` - if path is `/` then it returns data about the current torrents, if no headers, then it returns the byte size and count of all of the authored torrents<br> | ||
headers: | ||
* `X-Data` - `true` | `false` - if true, it returns the byte size and count of all the torrents, if false, it returns only the count of all the torrents<br> | ||
* `/path/to/dir/or/file` - if path is not `/` then it returns data in the headers about the user directory that is local and not publically shared<br> | ||
* `address` | `infohash` - a torrent you want to load<br> | ||
path: | ||
* `/any/path/to/dir/or/file` - it can be any path including `/`, if no headers, it returns the byte size, link, and other data in the headers<br> | ||
headers: | ||
* `X-Copy` - `true` | `false` - if true, copies a file and saves it to the user directory(with the address or infohash as the directory name, it is publically shared) on the local disk, if false, copies a file and saves it to the user directory(it is publically shared) on the local disk<br> | ||
- `_` - user's own data<br> | ||
path: | ||
- `/` - if path is `/` then it returns data about the current torrents, if no headers are used, then it returns the byte size and count of all of the authored torrents<br> | ||
headers: | ||
- `X-Data` - `true` | `false` - if true, it returns the byte size and count of all the torrents, if false, it returns only the count of all the torrents<br> | ||
- `/path/to/dir/or/file` - if path is not `/` then it returns data in the headers about the user directory that is local and not publically shared<br> | ||
- `address` | `infohash` - a torrent you want to load<br> | ||
path: | ||
- `/any/path/to/dir/or/file` - it can be any path including `/`, if no headers, it returns the byte size, link, and other data of the torrent in the headers<br> | ||
headers: | ||
- `X-Copy` - `true` | `false` - if true, copies a file and saves it to the user directory(with the address or infohash as the directory name, it is publically shared) on the local disk, if false, copies a file and saves it to the user directory(it is publically shared) on the local disk<br> | ||
- `X-Timer` - `String` - a number for a timeout<br> | ||
method: `GET` - return a body<br> | ||
hostname: | ||
* `_` - user's own data<br> | ||
path: | ||
* `/` - if path is `/` then it is same as `HEAD`, in addition, it also sends a body<br> | ||
headers: | ||
* `X-Data` - `true` | `false` - if true, it returns the byte size and count of all the torrents, if false, it returns only the count of all the torrents<br> | ||
* `/path/to/dir/or/file` - if path is not `/` then it is the same as `HEAD`, in addition, it also sends a body<br> | ||
* `address` | `infohash` - a torrent you want to load<br> | ||
path: | ||
* `/any/path/to/dir/or/file` - it can be any path including `/`, if no headers, it returns the byte size, link, and other data in the headers<br> | ||
headers: | ||
* `Range` - if path is a file, it returns the data from a file that fits this range<br> | ||
- `_` - user's own data<br> | ||
path: | ||
- `/` - if path is `/` then it is same as `HEAD`, in addition, it also sends a body. if there are no headers, then only author data is returned<br> | ||
headers: | ||
- `X-Data` - `true` | `false` - if true, it returns the byte size and count of all the torrents, if false, it returns only the count of all the torrents<br> | ||
- `/path/to/dir/or/file` - if path is not `/` then it is the same as `HEAD`, in addition, it also sends a body<br> | ||
- `address` | `infohash` - a torrent you want to load<br> | ||
path: | ||
- `/any/path/to/dir/or/file` - it can be any path including `/`, if no headers, it returns the byte size, link, and other data in the headers<br> | ||
headers: | ||
- `Range` - if path is a file, it returns the data from a file that fits this range<br> | ||
- `X-Timer` - `String` - a number for a timeout<br> | ||
method: `POST` - return a body<br> | ||
hostname: | ||
* `_` - make a new torrent<br> | ||
path: | ||
* `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
- `_` - make a new torrent<br> | ||
path: | ||
- `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
body: | ||
* `FormData` | `String` - either FormData which will hold the files or some string for a single file<br> | ||
- `FormData` | `String` - either FormData which will hold the files or some string for a single file<br> | ||
headers: | ||
* `X-Update` - `true` | `false` - if true, a mutable BEP46 torrent, if false, a immutable regular torrent<br> | ||
* `X-Version` - `String` - what sequence to use for the torrent<br> | ||
* `address` | `infohash` - an already existing torrent that you want to modify<br> | ||
path: | ||
* `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
- `X-Update` - `true` | `false` - if true, a mutable BEP46 torrent, if false, an immutable regular torrent<br> | ||
- `X-Version` - `String` - what sequence to use for the torrent<br> | ||
- `X-Opt` - `String` - options to use for the content, stringified object<br> | ||
- `address` | `infohash` - an already existing torrent that you want to modify<br> | ||
path: | ||
- `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
body: | ||
* `FormData` | `String` - either FormData which will hold the files or some string for a single file<br> | ||
- `FormData` | `String` - either FormData which will hold the files or some string for a single file<br> | ||
headers: | ||
* `X-Version` - `String` - what sequence to use for the torrent<br> | ||
- `X-Version` - `String` - what sequence to use for the torrent<br> | ||
- `X-Opt` - `String` - options to use for the content, stringified object<br> | ||
method: `DELETE` - returns a body<br> | ||
hostname: | ||
* `_` - delete user directory data<br> | ||
path: | ||
* `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
- `_` - delete user directory data<br> | ||
path: | ||
- `/path/to/dir/or/file` - any path, this is where the files will go for the torrent<br> | ||
- `address` | `infohash` - an already existing torrent to delete entirely or modify<br> | ||
path: | ||
- `/path/to/dir/or/file` - any path, if `/` then entire torrent is delete, if not `/`, then only the path is deleted and a new torrent is made | ||
headers: | ||
* `X-Update` - `true` | `false` - if true, a mutable BEP46 torrent, if false, a immutable regular torrent<br> | ||
* `X-Version` - `String` - what sequence to use for the torrent<br> | ||
* `address` | `infohash` - an already existing torrent to delete entirely or modify<br> | ||
path: | ||
* `/path/to/dir/or/file` - any path, if `/` then entire torrent is delete, if not `/`, then only the path is deleted and a new torrent is made | ||
- `X-Opt` - `String` - options to use for the content, stringified object<br> |
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
28518
385
71