![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@compassdigital/middleware
Advanced tools
Registering Provider-level middleware
const Middleware = require("@compassdigital/middleware").handler;
const ActionLogger = require("@compassdigital/middleware").fn.ActionLogger;
/**
* Inside the Provider constructor.
* The "bind" call is needed for this particular function but
* is not needed to make any custom middleware work with this
* package.
*/
this.middleware = new Middleware(ActionLogger.bind(this));
Registering handler-level middleware
const Middleware = require("@compassdigital/middleware").handler;
// Inside the domain-specific Provider
function bodyLogger (req, res, next) {
/**
* req: the request object from the lambda event
* res: the response object currently only holds a reference to user-defined local variables specific to the lifecycle of a single request
* next: the callback function to call when the middleware is finished work.
* - No parameters passes the middleware off to the next layer in the stack
* - Passing an error will cause the provider's error handler to take over and send the appropiate response
* - Passing true will skip the rest of the middleware for the current request
/
console.log(JSON.stringify(req.body));
return next();
}
Provider.on("post_test", "*:*:*", [ bodyLogger, async function (req, next) {
// Business logic here...
}]);
Feature flagging middleware provides an easy way to get state of flags in the req object.
const FeatureFlagging = require('@compassdigital/middleware').fn.FeatureFlagging;
You can register the middleware at the provider level with minimal boilerplate code.
UserProvider.use(FeatureFlagging.call(UserProvider));
Or at the handler level
Provider.on("post_test", "*:*:*", [FeatureFlagging(), async function (req, next) {
// Business logic here...
}]);
From here on, a feature_flags
property will be exposed on the req
object. You can then use the flags as
Provider.on("post_test", "*:*:*", async function (req, next) {
if (req.feature_flags.my_feature_1) doSomething();
});
For the middleware to be able to contact Split, an environment variable must be set in the provider's serverless.yml
file.
provider:
environment:
SPLIT_KEY: ${config:SPLIT_KEY}
Before the middleware hits Split to retrieve the flags, it gets a CDL config file that has a cache_time property. This tells the middleware how long it should hold on to the flags before getting them again from Split. This can be changed.
{
"is_split_enabled": true,
"cache_time": 10000
}
FAQs
CDL Provider middleware module
The npm package @compassdigital/middleware receives a total of 0 weekly downloads. As such, @compassdigital/middleware popularity was classified as not popular.
We found that @compassdigital/middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 54 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.