From 81b5e0d764605b1e527776ac64d24f1c5860b6d1 Mon Sep 17 00:00:00 2001 From: Emil Tholin Date: Wed, 10 Jan 2018 19:24:22 +0100 Subject: [PATCH] Handle DELETE requests with del export --- lib/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 5279ff3..fae7d30 100644 --- a/lib/index.js +++ b/lib/index.js @@ -177,7 +177,11 @@ function get_route_handler(fn) { } else { - const handler = mod[req.method.toLowerCase()]; + const method = req.method.toLowerCase(); + // 'delete' cannot be exported from a module because it is a keyword, + // so check for 'del' instead + const method_export = method === 'delete' ? 'del' : method; + const handler = mod[method_export]; if (handler) handler(req, res, next); }