clay-lambda
Advanced tools
+21
-21
@@ -1,36 +0,36 @@ | ||
| let clayjs = function(routes) { | ||
| return function(event, done, fail) { | ||
| const method = event.raw.httpMethod | ||
| const path = event.raw.path | ||
| const apiPath = '/' + path.split('/').slice(3).join('/') | ||
| let routes = [] | ||
| // Shortcuts | ||
| event.method = method; | ||
| event.path = path; | ||
| let clayjs = function (event, done, fail) { | ||
| const method = event.raw.httpMethod | ||
| const path = event.raw.path | ||
| const apiPath = '/' + path.split('/').slice(3).join('/') | ||
| if(routes.length == 0 | ||
| // Shortcuts | ||
| event.method = method; | ||
| event.path = path; | ||
| if (routes.length == 0 | ||
| || routes == null) { | ||
| return fail('No routes are defiend') | ||
| } | ||
| return fail('No routes are defiend') | ||
| } | ||
| for(let i = 0; i < routes.length; i++) { | ||
| let route = routes[i] | ||
| for (let i = 0; i < routes.length; i++) { | ||
| let route = routes[i] | ||
| if(route.path == path | ||
| if (route.path == path | ||
| && (route.method == method || route.method == '*')) { | ||
| return route.fn(event, done, fail) | ||
| } | ||
| return route.fn(event, done, fail) | ||
| } | ||
| } | ||
| return fail('Path ' + path + ' is not found.') | ||
| } | ||
| return fail('Path ' + path + ' is not found.') | ||
| } | ||
| function makeRequestMethod(type) { | ||
| return function(path, fn) { | ||
| return { | ||
| return function (path, fn) { | ||
| routes.push({ | ||
| method: type, | ||
| fn, | ||
| path | ||
| } | ||
| }) | ||
| } | ||
@@ -37,0 +37,0 @@ } |
+1
-1
| { | ||
| "name": "clay-lambda", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1260
-5.41%35
-2.78%