aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJohannes Zellner <johannes@nebulon.de>2015-06-27 16:07:34 +0200
committerJohannes Zellner <johannes@nebulon.de>2015-06-27 16:07:34 +0200
commit08b2ad7f716b3323ab8c168eb8a00a47fda03d66 (patch)
treeb7ca073bb9145844065d27c6c339514b59b5a5bb /src
parenteaa621841f04c1dfcc5ce98edf357d5a0d8cedfa (diff)
downloadSurfer-08b2ad7f716b3323ab8c168eb8a00a47fda03d66.tar.gz
Surfer-08b2ad7f716b3323ab8c168eb8a00a47fda03d66.tar.zst
Surfer-08b2ad7f716b3323ab8c168eb8a00a47fda03d66.zip
Add cli
Diffstat (limited to 'src')
-rw-r--r--src/actions.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/actions.js b/src/actions.js
new file mode 100644
index 0000000..33e47aa
--- /dev/null
+++ b/src/actions.js
@@ -0,0 +1,34 @@
1'use strict';
2
3exports.put = put;
4exports.get = get;
5exports.del = del;
6
7var superagent = require('superagent'),
8 path = require('path');
9
10var server = 'http://localhost:3000/api/files/';
11
12function put(filePath) {
13 var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1);
14 superagent.put(server + relativeFilePath).attach('file', filePath).end(function (error, result) {
15 if (error) return console.log('Failed', result ? result.body : error);
16 console.log('Success', result.body);
17 });
18}
19
20function get(filePath) {
21 var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1);
22 superagent.get(server + relativeFilePath).end(function (error, result) {
23 if (error) return console.log('Failed', result ? result.body : error);
24 console.log('Success', result.body);
25 });
26}
27
28function del(filePath) {
29 var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1);
30 superagent.del(server + relativeFilePath).end(function (error, result) {
31 if (error) return console.log('Failed', result ? result.body : error);
32 console.log('Success', result.body);
33 });
34}