Skip to content

Commit 26d034f

Browse files
committed
inital commit
0 parents  commit 26d034f

11 files changed

+365
-0
lines changed

.gitignore

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
# Created by https://www.gitignore.io/api/node
3+
# Edit at https://www.gitignore.io/?templates=node
4+
5+
### Node ###
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# Diagnostic reports (https://nodejs.org/api/report.html)
15+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
16+
17+
# Runtime data
18+
pids
19+
*.pid
20+
*.seed
21+
*.pid.lock
22+
23+
# Directory for instrumented libs generated by jscoverage/JSCover
24+
lib-cov
25+
26+
# Coverage directory used by tools like istanbul
27+
coverage
28+
*.lcov
29+
30+
# nyc test coverage
31+
.nyc_output
32+
33+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
34+
.grunt
35+
36+
# Bower dependency directory (https://bower.io/)
37+
bower_components
38+
39+
# node-waf configuration
40+
.lock-wscript
41+
42+
# Compiled binary addons (https://nodejs.org/api/addons.html)
43+
build/Release
44+
45+
# Dependency directories
46+
node_modules/
47+
jspm_packages/
48+
49+
# TypeScript v1 declaration files
50+
typings/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Optional REPL history
62+
.node_repl_history
63+
64+
# Output of 'npm pack'
65+
*.tgz
66+
67+
# Yarn Integrity file
68+
.yarn-integrity
69+
70+
# dotenv environment variables file
71+
.env
72+
.env.test
73+
74+
# parcel-bundler cache (https://parceljs.org/)
75+
.cache
76+
77+
# next.js build output
78+
.next
79+
80+
# nuxt.js build output
81+
.nuxt
82+
83+
# rollup.js default build output
84+
dist/
85+
86+
# Uncomment the public line if your project uses Gatsby
87+
# https://nextjs.org/blog/next-9-1#public-directory-support
88+
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
89+
# public
90+
91+
# Storybook build outputs
92+
.out
93+
.storybook-out
94+
95+
# vuepress build output
96+
.vuepress/dist
97+
98+
# Serverless directories
99+
.serverless/
100+
101+
# FuseBox cache
102+
.fusebox/
103+
104+
# DynamoDB Local files
105+
.dynamodb/
106+
107+
# Temporary folders
108+
tmp/
109+
temp/
110+
111+
# End of https://www.gitignore.io/api/node
112+

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/js-bindings.iml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

axiosInstance.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import axios from "axios";
2+
import {AUTH_KEY, IP_ADDRESS_KEY} from "./constants";
3+
4+
/**
5+
* Global level axios configuration. These settings are automatically used in other places by using an axiosInstance instead of axios directly
6+
*/
7+
export let axiosInstance = axios.create({
8+
headers: {'Content-Type': 'application/json'},
9+
responseType: "json"
10+
});
11+
12+
/**
13+
* Interceptor adds basic authentication to every axios request.
14+
*/
15+
axiosInstance.interceptors.request.use(
16+
config => {
17+
config.baseURL = localStorage.getItem(IP_ADDRESS_KEY);
18+
19+
config.headers.Authorization = 'Basic ' + localStorage.getItem(AUTH_KEY);
20+
return config;
21+
},
22+
error => Promise.reject(error)
23+
);
24+

constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const USER_NAME_KEY = "userName";
2+
export const AUTH_KEY = "authKey";
3+
export const PASSWORD_KEY = "password";
4+
export const IP_ADDRESS_KEY = "ipAddress";

endpoint.js

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
const urls = {
2+
/**
3+
* Make Directory.
4+
*/
5+
mkdir: "operations/mkdir",
6+
/**
7+
* Purge a directory.
8+
*/
9+
purge: "operations/purge",
10+
/**
11+
* Delete a file.
12+
*/
13+
deleteFile: "operations/deletefile",
14+
/**
15+
* Create public link.
16+
*/
17+
createPublicLink: "operations/publiclink",
18+
/**
19+
* Stats for rclone backend.
20+
*/
21+
stats: "core/stats",
22+
/**
23+
* Check and set bwlimit.
24+
*/
25+
bwlimit: "core/bwlimit",
26+
/**
27+
* Move a directory.
28+
*/
29+
moveDir: "sync/move",
30+
/**
31+
* Move a file.
32+
*/
33+
moveFile: "operations/movefile",
34+
/**
35+
* Copy Directory
36+
*/
37+
copyDir: "sync/copy",
38+
/**
39+
* Copy Files.
40+
*/
41+
copyFile: "operations/copyfile",
42+
/**
43+
* Cleanup the remote recycle bin(trash).
44+
*/
45+
cleanUpRemote: "operations/cleanup",
46+
47+
/**
48+
* Try to connect without any authentication headers.
49+
*/
50+
noopAuth: "rc/noopauth",
51+
/**
52+
* Check the version of the rclone.
53+
*/
54+
getRcloneVersion: "core/version",
55+
56+
/**
57+
* Memstats for the rclone backend.
58+
*/
59+
getRcloneMemStats: "core/memstats",
60+
/**
61+
* Get options available in the backend.
62+
*/
63+
getOptions: "options/get",
64+
/**
65+
* Get providers configuration in the rclone backend.
66+
*/
67+
getProviders: "config/providers",
68+
/**
69+
* Get entire remote configuration dump from backend.
70+
*/
71+
getConfigDump: "config/dump",
72+
/**
73+
* List the currently running jobs.
74+
*/
75+
getRunningJobs: "job/list",
76+
/**
77+
* Get the status for a job.
78+
*/
79+
getStatusForJob: "job/status",
80+
/**
81+
* Get config for a specific remote.
82+
*/
83+
getConfigForRemote: "config/get",
84+
/**
85+
* Create a new config with parameters.
86+
*/
87+
createConfig: "config/create",
88+
/**
89+
* Update an existing config with parameters.
90+
*/
91+
updateConfig: "config/update",
92+
/**
93+
* Get File system information and supported features for a given remote time.
94+
*/
95+
getFsInfo: "operations/fsinfo",
96+
97+
/**
98+
* List the remote names of created remotes.
99+
*/
100+
listRemotes: "config/listremotes",
101+
/**
102+
* Get the files for given remoteName and path.
103+
*/
104+
getFilesList: "operations/list",
105+
106+
/**
107+
* Get information about the rclone backend.
108+
*/
109+
getAbout: "operations/about",
110+
/**
111+
* Delete a config with config name.
112+
*/
113+
deleteConfig: "config/delete",
114+
115+
/**
116+
* Stop a running job by job id
117+
*/
118+
stopJob: "job/stop",
119+
120+
};
121+
export default urls;

index.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {axiosInstance} from "./axiosInstance";
2+
import urls from "./endpoint";
3+
4+
/**
5+
* getStats returns the current rclone stats.
6+
* @returns {Promise<unknown>}
7+
*/
8+
export function getStats () {
9+
console.log("HI");
10+
return new Promise((resolve, reject) => {
11+
axiosInstance.post(urls.stats).then(res => {
12+
resolve(res.data);
13+
}, error => {
14+
reject(error);
15+
})
16+
})
17+
18+
}

package-lock.json

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "rclone-api",
3+
"version": "1.0.0",
4+
"description": "Java Script bindings for rclone rc api",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "rclone",
11+
"license": "ISC",
12+
"dependencies": {
13+
"axios": "^0.19.2"
14+
}
15+
}

0 commit comments

Comments
 (0)