Skip to content

Commit

Permalink
fix: send error response if path not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Dec 29, 2016
1 parent e5522f9 commit c14edf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions dadi/lib/index.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit c14edf2

Please sign in to comment.