
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
@jschr/lambda-response
Advanced tools
Create lambda / api gateway responses with express-like api plus middleware for local development.
Express-style api for sending response with Lambda Integration Proxy for API Gateway.
Includes a cli and express middleware for local development.
npm install @jschr/lambda-response
import { Response } from '@jschr/lambda-response'
export default function handler(event, context) {
const res = new Response()
context.succeed(res.status(200).send('OK'))
context.succeed(res.status(200).send('OK'))
context.succeed(res.status(200).json({ foo: bar }))
context.succeed(res.redirect('http://google.com'))
}
Default headers can be passed when creating a new response:
const headers = { 'Content-Type': 'application/javascript' }
const res = new Response({ headers })
Or on an instance:
const res = new Response()
const headers = { 'Content-Type': 'application/javascript' }
res.set(headers)
CORS is enabled by default. You can pass in cors options when creating a new response:
const cors = { origin: 'example.com', methods: ['GET'], headers: ['X-Api-Key'] }
const res = new Response({ cors })
Check out the tests for more examples.
A CLI tool is provided for convienent local development. If you've installed in globally:
$ lambda-response foo/bar.default --port 8080
Where foo/bar
is the path to your lambda handler and default
is the exported function.
For advanced use cases you can use the lambda-response
express middleware:
import * as express from 'express'
import { middleware } from '@jschr/lambda-response'
import handler from 'foo/bar'
const app = express()
app.use(middleware(handler))
app.listen(8080)
FAQs
Express-like API for sending responses from Lambda Integration Proxy to API Gateway and a CLI for local development.
The npm package @jschr/lambda-response receives a total of 4 weekly downloads. As such, @jschr/lambda-response popularity was classified as not popular.
We found that @jschr/lambda-response 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.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.