
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@dotmh/lambda-controller
Advanced tools
A class to help make lambda function behind AWS API Gateway.
It exposes some common methods to allow you to use Lambda behind API Gateway more as you would making a normal HTTP app.
To install
npm i @dotmh/lamda-controller
Create a new controller
const controller = require('@dotmh/lambda-controller');
class MyController extends controller {}
You then need to declare a method or methods to handle your requests
const controller = require('@dotmh/lambda-controller');
class MyController extends controller {
handler() {
// Your logic goes here
}
}
This will contain your functions logic for that request
Lastly create a function to call your handler on your controller , and export the function as your serverless function
const controller = require('@dotmh/lambda-controller');
class MyController extends controller {
handler() {
// Your logic goes here
}
}
module.exports.handler = (event, ctx, callback) => {
(new MyController(event, ctx, callback)).handler();
}
For API , see Documentation
To keep the library as small as possible it doesn't include some functionality that you may need. This includes POST body handling and also functionality like cookies etc. The system is designed to be extend however. The extention system is based on mixin's this are just normal JS objects that are mixed in to the Lambda controller class.
A mixin that adds a function (method) and getter would look like this
const mixin = {
hello: () => "Hello",
get bye() {
return "Goodbye"
}
}
You can then add the mixin to Lamda controller using the add method.
// ...
(new MyController(event, ctx, callback)).add(mixin).handler();
// ...
Inside your Controller class (the class that extends Lambda Controller) you can use the mixin methods , getters and setters as if they were originally defined on the main Lambda controller class.
const Controller = require('@dotmh/lambda-controller');
class MyController extends Controller {
handler() {
return this.bye;
}
}
You may want to do somethings on intialization of the extending mixin. Normally you would use the constructor for this but because of the way the addon system work, the constructor A) Can not be overridden or extends , and B) would have already fired. For this purpose you can use an "init" function.
To use an init function declare a function called init on your mixin.
const mixin = {
init() {
// ... do something
},
get foo() {
return "bar"
}
}
your init function wont appear on the Controller after it has been added, but will be called when
the mixin is added to the controller class. It is called in the content of the controller so
this will refer to the controller object.
For the API documentation see https://dotmh.github.io/lambda-controller
Or to read locally
npm run readdocs
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Logo design by @dotmh
FAQs
A controller to work on AWS Lambda behind API Gateway
The npm package @dotmh/lambda-controller receives a total of 2 weekly downloads. As such, @dotmh/lambda-controller popularity was classified as not popular.
We found that @dotmh/lambda-controller 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.