diff --git a/package.json b/package.json index 26758d22..b4a8d846 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,6 @@ "@cloudcmd/read-files-sync": "^1.0.0", "apart": "^1.0.1", "chalk": "^2.0.1", - "checkup": "^1.3.0", "console-io": "^7.0.0", "copymitter": "^3.0.0", "criton": "^1.0.0", diff --git a/server/rest/index.js b/server/rest/index.js index 397472cd..11043acd 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -16,9 +16,8 @@ const wraptile = require('wraptile/legacy'); const pullout = require('pullout/legacy'); const json = require('jonny/legacy'); const ponse = require('ponse'); -const copymitter = require('copymitter'); -const check = require('checkup'); +const copymitter = require('copymitter'); const moveFiles = require('./move-files'); const swap = wraptile((fn, a, b) => fn(b, a)); @@ -32,12 +31,7 @@ const isWin32 = process.platform === 'win32'; * @param callback */ module.exports = (request, response, next) => { - check - .type('next', next, 'function') - .check({ - request, - response, - }); + check(request, response, next); const apiURL = CloudFunc.apiURL; const name = ponse.getPathName(request); @@ -168,12 +162,7 @@ const getMoveMsg = (files) => { }; function onPUT(name, body, callback) { - check - .type('callback', callback, 'function') - .check({ - name, - body, - }); + checkPut(name, body, callback); const cmd = getCMD(name); const files = json.parse(body); @@ -347,3 +336,25 @@ function formatMsg(msg, data, status) { return CloudFunc.formatMsg(msg, value, status); } +function check(request, response, next) { + if (typeof request !== 'object') + throw Error('request should be an object'); + + if (typeof response !== 'object') + throw Error('response should be an object'); + + if (typeof next !== 'function') + throw Error('next should be a function'); +} + +function checkPut(name, body, callback) { + if (typeof name !== 'string') + throw Error('name should be a string!'); + + if (typeof body !== 'string') + throw Error('body should be a string!'); + + if (typeof callback !== 'function') + throw Error('callback should be a function'); +} +