Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightship

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightship - npm Package Compare versions

Comparing version 9.0.2 to 9.0.3

55

dist/cjs/factories/createLightship.js

@@ -0,10 +1,16 @@

"use strict";
/* eslint-disable promise/prefer-await-to-then */
import { Logger } from '../Logger.js';
import { SERVER_IS_NOT_READY, SERVER_IS_NOT_SHUTTING_DOWN, SERVER_IS_READY, SERVER_IS_SHUTTING_DOWN, } from '../states.js';
import { isKubernetes } from '../utilities/isKubernetes.js';
import delay from 'delay';
import createFastify from 'fastify';
import { EventEmitter } from 'node:events';
import { serializeError } from 'serialize-error';
const log = Logger.child({
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLightship = void 0;
const Logger_js_1 = require("../Logger.js");
const states_js_1 = require("../states.js");
const isKubernetes_js_1 = require("../utilities/isKubernetes.js");
const delay_1 = __importDefault(require("delay"));
const fastify_1 = __importDefault(require("fastify"));
const node_events_1 = require("node:events");
const serialize_error_1 = require("serialize-error");
const log = Logger_js_1.Logger.child({
namespace: 'factories/createLightship',

@@ -27,3 +33,3 @@ });

};
export const createLightship = async (userConfiguration) => {
const createLightship = async (userConfiguration) => {
let blockingTasks = [];

@@ -36,3 +42,3 @@ let resolveFirstReady;

});
const eventEmitter = new EventEmitter();
const eventEmitter = new node_events_1.EventEmitter();
const beacons = [];

@@ -44,3 +50,3 @@ const shutdownHandlers = [];

};
const modeIsLocal = configuration.detectKubernetes === true && isKubernetes() === false;
const modeIsLocal = configuration.detectKubernetes === true && (0, isKubernetes_js_1.isKubernetes)() === false;
if (modeIsLocal) {

@@ -66,3 +72,3 @@ log.info('running in local mode');

};
const app = createFastify({
const app = (0, fastify_1.default)({
exposeHeadRoutes: true,

@@ -72,3 +78,3 @@ });

log.error({
error: serializeError(error),
error: (0, serialize_error_1.serializeError)(error),
}, 'lightship error');

@@ -79,9 +85,9 @@ done();

if (serverIsShuttingDown) {
await reply.code(500).send(SERVER_IS_SHUTTING_DOWN);
await reply.code(500).send(states_js_1.SERVER_IS_SHUTTING_DOWN);
}
else if (serverIsReady) {
await reply.send(SERVER_IS_READY);
await reply.send(states_js_1.SERVER_IS_READY);
}
else {
await reply.code(500).send(SERVER_IS_NOT_READY);
await reply.code(500).send(states_js_1.SERVER_IS_NOT_READY);
}

@@ -91,6 +97,6 @@ });

if (serverIsShuttingDown) {
await reply.code(500).send(SERVER_IS_SHUTTING_DOWN);
await reply.code(500).send(states_js_1.SERVER_IS_SHUTTING_DOWN);
}
else {
await reply.send(SERVER_IS_NOT_SHUTTING_DOWN);
await reply.send(states_js_1.SERVER_IS_NOT_SHUTTING_DOWN);
}

@@ -100,6 +106,6 @@ });

if (isServerReady()) {
await reply.send(SERVER_IS_READY);
await reply.send(states_js_1.SERVER_IS_READY);
}
else {
await reply.code(500).send(SERVER_IS_NOT_READY);
await reply.code(500).send(states_js_1.SERVER_IS_NOT_READY);
}

@@ -144,3 +150,3 @@ });

log.debug('delaying shutdown handler by %d seconds', configuration.shutdownDelay / 1000);
await delay(configuration.shutdownDelay);
await (0, delay_1.default)(configuration.shutdownDelay);
}

@@ -192,3 +198,3 @@ let gracefulShutdownTimeoutId;

log.error({
error: serializeError(error),
error: (0, serialize_error_1.serializeError)(error),
}, 'shutdown handler produced an error');

@@ -227,3 +233,3 @@ }

eventEmitter.emit('beaconStateChange');
await delay(0);
await (0, delay_1.default)(0);
},

@@ -238,3 +244,3 @@ };

log.error({
error: serializeError(error),
error: (0, serialize_error_1.serializeError)(error),
}, 'service failed to become available for the first time');

@@ -276,1 +282,2 @@ await shutdown(false);

};
exports.createLightship = createLightship;

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

export { createLightship } from './factories/createLightship.js';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLightship = void 0;
var createLightship_js_1 = require("./factories/createLightship.js");
Object.defineProperty(exports, "createLightship", { enumerable: true, get: function () { return createLightship_js_1.createLightship; } });

@@ -1,1 +0,1 @@

export declare const Logger: import("roarr").Logger<import("roarr/dist/types.js").JsonObject>;
export declare const Logger: import("roarr").Logger<import("roarr/dist/types").JsonObject>;

@@ -1,4 +0,7 @@

import { Roarr } from 'roarr';
export const Logger = Roarr.child({
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const roarr_1 = require("roarr");
exports.Logger = roarr_1.Roarr.child({
package: 'lightship',
});

@@ -0,7 +1,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SERVER_IS_SHUTTING_DOWN = exports.SERVER_IS_READY = exports.SERVER_IS_NOT_SHUTTING_DOWN = exports.SERVER_IS_NOT_READY = void 0;
const createState = (subject) => {
return subject;
};
export const SERVER_IS_NOT_READY = createState('SERVER_IS_NOT_READY');
export const SERVER_IS_NOT_SHUTTING_DOWN = createState('SERVER_IS_NOT_SHUTTING_DOWN');
export const SERVER_IS_READY = createState('SERVER_IS_READY');
export const SERVER_IS_SHUTTING_DOWN = createState('SERVER_IS_SHUTTING_DOWN');
exports.SERVER_IS_NOT_READY = createState('SERVER_IS_NOT_READY');
exports.SERVER_IS_NOT_SHUTTING_DOWN = createState('SERVER_IS_NOT_SHUTTING_DOWN');
exports.SERVER_IS_READY = createState('SERVER_IS_READY');
exports.SERVER_IS_SHUTTING_DOWN = createState('SERVER_IS_SHUTTING_DOWN');

@@ -1,2 +0,2 @@

/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" />
import { type Server } from 'node:http';

@@ -3,0 +3,0 @@ /**

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,4 +0,8 @@

export const isKubernetes = () => {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isKubernetes = void 0;
const isKubernetes = () => {
// eslint-disable-next-line node/no-process-env
return Boolean(process.env.KUBERNETES_SERVICE_HOST);
};
exports.isKubernetes = isKubernetes;

@@ -39,3 +39,3 @@ {

"tsx": "^3.12.7",
"typescript": "^5.0.4"
"typescript": "^5.2.2"
},

@@ -75,3 +75,3 @@ "engines": {

"types": "./dist/esm/index.d.ts",
"version": "9.0.2"
"version": "9.0.3"
}
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