+3
-1
@@ -21,3 +21,5 @@ const event = (originalEvent = {}, body = {}, overrides = {}) => ({ | ||
| identity: { | ||
| ...(originalEvent.requestContext ? originalEvent.requestContext.identity : {}), | ||
| ...(originalEvent.requestContext | ||
| ? originalEvent.requestContext.identity | ||
| : {}), | ||
| ...(overrides.requestContext ? overrides.requestContext.identity : {}), | ||
@@ -24,0 +26,0 @@ }, |
+11
-3
@@ -1,3 +0,7 @@ | ||
| const context = (resolve, reject) => ({ fail: (error) => reject(error), succeed: (response) => resolve(response) }); | ||
| const callback = (resolve, reject) => (error, success) => (error ? reject(error) : resolve(success)); | ||
| const context = (resolve, reject) => ({ | ||
| fail: (error) => reject(error), | ||
| succeed: (response) => resolve(response), | ||
| }); | ||
| const callback = (resolve, reject) => (error, success) => | ||
| error ? reject(error) : resolve(success); | ||
@@ -7,3 +11,7 @@ const invoker = (event, fn) => | ||
| try { | ||
| const response = fn(event, context(resolve, reject), callback(resolve, reject)); | ||
| const response = fn( | ||
| event, | ||
| context(resolve, reject), | ||
| callback(resolve, reject), | ||
| ); | ||
@@ -10,0 +18,0 @@ resolve(response); |
+3
-1
| module.exports = (record, path, defaultValue) => | ||
| path.match(/([^.[\]]+)/gu).reduce((result, piece) => result && result[piece], record) || defaultValue; | ||
| path | ||
| .match(/([^.[\]]+)/gu) | ||
| .reduce((result, piece) => result?.[piece], record) || defaultValue; |
| const cookie = require('cookie'); | ||
| const get = require('./../get'); | ||
| module.exports = (event) => cookie.parse(get(event, 'headers.Cookie', get(event, 'headers.cookie', ''))); | ||
| module.exports = (event) => | ||
| cookie.parse(get(event, 'headers.Cookie', get(event, 'headers.cookie', ''))); |
| const get = require('./../get'); | ||
| const parseJson = require('./../parseJson'); | ||
| module.exports = (event) => get(event, 'Records', []).map(({ body }) => parseJson(body)); | ||
| module.exports = (event) => | ||
| get(event, 'Records', []).map(({ body }) => parseJson(body)); |
| const binary = require('./binary'); | ||
| const fs = require('fs'); | ||
| const fs = require('node:fs'); | ||
| module.exports = (res, filePath, contentType) => binary(res, fs.readFileSync(filePath), contentType); | ||
| module.exports = (res, filePath, contentType) => | ||
| binary(res, fs.readFileSync(filePath), contentType); |
| const response = require('./response'); | ||
| module.exports = (res, body) => response(res, JSON.stringify(body), 'application/json'); | ||
| module.exports = (res, body) => | ||
| response(res, JSON.stringify(body), 'application/json'); |
+1
-1
| module.exports = async (req, res, next) => { | ||
| const response = await next(req, res); | ||
| return response && response.getResponse ? response.getResponse() : response; | ||
| return response?.getResponse ? response.getResponse() : response; | ||
| }; |
+4
-1
@@ -22,3 +22,6 @@ const binary = require('./helpers/binary'); | ||
| setHeader: (name, value) => setHeader(response, name, value), | ||
| setHeaders: (headers) => Object.keys(headers).map((name) => setHeader(response, name, headers[name])), | ||
| setHeaders: (headers) => | ||
| Object.keys(headers).map((name) => | ||
| setHeader(response, name, headers[name]), | ||
| ), | ||
| setStatusCode: (value) => setStatusCode(response, value), | ||
@@ -25,0 +28,0 @@ }); |
+1
-1
| MIT License | ||
| Copyright (c) 2018-present Prefinem | ||
| Copyright (c) 2018-present Raxvis | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
+9
-13
| { | ||
| "author": { | ||
| "email": "prefinem@gmail.com", | ||
| "name": "Prefinem", | ||
| "url": "https://prefinem.com" | ||
| "email": "william@raxvis.com", | ||
| "name": "Raxvis" | ||
| }, | ||
@@ -14,10 +13,7 @@ "dependencies": { | ||
| "devDependencies": { | ||
| "eslint": "8.57.1", | ||
| "eslint-config-prettier": "9.1.0", | ||
| "eslint-plugin-jest": "28.8.3", | ||
| "@biomejs/biome": "1.9.4", | ||
| "express": "4.21.1", | ||
| "husky": "9.1.6", | ||
| "jest": "29.7.0", | ||
| "lint-staged": "15.2.10", | ||
| "prettier": "3.3.3" | ||
| "lint-staged": "15.2.10" | ||
| }, | ||
@@ -33,3 +29,3 @@ "engines": { | ||
| ], | ||
| "homepage": "https://github.com/Prefinem/lambdify", | ||
| "homepage": "https://github.com/Raxvis/lambdify", | ||
| "husky": { | ||
@@ -51,9 +47,9 @@ "hooks": { | ||
| "canary": "npm publish --tag canary", | ||
| "clean": "npm run lint && npm run prettify", | ||
| "lint": "./node_modules/.bin/eslint '**/*.js' --fix", | ||
| "prettify": "./node_modules/.bin/prettier --config ./.prettierrc.json --write '**/*.js'", | ||
| "clean": "npx @biomejs/biome check --write", | ||
| "lint": "npx @biomejs/biome format --write **/*.js", | ||
| "prettify": "npx @biomejs/biome lint --write **/*.js", | ||
| "staged": "lint-staged", | ||
| "test": "./node_modules/.bin/jest" | ||
| }, | ||
| "version": "4.5.0" | ||
| "version": "4.6.0" | ||
| } |
+3
-14
@@ -5,22 +5,13 @@ # lambdify | ||
| [](https://github.com/Prefinem/lambdify/actions) [](https://codeclimate.com/github/Prefinem/lambdify/maintainability) [](https://codecov.io/gh/Prefinem/lambdify) | ||
| [](https://github.com/Raxvis/lambdify/actions) [](https://codeclimate.com/github/Raxvis/lambdify/maintainability) [](https://codecov.io/gh/Raxvis/lambdify) | ||
|  | ||
|   | ||
|   | ||
|   | ||
|   | ||
| Lambdify is a set of tools that makes building and consuming AWS Lambda functions easier. | ||
| # NOTICE | ||
| **THESE ARE v4 DOCS. Please see [branch v3](https://github.com/Prefinem/lambdify/tree/v3) for v3 Docs** | ||
| **Master branch is v4. v4 drops lambdify-fn and lambdify-utils and is moving to a single package.** | ||
| If you used methods from lambdify-fn, you can use [afpf](https://github.com/Prefinem/afpf) instead | ||
| **_WARNING: Version >= 3.0.0 is for Node 8.10 or greater_** | ||
| # Getting Started | ||
@@ -372,3 +363,1 @@ | ||
| This was originally developed to handle next.js SSR on AWS Lambda. Officially there is no support and although packages like [serverless-nextjs-plugin](https://www.npmjs.com/package/serverless-nextjs-plugin) exist, they require more packages and the serverless deployment system. | ||
| Example of Next.js package soon to come |
@@ -7,3 +7,8 @@ /* eslint-disable max-params */ | ||
| if (typeof key === 'function') { | ||
| actions.push({ fn: key, middleware: [value, fn, ...middleware], options: {}, type: 'sqs' }); | ||
| actions.push({ | ||
| fn: key, | ||
| middleware: [value, fn, ...middleware], | ||
| options: {}, | ||
| type: 'sqs', | ||
| }); | ||
| } else { | ||
@@ -10,0 +15,0 @@ actions.push({ |
| const pathMatch = (req, action) => { | ||
| try { | ||
| if (action.method.toUpperCase() === 'ANY' || action.method.toUpperCase() === req.getMethod()) { | ||
| if ( | ||
| action.method.toUpperCase() === 'ANY' || | ||
| action.method.toUpperCase() === req.getMethod() | ||
| ) { | ||
| const isMatch = action.pattern(req.getPath()); | ||
@@ -10,3 +13,5 @@ | ||
| // This sets the path params | ||
| Object.keys(params).forEach((key) => req.setPathParam(key, params[key])); | ||
| for (const key of Object.keys(params)) { | ||
| req.setPathParam(key, params[key]); | ||
| } | ||
@@ -13,0 +18,0 @@ return true; |
@@ -9,5 +9,7 @@ const get = require('./../../lib/get'); | ||
| return false; | ||
| } else if (!action.options || !action.options.key) { | ||
| } | ||
| if (!action.options || !action.options.key) { | ||
| return true; | ||
| } else if (get(message, action.options.key) === action.options.value) { | ||
| } | ||
| if (get(message, action.options.key) === action.options.value) { | ||
| return true; | ||
@@ -14,0 +16,0 @@ } |
@@ -1,3 +0,4 @@ | ||
| const getEventBody = (event) => Buffer.from(event.body, event.isBase64Encoded ? 'base64' : 'utf8'); | ||
| const getEventBody = (event) => | ||
| Buffer.from(event.body, event.isBase64Encoded ? 'base64' : 'utf8'); | ||
| module.exports = getEventBody; |
@@ -6,2 +6,3 @@ const binarycase = require('binary-case'); | ||
| // headers with the same name, as discussed on the AWS Forum https://forums.aws.amazon.com/message.jspa?messageID=725953#725953 | ||
| // biome-ignore lint/performance/noDelete: This should not exist and should be removed. Undefined might keep the key on the object and thus fail | ||
| delete originalHeaders.connection; | ||
@@ -15,12 +16,14 @@ | ||
| if (header.toLowerCase() === 'set-cookie' && Array.isArray(value)) { | ||
| return { | ||
| ...result, | ||
| ...value.reduce((headers, cookie, index) => ({ ...headers, [binarycase(header, index + 1)]: cookie }), {}), | ||
| }; | ||
| value.forEach((cookie, index) => { | ||
| result[binarycase(header, index + 1)] = cookie; | ||
| }); | ||
| return result; | ||
| } | ||
| return { | ||
| ...result, | ||
| [header.toLowerCase()]: Array.isArray(value) ? value.join(',') : value, | ||
| }; | ||
| result[header.toLowerCase()] = Array.isArray(value) | ||
| ? value.join(',') | ||
| : value; | ||
| return result; | ||
| }, {}), | ||
@@ -27,0 +30,0 @@ }; |
+1
-1
@@ -13,3 +13,3 @@ /* | ||
| const getSocketPath = require('./getSocketPath'); | ||
| const http = require('http'); | ||
| const http = require('node:http'); | ||
@@ -16,0 +16,0 @@ process.on('unhandledRejection', (err) => { |
+10
-4
| const getEventBody = require('./getEventBody'); | ||
| const handleError = require('./handleError'); | ||
| const handleRequestResponse = require('./handleRequestResponse'); | ||
| const http = require('http'); | ||
| const url = require('url'); | ||
| const http = require('node:http'); | ||
| const url = require('node:url'); | ||
@@ -10,3 +10,6 @@ const cleanHeaders = (headers = {}) => | ||
| .filter((header) => typeof headers[header] !== 'undefined') | ||
| .reduce((result, header) => ({ ...result, [header]: headers[header] }), {}); | ||
| .reduce((result, header) => { | ||
| result[header] = headers[header]; | ||
| return result; | ||
| }, {}); | ||
@@ -18,3 +21,6 @@ const proxyEvent = (event, socketPath) => | ||
| method: event.httpMethod, | ||
| path: url.format({ pathname: event.path, query: event.queryStringParameters }), | ||
| path: url.format({ | ||
| pathname: event.path, | ||
| query: event.queryStringParameters, | ||
| }), | ||
| socketPath, | ||
@@ -21,0 +27,0 @@ }; |
Network access
Supply chain riskThis module accesses the network.
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
5
-37.5%568
7.37%2
-33.33%0
-100%31213
-0.89%362
-2.95%