Permalink
Browse files

fix: send error response if path not specified

  • Loading branch information...
jimlambie committed Dec 29, 2016
1 parent e5522f9 commit c14edf2a259da2f83eca86ee4bbf821b5da76fa9
Showing with 6 additions and 3 deletions.
  1. +5 −2 dadi/lib/index.js
  2. +1 −1 package.json
@@ -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'
@@ -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",

0 comments on commit c14edf2

Please sign in to comment.