mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 08:54:10 +00:00
feature(markdown) rm util
This commit is contained in:
parent
1849cc227f
commit
60e80e7f14
1 changed files with 14 additions and 2 deletions
|
|
@ -7,16 +7,28 @@
|
|||
|
||||
fs = require('fs'),
|
||||
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
root = require(DIR + 'root'),
|
||||
pipe = require('pipe-io'),
|
||||
ponse = require('ponse'),
|
||||
markdown = require('markdown-it')();
|
||||
|
||||
function check(name, request, callback) {
|
||||
if (typeof name !== 'string')
|
||||
throw(Error('name should be string!'));
|
||||
|
||||
else if (!request)
|
||||
throw(Error('request could not be empty!'));
|
||||
|
||||
else if (typeof callback !== 'function')
|
||||
throw(Error('callback should be function!'));
|
||||
}
|
||||
|
||||
module.exports = function(name, request, callback) {
|
||||
var query,
|
||||
method = request.method;
|
||||
|
||||
check(name, request, callback);
|
||||
|
||||
switch(method) {
|
||||
case 'GET':
|
||||
name = name.replace('/markdown', '');
|
||||
|
|
@ -38,7 +50,7 @@
|
|||
case 'PUT':
|
||||
pipe.getBody(request, function(error, data) {
|
||||
if (error)
|
||||
Util.exec(callback, error);
|
||||
callback(error);
|
||||
else
|
||||
parse(data, callback);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue