Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
lambda-serverless-api
Advanced tools
This project abstracts the creation of a basic API and the most commonly desired features.
Provides support for:
$ npm install --save lambda-serverless-api
First we need to wrap our lambda endpoint. Inside the lambda function we can then use ApiError
and JsonResponse
as following:
const api = require("lambda-serverless-api")({
limiter: {},
rollbar: {}
});
module.exports = api.wrap(process.env.RATE_LIMIT_PER_IP, () => {
if (new Date().getHours() === 4) {
throw api.ApiError("I am a teapot", 418);
}
return api.JsonResponse({ message: "What's up?" });
});
where RATE_LIMIT_PER_IP
allows to set different limits per endpoint. Rate limiting is explained below.
If you want to send plain text instead of json, you can use ApiResponse
.
You can pass an additional messageId
and context
to the ApiError
constructor.
These will be returned with the error response.
Rate limiting uses lambda-rate-limiter. Note that there are some serious restrictions because it does not use centralized storage!
To customize rate limiting, the package options are passed as limiter
into the constructor.
To monitor api errors and exceptions lambda-rollbar can be enabled. Options are passed by putting them as rollbar
into the constructor.
FAQs
Basic Api Wrapper for Serverless Framework.
The npm package lambda-serverless-api receives a total of 454 weekly downloads. As such, lambda-serverless-api popularity was classified as not popular.
We found that lambda-serverless-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.