This repository is for zephyr, which is implemented for a GUI of Eos.
Revision | 87de47cf1ef759d97164624b75238684596a26ff (tree) |
---|---|
Time | 2016-01-27 04:29:46 |
Author | himetani_cafe <fumifumi@yasu...> |
Commiter | himetani_cafe |
[Develop and manual Test] API endpoint (get) /api/v1/workspace/:fileId?
workspaceの情報一覧を返す。
{
}
modified: server/api/v1/fileUpload/index.js
modified: server/api/v1/workspace/index.js
modified: server/app.js
modified: server/class/DB.js
@@ -41,7 +41,6 @@ router.post('/', function(req, res) { | ||
41 | 41 | var fileName = file.name; |
42 | 42 | var tmpPath = file.path; |
43 | 43 | var info = { |
44 | - status: null, | |
45 | 44 | parentDirectory: parentDirectory, |
46 | 45 | fileName: fileName, |
47 | 46 | tmpPath: tmpPath, |
@@ -67,12 +66,15 @@ router.post('/', function(req, res) { | ||
67 | 66 | }) |
68 | 67 | .then(function(fileIds) { |
69 | 68 | fileIds.forEach(function(fileId, i) { |
70 | - filesInfo[i].status = 'success'; | |
71 | 69 | filesInfo[i].fileId = fileId; |
72 | 70 | fs.renameSync(filesInfo[i].tmpPath, workspace + fileId); |
73 | 71 | delete filesInfo[i].tmpPath; |
74 | 72 | }) |
75 | - res.send(filesInfo); | |
73 | + var info = { | |
74 | + status: 'success', | |
75 | + info: filesInfo | |
76 | + }; | |
77 | + res.send(info); | |
76 | 78 | }); |
77 | 79 | }); |
78 | 80 |
@@ -9,10 +9,23 @@ var db = require(__dirname + '/../../../../server/class/DB').instance; | ||
9 | 9 | router.get('/:fileId?', function(req, res) { |
10 | 10 | var fileId = req.param('fileId'); |
11 | 11 | if(!fileId || fileId === '1f83f620-c1ed-11e5-9657-7942989daa00') { |
12 | - res.send('root'); | |
13 | - } else { | |
14 | - res.send('not root'); | |
15 | - } | |
12 | + fileId === '1f83f620-c1ed-11e5-9657-7942989daa00'; | |
13 | + } | |
14 | + db.getFiles(fileId) | |
15 | + .then(function(r) { | |
16 | + var info = { | |
17 | + status: 'success', | |
18 | + info: r | |
19 | + } | |
20 | + res.send(info); | |
21 | + }) | |
22 | + .catch(function(err) { | |
23 | + var info = { | |
24 | + status: 'error', | |
25 | + message: err.message | |
26 | + }; | |
27 | + res.send(info); | |
28 | + }) | |
16 | 29 | }); |
17 | 30 | |
18 | 31 | module.exports = router; |
@@ -26,7 +26,7 @@ DB.init() | ||
26 | 26 | .then(function() { |
27 | 27 | var server = app.listen(config.port, config.ip, function () { |
28 | 28 | console.log('Zephyr listening at http://%s:%s', config.ip, config.port); |
29 | - console.log(app.get('env')) | |
29 | + console.log('NODE_ENV = ' + app.get('env')) | |
30 | 30 | }); |
31 | 31 | |
32 | 32 | var io = require('socket.io').listen(server); |
@@ -249,13 +249,11 @@ function getFiles(fileId) { | ||
249 | 249 | }; |
250 | 250 | Files.findAll(q) |
251 | 251 | .then(function(r) { |
252 | - console.log(r); | |
253 | 252 | if(r.length === 0) { |
254 | 253 | reject(new Error('"'+fileId+'" is invalid.')); |
255 | 254 | } |
256 | - var fileIds = r.map(function(data) { return data.fileId; }); | |
257 | - console.log(fileIds); | |
258 | - resolve(fileIds); | |
255 | + var files = r.map(function(data) { return data; }); | |
256 | + resolve(files); | |
259 | 257 | }); |
260 | 258 | }); |
261 | 259 | } |