mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(edit) add socket
This commit is contained in:
parent
7f1a85ed6c
commit
261be70cae
2 changed files with 86 additions and 7 deletions
34
lib/server/edit.js
Normal file
34
lib/server/edit.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var DIR_SERVER = __dirname + '/',
|
||||
DIR_LIB = DIR_SERVER + '../',
|
||||
|
||||
path = require('path'),
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
CloudFunc = require(DIR_LIB + 'cloudfunc'),
|
||||
patch = require(DIR_SERVER + 'patch');
|
||||
|
||||
module.exports = function(sock) {
|
||||
Util.check(arguments, ['socket']);
|
||||
|
||||
sock.of('/config')
|
||||
.on('connection', function(socket) {
|
||||
socket.on('patch', function(data) {
|
||||
var options = {
|
||||
size: CloudFunc.MAX_FILE_SIZE
|
||||
};
|
||||
|
||||
patch(name, data, options, function(error) {
|
||||
var baseName = path.basename(name),
|
||||
msg = CloudFunc.formatMsg('patch', baseName);
|
||||
|
||||
if (error)
|
||||
socket.emit('err', error);
|
||||
else
|
||||
socket.emit('message', msg);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue