-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring, linting and remove deleteTorrent function
- Loading branch information
Showing
13 changed files
with
172 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
"rules": { | ||
"indent": [2, 4], | ||
"no-console": [0], | ||
"max-len": [0], | ||
"func-names": [0] | ||
}, | ||
"globals": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
npm-debug.log* | ||
node_modules | ||
config/test.json | ||
config/development.json | ||
config/dev.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"apiBaseUrl": "https://api.real-debrid.com/", | ||
"apiBaseUrl": "https://api.real-debrid.com", | ||
"apiEndpoint": "https://api.real-debrid.com/rest/1.0", | ||
"clientId": "MPCF6OE5DLDM2", | ||
"requestDelay": 1000 | ||
"requestDelay": 2000 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import request from 'request'; | ||
import chalk from 'chalk'; | ||
import fs from 'fs'; | ||
|
||
const callback = (resolve, reject) => (error, response, body) => { | ||
if (error) { | ||
reject('Resource temporarily unavailable'); | ||
} | ||
|
||
if (body) { | ||
const bodyParse = JSON.parse(body); | ||
if (!bodyParse || bodyParse.error) { | ||
reject(bodyParse.error); | ||
} | ||
resolve(bodyParse); | ||
} | ||
|
||
resolve(true); | ||
}; | ||
|
||
const http = { | ||
post: (url, data = []) => new Promise((resolve, reject) => { | ||
request.post(url, data, callback(resolve, reject)); | ||
}).catch((error) => { | ||
console.error(chalk.red(error)); | ||
process.exit(); | ||
}), | ||
|
||
get: (url, delay = 0) => new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
request(url, callback(resolve, reject)); | ||
}, delay); | ||
}).catch((error) => { | ||
console.error(chalk.red(error)); | ||
process.exit(); | ||
}), | ||
|
||
put: (url, file) => new Promise((resolve, reject) => { | ||
fs.createReadStream(file).pipe(request.put(url, {}, callback(resolve, reject))); | ||
}).catch((error) => { | ||
console.error(chalk.red(error)); | ||
process.exit(); | ||
}), | ||
}; | ||
|
||
export default http; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.