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 6.8.0 to 7.0.0

2

dist/src/factories/createLightship.d.ts
import type { ConfigurationInput, Lightship } from '../types';
declare const _default: (userConfiguration?: ConfigurationInput | undefined) => Lightship;
declare const _default: (userConfiguration?: ConfigurationInput | undefined) => Promise<Lightship>;
export default _default;

@@ -9,4 +9,3 @@ "use strict";

const delay_1 = __importDefault(require("delay"));
const express_1 = __importDefault(require("express"));
const http_terminator_1 = require("http-terminator");
const fastify_1 = __importDefault(require("fastify"));
const serialize_error_1 = require("serialize-error");

@@ -38,3 +37,3 @@ const Logger_1 = __importDefault(require("../Logger"));

};
exports.default = (userConfiguration) => {
exports.default = async (userConfiguration) => {
let blockingTasks = [];

@@ -67,51 +66,51 @@ let resolveFirstReady;

};
const app = (0, express_1.default)();
const modeIsLocal = configuration.detectKubernetes === true && (0, utilities_1.isKubernetes)() === false;
const server = app.listen(modeIsLocal ? undefined : configuration.port, () => {
const address = server.address();
log.info('Lightship HTTP service is running on port %s', address.port);
const app = (0, fastify_1.default)();
app.addHook('onError', (request, reply, error, done) => {
// Only send Sentry errors when not in development
// eslint-disable-next-line node/no-process-env
if (process.env.NODE_ENV !== 'development') {
(0, node_1.captureException)(error);
}
done();
});
const httpTerminator = (0, http_terminator_1.createHttpTerminator)({
server,
});
app.use(node_1.Handlers.requestHandler());
app.get('/health', (incomingMessage, serverResponse) => {
app.get('/health', (request, reply) => {
if (serverIsShuttingDown) {
serverResponse
.status(500)
void reply
.code(500)
.send(states_1.SERVER_IS_SHUTTING_DOWN);
}
else if (serverIsReady) {
serverResponse
void reply
.send(states_1.SERVER_IS_READY);
}
else {
serverResponse
.status(500)
void reply
.code(500)
.send(states_1.SERVER_IS_NOT_READY);
}
});
app.get('/live', (incomingMessage, serverResponse) => {
app.get('/live', (request, reply) => {
if (serverIsShuttingDown) {
serverResponse
.status(500)
void reply
.code(500)
.send(states_1.SERVER_IS_SHUTTING_DOWN);
}
else {
serverResponse
void reply
.send(states_1.SERVER_IS_NOT_SHUTTING_DOWN);
}
});
app.get('/ready', (incomingMessage, serverResponse) => {
app.get('/ready', (request, reply) => {
if (isServerReady()) {
serverResponse
void reply
.send(states_1.SERVER_IS_READY);
}
else {
serverResponse
.status(500)
void reply
.code(500)
.send(states_1.SERVER_IS_NOT_READY);
}
});
app.use(node_1.Handlers.errorHandler());
const modeIsLocal = configuration.detectKubernetes === true && (0, utilities_1.isKubernetes)() === false;
await app.listen(modeIsLocal ? 0 : configuration.port, '0.0.0.0');
const signalNotReady = () => {

@@ -205,3 +204,3 @@ if (serverIsReady === false) {

log.debug('all shutdown handlers have run to completion; proceeding to terminate the Node.js process');
await httpTerminator.terminate();
void app.close();
setTimeout(() => {

@@ -262,3 +261,3 @@ log.warn('process did not exit on its own; investigate what is keeping the event loop active');

},
server,
server: app.server,
shutdown: () => {

@@ -265,0 +264,0 @@ return shutdown(false);

@@ -21,4 +21,3 @@ {

"delay": "^5.0.0",
"express": "^4.17.1",
"http-terminator": "^3.0.4",
"fastify": "^3.27.2",
"roarr": "^7.8.0",

@@ -30,3 +29,2 @@ "serialize-error": "^8.1.0"

"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/express": "^4.17.13",
"@types/http-terminator": "^2.0.2",

@@ -71,7 +69,7 @@ "@types/node": "^16.9.2",

"generate-readme": "gitdown ./.README/README.md --output-file ./README.md",
"lint": "eslint ./src ./test --ext .js --ext .ts",
"lint": "eslint ./src ./test",
"test": "NODE_ENV=test ava --verbose --serial",
"typecheck": "tsc --noEmit"
},
"version": "6.8.0"
"version": "7.0.0"
}

@@ -109,3 +109,3 @@ <a name="lightship"></a>

const lightship: Lightship = createLightship(configuration);
const lightship: Lightship = await createLightship(configuration);

@@ -228,3 +228,3 @@ ```

const lightship = createLightship();
const lightship = await createLightship();

@@ -265,3 +265,3 @@ lightship.queueBlockingTask(new Promise((resolve) => {

const lightship = createLightship();
const lightship = await createLightship();

@@ -333,3 +333,3 @@ const app = express();

const lightship = createLightship();
const lightship = await createLightship();

@@ -376,3 +376,3 @@ lightship.registerShutdownHandler(() => {

const lightship = createLightship();
const lightship = await createLightship();

@@ -433,3 +433,3 @@ lightship.registerShutdownHandler(() => {

const lightship = createLightship();
const lightship = await createLightship();

@@ -462,3 +462,3 @@ lightship.registerShutdownHandler(async () => {

```js
const lightship = createLightship();
const lightship = await createLightship();

@@ -620,3 +620,3 @@ const beacon = lightship.createBeacon();

const lightship = createLightship();
const lightship = await createLightship();

@@ -623,0 +623,0 @@ lightship.registerShutdownHandler(() => {

import {
EventEmitter,
} from 'events';
import type {
AddressInfo,
} from 'net';
import {
Handlers as SentryHandlers,
captureException,
} from '@sentry/node';
import delay from 'delay';
import express from 'express';
import createFastify from 'fastify';
import {
createHttpTerminator,
} from 'http-terminator';
import {
serializeError,

@@ -68,3 +62,3 @@ } from 'serialize-error';

export default (userConfiguration?: ConfigurationInput): Lightship => {
export default async (userConfiguration?: ConfigurationInput): Promise<Lightship> => {
let blockingTasks: BlockingTask[] = [];

@@ -109,28 +103,25 @@

const app = express();
const app = createFastify();
const modeIsLocal = configuration.detectKubernetes === true && isKubernetes() === false;
app.addHook('onError', (request, reply, error, done) => {
// Only send Sentry errors when not in development
// eslint-disable-next-line node/no-process-env
if (process.env.NODE_ENV !== 'development') {
captureException(error);
}
const server = app.listen(modeIsLocal ? undefined : configuration.port, () => {
const address = server.address() as AddressInfo;
log.info('Lightship HTTP service is running on port %s', address.port);
done();
});
const httpTerminator = createHttpTerminator({
server,
});
app.use(SentryHandlers.requestHandler());
app.get('/health', (incomingMessage, serverResponse) => {
app.get('/health', (request, reply) => {
if (serverIsShuttingDown) {
serverResponse
.status(500)
void reply
.code(500)
.send(SERVER_IS_SHUTTING_DOWN);
} else if (serverIsReady) {
serverResponse
void reply
.send(SERVER_IS_READY);
} else {
serverResponse
.status(500)
void reply
.code(500)
.send(SERVER_IS_NOT_READY);

@@ -140,9 +131,9 @@ }

app.get('/live', (incomingMessage, serverResponse) => {
app.get('/live', (request, reply) => {
if (serverIsShuttingDown) {
serverResponse
.status(500)
void reply
.code(500)
.send(SERVER_IS_SHUTTING_DOWN);
} else {
serverResponse
void reply
.send(SERVER_IS_NOT_SHUTTING_DOWN);

@@ -152,9 +143,9 @@ }

app.get('/ready', (incomingMessage, serverResponse) => {
app.get('/ready', (request, reply) => {
if (isServerReady()) {
serverResponse
void reply
.send(SERVER_IS_READY);
} else {
serverResponse
.status(500)
void reply
.code(500)
.send(SERVER_IS_NOT_READY);

@@ -164,4 +155,6 @@ }

app.use(SentryHandlers.errorHandler());
const modeIsLocal = configuration.detectKubernetes === true && isKubernetes() === false;
await app.listen(modeIsLocal ? 0 : configuration.port, '0.0.0.0');
const signalNotReady = () => {

@@ -287,3 +280,3 @@ if (serverIsReady === false) {

await httpTerminator.terminate();
void app.close();

@@ -357,3 +350,3 @@ setTimeout(() => {

},
server,
server: app.server,
shutdown: () => {

@@ -360,0 +353,0 @@ return shutdown(false);

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