UNPKG

alpha-dic

Version:

Asynchronous dependency injection container

24 lines (23 loc) 942 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deprecatedMiddleware = exports.deprecated = exports.deprecatedAnnotationName = void 0; exports.deprecatedAnnotationName = '__deprecatedService'; function deprecated(note) { return { name: exports.deprecatedAnnotationName, note }; } exports.deprecated = deprecated; function deprecatedMiddleware(messageFunc = console.warn) { return (definition, next) => { const deprecatedAnnotations = definition.annotations .filter(d => d && d.name === exports.deprecatedAnnotationName); if (deprecatedAnnotations.length) { const deprecationNote = deprecatedAnnotations.map(d => d.note).join(', '); messageFunc(`Service ${definition.name.toString()} is deprecated: ` + deprecationNote); } return next(definition); }; } exports.deprecatedMiddleware = deprecatedMiddleware;