New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vue-storefront/middleware

Package Overview
Dependencies
Maintainers
0
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue-storefront/middleware - npm Package Compare versions

Comparing version 4.3.1 to 4.4.0-terminus.0

5

lib/createServer.d.ts

@@ -1,5 +0,6 @@

import type { Express } from "express";
/// <reference types="node" />
import { Server } from "node:http";
import type { IntegrationContext, MiddlewareConfig, CreateServerOptions } from "./types";
declare function createServer<TIntegrationContext extends Record<string, IntegrationContext>>(config: MiddlewareConfig<TIntegrationContext>, options?: CreateServerOptions): Promise<Express>;
declare function createServer<TIntegrationContext extends Record<string, IntegrationContext>>(config: MiddlewareConfig<TIntegrationContext>, options?: CreateServerOptions): Promise<Server>;
export { createServer };
//# sourceMappingURL=createServer.d.ts.map

31

lib/index.cjs.js

@@ -10,2 +10,5 @@ 'use strict';

var helmet = require('helmet');
var http = require('node:http');
var terminus = require('@godaddy/terminus');
var promises = require('node:timers/promises');

@@ -19,2 +22,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var helmet__default = /*#__PURE__*/_interopDefaultLegacy(helmet);
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);

@@ -371,7 +375,32 @@ /**

app.get("/:integrationName/:extensionName?/:functionName", prepareApiFunction(integrations), prepareErrorHandler(integrations), prepareArguments, callApiFunction);
// This could instead be implemented as a healthcheck within terminus, but we don't want /healthz to change response if app received SIGTERM
app.get("/healthz", (_req, res) => {
res.end("ok");
});
const terminusOptions = {
// health check options
healthChecks: {
verbatim: true,
"/readyz": async () => {
if (!Array.isArray(options.readinessChecks) ||
options.readinessChecks.length === 0) {
return;
}
const calledReadinessChecks = options.readinessChecks.map((fn) => fn());
const readinessErrors = (await Promise.allSettled(calledReadinessChecks)).reduce((errors, settledReadinessCheck) => settledReadinessCheck.status === "rejected"
? [...errors, settledReadinessCheck.reason]
: errors, []);
if (readinessErrors.length) {
throw new terminus.HealthCheckError("Readiness check failed", readinessErrors);
}
},
},
// In case some requests are still being handled when SIGTERM was received, naively wait in hopes that they will be resolved in that time, and only then shut down the process
beforeShutdown: () => promises.setTimeout(10 ** 4),
useExit0: true,
};
const server = http__default["default"].createServer(app);
terminus.createTerminus(server, terminusOptions);
consola__default["default"].success("Middleware created!");
return app;
return server;
}

@@ -378,0 +407,0 @@

@@ -6,2 +6,5 @@ import consola from 'consola';

import helmet from 'helmet';
import http from 'node:http';
import { createTerminus, HealthCheckError } from '@godaddy/terminus';
import { setTimeout } from 'node:timers/promises';

@@ -358,7 +361,32 @@ /**

app.get("/:integrationName/:extensionName?/:functionName", prepareApiFunction(integrations), prepareErrorHandler(integrations), prepareArguments, callApiFunction);
// This could instead be implemented as a healthcheck within terminus, but we don't want /healthz to change response if app received SIGTERM
app.get("/healthz", (_req, res) => {
res.end("ok");
});
const terminusOptions = {
// health check options
healthChecks: {
verbatim: true,
"/readyz": async () => {
if (!Array.isArray(options.readinessChecks) ||
options.readinessChecks.length === 0) {
return;
}
const calledReadinessChecks = options.readinessChecks.map((fn) => fn());
const readinessErrors = (await Promise.allSettled(calledReadinessChecks)).reduce((errors, settledReadinessCheck) => settledReadinessCheck.status === "rejected"
? [...errors, settledReadinessCheck.reason]
: errors, []);
if (readinessErrors.length) {
throw new HealthCheckError("Readiness check failed", readinessErrors);
}
},
},
// In case some requests are still being handled when SIGTERM was received, naively wait in hopes that they will be resolved in that time, and only then shut down the process
beforeShutdown: () => setTimeout(10 ** 4),
useExit0: true,
};
const server = http.createServer(app);
createTerminus(server, terminusOptions);
consola.success("Middleware created!");
return app;
return server;
}

@@ -365,0 +393,0 @@

@@ -78,2 +78,8 @@ import { CorsOptions, CorsOptionsDelegate } from "cors";

export type CreateApiProxyFn = <CONFIG, API, CLIENT>(givenConfig: any, customApi?: any) => ApiInstance<CONFIG, API, CLIENT>;
/**
* Function that will be called to determine process readiness.
* @returns Return value is never considered - only thrown exceptions
* @throws The implementation *must* throw an exception at some point in the code, which means that the readiness check should fail
*/
export type ReadinessCheck = () => Promise<void>;
export interface CreateServerOptions {

@@ -107,3 +113,9 @@ /**

cors?: CorsOptions | CorsOptionsDelegate;
/**
* Array of functions that will be called in parallel every time the /readyz endpoint receives a GET request
* If at least one function throws an exception, the response from the /readyz endpoint will report an error
* @see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-readiness-probes
*/
readinessChecks?: ReadinessCheck[];
}
//# sourceMappingURL=server.d.ts.map
{
"name": "@vue-storefront/middleware",
"version": "4.3.1",
"version": "4.4.0-terminus.0",
"main": "lib/index.cjs.js",

@@ -23,2 +23,3 @@ "module": "lib/index.es.js",

"dependencies": {
"@godaddy/terminus": "^4.12.1",
"consola": "^2.15.3",

@@ -25,0 +26,0 @@ "cookie-parser": "^1.4.6",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc