common-services
Advanced tools
Comparing version 7.1.4 to 7.1.5
@@ -0,1 +1,10 @@ | ||
## [7.1.5](https://github.com/nfroidure/common-services/compare/v7.1.4...v7.1.5) (2020-07-17) | ||
### Bug Fixes | ||
* **process:** cleanup the process service listeners ([8b91cac](https://github.com/nfroidure/common-services/commit/8b91cac54c00d9a44c6c121466c0ae41b59a2c36)) | ||
## [7.1.4](https://github.com/nfroidure/common-services/compare/v7.1.3...v7.1.4) (2020-04-03) | ||
@@ -2,0 +11,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { LogService } from './log'; | ||
import { RandomService } from './random'; | ||
import type { LogService } from './log'; | ||
import type { RandomService } from './random'; | ||
export declare type CodeGeneratorServiceConfig = { | ||
@@ -4,0 +4,0 @@ CHARS_SET?: string; |
@@ -1,2 +0,2 @@ | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
export interface CounterService { | ||
@@ -3,0 +3,0 @@ (): Promise<number>; |
@@ -1,2 +0,2 @@ | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
export interface DelayProvider { | ||
@@ -3,0 +3,0 @@ service: DelayService; |
@@ -1,3 +0,3 @@ | ||
import { LogService } from './log'; | ||
import { DelayService } from './delay'; | ||
import type { LogService } from './log'; | ||
import type { DelayService } from './delay'; | ||
interface Lock { | ||
@@ -4,0 +4,0 @@ releasePromise: Promise<void>; |
@@ -1,7 +0,8 @@ | ||
import Knifecycle, { FatalErrorProvider } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
/// <reference types="node" /> | ||
import type { Knifecycle, FatalErrorProvider } from 'knifecycle'; | ||
import type { LogService } from './log'; | ||
export declare type ProcessServiceConfig = { | ||
NODE_ENV?: string; | ||
PROCESS_NAME?: string; | ||
SIGNALS?: string[]; | ||
SIGNALS?: NodeJS.Signals[]; | ||
NODE_ENVS?: string[]; | ||
@@ -27,2 +28,5 @@ }; | ||
*/ | ||
declare function initProcess({ NODE_ENV, PROCESS_NAME, SIGNALS, NODE_ENVS, log, exit, $instance, $fatalError, }: ProcessServiceDependencies): Promise<typeof global.process>; | ||
declare function initProcess({ NODE_ENV, PROCESS_NAME, SIGNALS, NODE_ENVS, log, exit, $instance, $fatalError, }: ProcessServiceDependencies): Promise<{ | ||
service: NodeJS.Process; | ||
dispose: () => Promise<void>; | ||
}>; |
@@ -27,3 +27,3 @@ "use strict"; | ||
singleton: true | ||
}, (0, _knifecycle.autoService)(initProcess), true); | ||
}, (0, _knifecycle.autoProvider)(initProcess), true); | ||
/** | ||
@@ -53,2 +53,3 @@ * Instantiate the process service | ||
let shuttingDown = null; | ||
let signalsListeners = SIGNALS.map(signal => [signal, terminate.bind(null, signal)]); | ||
/* Architecture Note #1.5.1: Node environment filtering | ||
@@ -74,4 +75,4 @@ It also forces NODE_ENV to be set to avoid unintentionnal | ||
SIGNALS.forEach(signal => { | ||
global.process.on(signal, terminate.bind(null, signal)); | ||
signalsListeners.forEach(([signal, signalListener]) => { | ||
global.process.on(signal, signalListener); | ||
}); | ||
@@ -94,7 +95,9 @@ /* Architecture Note #1.5.3: Handling services fatal errors | ||
global.process.on('uncaughtException', err => { | ||
global.process.on('uncaughtException', catchUncaughtException); | ||
function catchUncaughtException(err) { | ||
log('error', '💀 - Uncaught Exception'); | ||
log('stack', err.stack || err); | ||
terminate('ERR'); | ||
}); | ||
} | ||
@@ -126,5 +129,15 @@ function terminate(signal) { | ||
async function dispose() { | ||
global.process.removeListener('uncaughtException', catchUncaughtException); | ||
signalsListeners.forEach(([signal, signalListener]) => { | ||
global.process.removeListener(signal, signalListener); | ||
}); | ||
} | ||
log('debug', '📇 - Process service initialized.'); | ||
return global.process; | ||
return { | ||
service: global.process, | ||
dispose | ||
}; | ||
} | ||
//# sourceMappingURL=process.js.map |
@@ -1,2 +0,2 @@ | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
export interface RandomService { | ||
@@ -3,0 +3,0 @@ (): number; |
@@ -1,2 +0,2 @@ | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
export interface TimeService { | ||
@@ -3,0 +3,0 @@ (): number; |
@@ -1,2 +0,2 @@ | ||
import { TimeService } from './time'; | ||
import type { TimeService } from './time'; | ||
declare const _default: ({ log, }: { | ||
@@ -3,0 +3,0 @@ log?: import("./log").LogService; |
{ | ||
"name": "common-services", | ||
"version": "7.1.4", | ||
"version": "7.1.5", | ||
"description": "A module to gather very common services and their mocks.", | ||
@@ -42,28 +42,28 @@ "main": "dist/index", | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.9.0", | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"@babel/register": "^7.9.0", | ||
"@types/jest": "^25.1.4", | ||
"@typescript-eslint/eslint-plugin": "^2.26.0", | ||
"@typescript-eslint/parser": "^2.26.0", | ||
"@types/jest": "^25.2.2", | ||
"@typescript-eslint/eslint-plugin": "^2.33.0", | ||
"@typescript-eslint/parser": "^2.33.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-plugin-knifecycle": "^1.2.0", | ||
"commitizen": "^4.0.3", | ||
"conventional-changelog-cli": "^2.0.31", | ||
"coveralls": "^3.0.11", | ||
"cz-conventional-changelog": "^3.1.0", | ||
"eslint": "^6.8.0", | ||
"commitizen": "^4.1.2", | ||
"conventional-changelog-cli": "^2.0.34", | ||
"coveralls": "^3.1.0", | ||
"cz-conventional-changelog": "^3.2.0", | ||
"eslint": "^7.0.0", | ||
"eslint-config-typescript": "^3.0.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"jest": "^25.2.4", | ||
"jsarch": "^2.0.3", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^26.0.1", | ||
"jsarch": "^3.0.0", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"metapak": "^3.1.8", | ||
"metapak-nfroidure": "10.1.2", | ||
"prettier": "^2.0.2", | ||
"metapak": "^3.1.10", | ||
"metapak-nfroidure": "10.2.1", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^3.8.3" | ||
"typescript": "^3.9.2" | ||
}, | ||
@@ -113,5 +113,5 @@ "scripts": { | ||
"dependencies": { | ||
"@types/node": "^13.9.8", | ||
"@types/node": "^14.0.23", | ||
"knifecycle": "^9.1.1", | ||
"sinon": "^9.0.1", | ||
"sinon": "^9.0.2", | ||
"yerror": "^5.0.0" | ||
@@ -255,3 +255,3 @@ }, | ||
}, | ||
"modules": "false" | ||
"modules": false | ||
} | ||
@@ -258,0 +258,0 @@ ] |
import initCodeGenerator from './codeGenerator'; | ||
import { RandomService } from './random'; | ||
import type { RandomService } from './random'; | ||
@@ -4,0 +4,0 @@ describe('codeGenerator', () => { |
import { autoService } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import { RandomService } from './random'; | ||
import type { LogService } from './log'; | ||
import type { RandomService } from './random'; | ||
@@ -5,0 +5,0 @@ function noop() {} |
import { autoService, options } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
@@ -4,0 +4,0 @@ function noop() {} |
import YError from 'yerror'; | ||
import initDelayService, { DelayService } from './delay'; | ||
import initDelayService from './delay'; | ||
import { reuseSpecialProps } from 'knifecycle'; | ||
import type { DelayService } from './delay'; | ||
@@ -5,0 +6,0 @@ /* Architecture Note #1.4.1: Mocking delays |
import YError from 'yerror'; | ||
import { autoProvider, options } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
@@ -5,0 +5,0 @@ function noop() {} |
@@ -5,3 +5,3 @@ import assert from 'assert'; | ||
import initLockService from './lock'; | ||
import { DelayService } from './delay'; | ||
import type { DelayService } from './delay'; | ||
@@ -8,0 +8,0 @@ describe('initLockService', () => { |
import YError from 'yerror'; | ||
import { autoService, options } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import { DelayService } from './delay'; | ||
import type { LogService } from './log'; | ||
import type { DelayService } from './delay'; | ||
@@ -6,0 +6,0 @@ const noop = () => {}; |
import YError from 'yerror'; | ||
import Knifecycle, { | ||
autoService, | ||
options, | ||
FatalErrorProvider, | ||
} from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import { autoProvider, options } from 'knifecycle'; | ||
import type { Knifecycle, FatalErrorProvider } from 'knifecycle'; | ||
import type { LogService } from './log'; | ||
const DEFAULT_NODE_ENVS = ['development', 'test', 'production']; | ||
const DEFAULT_SIGNALS = ['SIGTERM', 'SIGINT']; | ||
const DEFAULT_SIGNALS: NodeJS.Signals[] = ['SIGTERM', 'SIGINT']; | ||
@@ -17,3 +14,3 @@ function noop() {} | ||
PROCESS_NAME?: string; | ||
SIGNALS?: string[]; | ||
SIGNALS?: NodeJS.Signals[]; | ||
NODE_ENVS?: string[]; | ||
@@ -36,3 +33,3 @@ }; | ||
export default options({ singleton: true }, autoService(initProcess), true); | ||
export default options({ singleton: true }, autoProvider(initProcess), true); | ||
@@ -57,4 +54,10 @@ /** | ||
$fatalError, | ||
}: ProcessServiceDependencies): Promise<typeof global.process> { | ||
}: ProcessServiceDependencies): Promise<{ | ||
service: NodeJS.Process; | ||
dispose: () => Promise<void>; | ||
}> { | ||
let shuttingDown = null; | ||
let signalsListeners = SIGNALS.map<[NodeJS.Signals, NodeJS.SignalsListener]>( | ||
(signal) => [signal, terminate.bind(null, signal)], | ||
); | ||
@@ -84,4 +87,4 @@ /* Architecture Note #1.5.1: Node environment filtering | ||
*/ | ||
SIGNALS.forEach((signal) => { | ||
global.process.on(signal as NodeJS.Signals, terminate.bind(null, signal)); | ||
signalsListeners.forEach(([signal, signalListener]) => { | ||
global.process.on(signal, signalListener); | ||
}); | ||
@@ -106,7 +109,9 @@ | ||
*/ | ||
global.process.on('uncaughtException', (err) => { | ||
global.process.on('uncaughtException', catchUncaughtException); | ||
function catchUncaughtException(err) { | ||
log('error', '💀 - Uncaught Exception'); | ||
log('stack', err.stack || err); | ||
terminate('ERR'); | ||
}); | ||
} | ||
@@ -141,4 +146,14 @@ function terminate(signal) { | ||
async function dispose() { | ||
global.process.removeListener('uncaughtException', catchUncaughtException); | ||
signalsListeners.forEach(([signal, signalListener]) => { | ||
global.process.removeListener(signal, signalListener); | ||
}); | ||
} | ||
log('debug', '📇 - Process service initialized.'); | ||
return global.process; | ||
return { | ||
service: global.process, | ||
dispose, | ||
}; | ||
} |
import { autoService, options } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
@@ -4,0 +4,0 @@ function noop() {} |
import sinon from 'sinon'; | ||
import initTimeService, { TimeService } from './time'; | ||
import initTimeService from './time'; | ||
import { reuseSpecialProps } from 'knifecycle'; | ||
import type { TimeService } from './time'; | ||
@@ -5,0 +6,0 @@ /* Architecture Note #1.2.1: Mocking time |
import { autoService, options } from 'knifecycle'; | ||
import { LogService } from './log'; | ||
import type { LogService } from './log'; | ||
@@ -4,0 +4,0 @@ function noop() {} |
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
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
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
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
395824
4963
+ Added@types/node@14.18.63(transitive)
- Removed@types/node@13.13.52(transitive)
Updated@types/node@^14.0.23
Updatedsinon@^9.0.2