![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
lambda-restify
Advanced tools
A restify like interface for aws lambda with api gateway event source
A restify/expressjs like interface for aws lambda with api gateway event.
npm install --save lambda-restify
If you are writing aws lambda function to develop rest apis using aws api gateway, this package will help you with request/response/routing/middlewares/versioned apis type features generally found in packages like restify or express.
Instead of using http module for opening a server and listening for incoming requests, this package relies on lambda event and callback.
When you make an http request against aws apigateway it triggers aws lambda with an event containing all the information about the incoming request (like method, url, querystring, headers, and body). lambda-restify relies on that information to create request object.
When your route handler sends response back (including headers, content), lambda-restify triggers lambda callback.
It requires node >= 6.10.0. Make sure you choose "6.10.2" or above while creating lambda function. At the time of writing lambda supports v4.3.2 and 6.10.2.
npm install --save lambda-restify
See list of supported options here.
const Server = require('lambda-restify').default;
const server = new Server(options);
Or, if you are using imports
import Server from 'lambda-restify';
const server = new Server(options);
See restify documentation for documentation on server.pre, server.use, server.get (and other http verbs). Since lambda-restify uses restify like interface all that docs apply here as well.
server.pre(function(req, res, next) {
// this handler is run for all routes, even 404
// do something here
next()
})
server.use(function(req, res, next) {
// this handler is run for after routing is done
// and successful match is found (not on 404)
// do something here
next()
})
server.post('/user/:id', function(req, res) {
// headers available
const apiKey = req.header('apikey');
// route param
const userId = req.params.id;
// query string
const queryValue = req.query('queryKey')
// body
const name = req.body.name
// send response with res.json or res.send
res.json({
status: 1
})
})
// define other route handlers
exports.yourlambdaHandler = function(event, context, callback) {
server.handleLambdaEvent(event, context, callback)
}
Note
Most likely, you will need to set:
context.callbackWaitsForEmptyEventLoop = false
before calling server.handleLamdaEvent in your lamda handler. See http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html for details.
See restify documentation. Following items work just as they did in restify:
Server.handleLambdaEvent(lambdaEvent, context, lambdaCallback)
Plug this into lambda handler to route all incoming lambda events.
FAQs
A restify like interface for aws lambda with api gateway event source
The npm package lambda-restify receives a total of 4 weekly downloads. As such, lambda-restify popularity was classified as not popular.
We found that lambda-restify 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.