Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

sentry / @nestjs/websockets   js

Repository URL to install this package:

Version: 7.0.10 

/ gateway-metadata-explorer.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const constants_1 = require("./constants");
class GatewayMetadataExplorer {
    constructor(metadataScanner) {
        this.metadataScanner = metadataScanner;
    }
    explore(instance) {
        const instancePrototype = Object.getPrototypeOf(instance);
        return this.metadataScanner.scanFromPrototype(instance, instancePrototype, method => this.exploreMethodMetadata(instancePrototype, method));
    }
    exploreMethodMetadata(instancePrototype, methodName) {
        const callback = instancePrototype[methodName];
        const isMessageMapping = Reflect.getMetadata(constants_1.MESSAGE_MAPPING_METADATA, callback);
        if (shared_utils_1.isUndefined(isMessageMapping)) {
            return null;
        }
        const message = Reflect.getMetadata(constants_1.MESSAGE_METADATA, callback);
        return {
            callback,
            message,
            methodName,
        };
    }
    *scanForServerHooks(instance) {
        for (const propertyKey in instance) {
            if (shared_utils_1.isFunction(propertyKey)) {
                continue;
            }
            const property = String(propertyKey);
            const isServer = Reflect.getMetadata(constants_1.GATEWAY_SERVER_METADATA, instance, property);
            if (!shared_utils_1.isUndefined(isServer)) {
                yield property;
            }
        }
    }
}
exports.GatewayMetadataExplorer = GatewayMetadataExplorer;