![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.
@commercetools-backend/express
Advanced tools
Zero-config HTTP server as Express.js to facilitate development
Zero-config HTTP server as Express.js to facilitate development.
This package is primarily built for HTTP servers used by Custom Applications and it provides a set of components to facilitate the development of the HTTP server.
$ npm install --save @commercetools-backend/express
This Express.js middleware should be used to handle the authentication exchange between the server and the /proxy/forward-to
endpoint of the Merchant Center API Gateway.
You can read more about the "Proxy to External API" concepts here.
const {
createSessionMiddleware,
CLOUD_IDENTIFIERS,
} = require('@commercetools-backend/express');
app.use(
createSessionMiddleware({
audience: 'https://my-api-server.com',
issuer: CLOUD_IDENTIFIERS.GCP_EU,
})
);
app.use((request, response, next) => {
// `request.session` contains the useful information
});
audience
(string): The public-facing URL of your API server. The value should only contain the origin URL (protocol, hostname, port), the request path is inferred from the incoming request.
issuer
(string): Either a cloud identifier or a valid URL to the Merchant Center API Gateway. The cloud identifier maps to the Merchant Center API URL of the related cloud region.
gcp-au
: https://mc-api.australia-southeast1.gcp.commercetools.com
gcp-eu
: https://mc-api.europe-west1.gcp.commercetools.com
gcp-us
: https://mc-api.us-central1.gcp.commercetools.com
aws-fra
: https://mc-api.eu-central-1.aws.commercetools.com
aws-ohio
: https://mc-api.us-east-2.aws.commercetools.com
inferIssuer
(boolean): Determines whether the issuer should be inferred from the custom request HTTP header x-mc-api-cloud-identifier
which is sent by the Merchant Center API Gateway when forwarding the request. This might be useful in case the server is used in multiple regions.
jwks
(object): See options of jwks-rsa
.
If your HTTP server runs as a Serverless Function, the Express.js middleware should not be needed. Instead you can use the underlying function that does not require the next
callback.
Example for Google Cloud Functions
const {
createSessionAuthVerifier,
CLOUD_IDENTIFIERS,
} = require('@commercetools-backend/express');
const sessionAuthVerifier = createSessionAuthVerifier({
audience: 'https://my-api-server.com',
issuer: CLOUD_IDENTIFIERS.GCP_EU,
});
exports.handler = async function (request, response) {
try {
await sessionAuthVerifier(request, response);
} catch (error) {
response.status(401).send(JSON.stringify({ message: 'Unauthorized' }));
return;
}
// `request.session` contains the useful information
};
The same concept applies for serverless functions in other cloud providers.
FAQs
Zero-config HTTP server as Express.js to facilitate development
The npm package @commercetools-backend/express receives a total of 48 weekly downloads. As such, @commercetools-backend/express popularity was classified as not popular.
We found that @commercetools-backend/express demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.