Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Create and maintain your AWS Lambdas or Google Cloud Functions functions easily with LAMBD!
npm i -S lambd
const Lambd = require('lambd');
const { Platforms } = Lambd;
const myLambdaFunction = ({ request, response }) => {
// Here your lambda code
response.json({ ok: true, userid: request.params.userid });
});
// AWS Lambdas by default:
// Lambd.create()
// Google Cloud Functions
// Lambd.createFunctions()
// Otherwise
// You can use Platform enum object and select platform
module.exports.myFunction = Lambd.platform(Platforms.GCLOUD).get('/:userid', myLambdaFunction).getHandler();
// This allows you make compatible all your lambdas between AWS and GCLOUD Functions platforms only you must change platform on code.
const Lambd = require('lambd');
const myLambdaFunction = ({ response }) => {
// Here your functions code
response.json({ ok: true });
});
module.exports.handler = Lambd.createFunctions().get(myLambdaFunction).getHandler();
### API example
const Lambd = require('lambd');
const myLambda = Lambd.create();
// Middlewares
const authMiddleware = (next) => (options) => {
const { request, response } = options;
const { auth } = request;
if (auth && auth === 'esto_es_una_prueba') {
next(options);
} else {
response.status(403).error('not authorized');
}
};
const mongoMiddleware = (next) => (options) => {
const { response } = options;
const url = 'mongodb://localhost:27017/myproject';
MongoClient.connect(url, (err, db) => {
if (err) {
return response.error(err);
}
options.db = db;
return next(options);
});
};
myLambda.use(authMiddleware);
myLambda.use(mongoMiddleware);
// Route: /users/:userid
const handler = myLamba
.get(({ request, db }) => UserService(db).findById(request.params.userid))
.put('/:userid', ({ request, db }) => UserService(db).findByIdAndUpdate(request.params.userid, request.body))
.delete(':userid', ({ request, db }) => UserService(db).findByIdAndDelete(request.params.userid))
.getHandler();
module.exports.handler = handler;
LAMBD allows you use middlewares to add power to your lambda function.
const Lambd = require('lambd');
const { MongoClient } = require('mongodb');
const myLambdaFunction = ({ response, db }) => {
// Here your lambda code
db.collection('users').find({}).toArray((err, users) => {
if (err) {
return response.error(err);
}
return response.json({ ok: true, users });
});
});
const mongoMiddleware = (next) => (options) => {
const { response } = options;
const url = 'mongodb://localhost:27017/myproject';
MongoClient.connect(url, (err, db) => {
if (err) {
return response.error(err);
}
options.db = db;
return next(options);
});
};
// Global Middleware
// Lambd.use(mongoMiddleware);
// Lambda Middleware
const myLambda = Lambd.create();
myLambda.use(mongoMiddleware);
// Set headers to all lambdas
// Lambd.set('MyFirstHeader', 'value');
// Lambd.set({ 'MySecondHeader': 'value2', 'MyThirdHeader': 'value3' });
// Lambda header
myLambda.set('MyFirstHeader', 'value');
myLambda.set({ 'MySecondHeader': 'value2', 'MyThirdHeader': 'value3' });
module.exports.handler = myLambda.get(myLambdaFunction).getHandler();
FAQs
Create & mantain easily Google Cloud Functiosn and/or AWS Lambdas.
The npm package lambd receives a total of 5 weekly downloads. As such, lambd popularity was classified as not popular.
We found that lambd 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.