
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
legerdemain
Advanced tools
Let's your express app understand the AWS API Gateway event/context functions.
Lets your Node.js Express app understand Amazon's API Gateway/Lambda requests.
Legerdemain is very much a work in progress. Don't use it for production. Please do report problems & use cases in the Issues tab on Github.
Legerdemain is part of Hocus Pocus, and works well with Hocus and Pocus. You can use Legerdemain without Hocus and Pocus, but you'll have to do a lot more things manually.
npm install legerdemain --save
module.exports = app;
translator.js
in the next step.var legerdemain = require('legerdemain');
var app = require('./app.js');
exports.handlers = legerdemain.bind(app)
Zip up the contents of your app. Do not zip up the folder, just the contents.
Create a new Lambda function.
Set the handler to translator.handler
.
Create a new API.
Define your resources and methods to match your app's routes. Map each method to your Lambda.
For each Method in the Gateway:
For the Integration Request, create a Mapping Template with Content-type of application/json. The actual template should look like this:
{
"stage": "$context.stage",
"request-id": "$context.requestId",
"api-id": "$context.apiId",
"resource-path": "$context.resourcePath",
"resource-id": "$context.resourceId",
"http-method": "$context.httpMethod",
"source-ip": "$context.identity.sourceIp",
"user-agent": "$context.identity.userAgent",
"account-id": "$context.identity.accountId",
"api-key": "$context.identity.apiKey",
"caller": "$context.identity.caller",
"user": "$context.identity.user",
"user-arn": "$context.identity.userArn",
"queryString": "$input.params().querystring",
"headers": "$input.params().header",
"pathParams": "$input.params().path",
"allParams": "$input.params()"
}
If the method is meant to return HTML,
3a) Create a Method Response with Content-type of text/html and use the Empty Model.
3b) Create an Integration Response with a Mapping Template, Content-type of text/html, with the following actual template:
#set($inputRoot = $input.path('$'))
$inputRoot.data
AWS API Gateway will give you the base URL to your app. Open that base url, plus your route, in your browser. For instance, if you have a "/" route, you can just open the base URL that AWS API Gatway provided.
MIT
FAQs
Let's your express app understand the AWS API Gateway event/context functions.
The npm package legerdemain receives a total of 2 weekly downloads. As such, legerdemain popularity was classified as not popular.
We found that legerdemain demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.