diff --git a/dadi/lib/index.js b/dadi/lib/index.js index f960d1a4..8b33aacd 100755 --- a/dadi/lib/index.js +++ b/dadi/lib/index.js @@ -7,6 +7,7 @@ var chokidar = require('chokidar') var cluster = require('cluster') var colors = require('colors') // eslint-disable-line var parsecomments = require('parse-comments') +var formatError = require('@dadi/format-error') var fs = require('fs') var mkdirp = require('mkdirp') var path = require('path') @@ -279,9 +280,11 @@ Server.prototype.loadApi = function (options) { var method = req.method && req.method.toLowerCase() if (method !== 'post') return next() - var pathname = req.body.path + if (!req.body.path) { + return help.sendBackJSON(400, res, next)(null, formatError.createApiError('0003')) + } - return help.clearCache(pathname, function (err) { + return help.clearCache(req.body.path, function (err) { help.sendBackJSON(200, res, next)(err, { result: 'success', message: 'Cache flush successful' diff --git a/package.json b/package.json index 465c22e8..6cd4018a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start": "node start.js --node_env=development" }, "dependencies": { - "@dadi/cache": "1.2.0", + "@dadi/cache": "^1.2.0", "@dadi/format-error": "^1.0.0", "@dadi/logger": "latest", "@dadi/status": "latest",