UNPKG

openapi-metadata

Version:

Auto-Generate OpenAPI specifications from Typescript decorators

31 lines (27 loc) 996 B
'use strict'; const noExplicitType = require('../errors/no-explicit-type.cjs'); const reflectMetadataMissing = require('../errors/reflect-metadata-missing.cjs'); function assertReflectMetadata() { if (typeof Reflect !== "object" || typeof Reflect.getMetadata !== "function") { throw new reflectMetadataMissing.ReflectMetadataMissingError(); } } function findType({ metadataKey, prototype, propertyKey }) { assertReflectMetadata(); const reflectedType = Reflect.getMetadata(metadataKey, prototype, propertyKey); if (!reflectedType) { throw new noExplicitType.NoExplicitTypeError(prototype.constructor.name, propertyKey); } return reflectedType; } const IS_THUNK_REG = /^.+=>[\w\d\s\t\n\r]*/; function isThunk(value) { if (typeof value !== "function") { return false; } return Boolean(IS_THUNK_REG.exec(value)); } exports.assertReflectMetadata = assertReflectMetadata; exports.findType = findType; exports.isThunk = isThunk; //# sourceMappingURL=metadata.cjs.map