當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript wicked-sdk.Callback類代碼示例

本文整理匯總了TypeScript中wicked-sdk.Callback的典型用法代碼示例。如果您正苦於以下問題:TypeScript Callback類的具體用法?TypeScript Callback怎麽用?TypeScript Callback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Callback類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: callback

    }, function (err, results) {
        if (err)
            return callback(err);
        const services = results.services as KongCollection<KongService>;
        const routes = results.routes as KongCollection<KongRoute>;

        // Step 1: Build a service id to service map
        const serviceIdMap = new Map<string, KongService>();
        for (let i = 0; i < services.data.length; ++i) {
            const s = services.data[i];
            serviceIdMap.set(s.id, s);
        }
        // Step 2: Match the routes to the services
        const kongApis: KongApi[] = [];
        for (let i = 0; i < routes.data.length; ++i) {
            const r = routes.data[i];
            if (!serviceIdMap.has(r.service.id)) {
                warn(`kongGetAllApis: Route ${r.id} with paths ${r.paths} has an unknown service id ${r.service.id}`);
                continue;
            }
            kongApis.push(wicked.kongServiceRouteToApi(serviceIdMap.get(r.service.id), r));
        }

        return callback(null, {
            data: kongApis
        });
    });
開發者ID:Haufe-Lexware,項目名稱:wicked.portal-kong-adapter,代碼行數:27,代碼來源:utils.ts

示例2: callback

        }, function (err, authServers: WickedAuthServer[]) {
            if (err)
                return callback(err);
            debug(JSON.stringify(authServers, null, 2));
            // Fix auth server and API auth server IDs; also adapt
            // the upstream_url (canonicalize it).
            for (let i = 0; i < authServers.length; ++i) {
                const as = authServers[i] as WickedAuthServer;
                const id = `${authServerNames[i]}-auth`;
                as.id = id;
                if (as.config.api.hasOwnProperty('id'))
                    delete as.config.api.id;
                as.config.api.name = id;

                try {
                    const url = new URL(as.config.api.upstream_url);
                    as.config.api.upstream_url = url.toString();
                } catch (err) {
                    const msg = `getAuthServerApis(): upstream_url for auth server ${authServerNames[i]} is not a valid URL: ${as.config.api.upstream_url}`;
                    return callback(new WickedError(msg, 500));
                }

                checkApiConfig(as.config);
            }
            callback(null, authServers);
        });
開發者ID:Haufe-Lexware,項目名稱:wicked.portal-kong-adapter,代碼行數:26,代碼來源:portal.ts

示例3: callback

    wicked.getWebhookEvents('kong-adapter', function (err, pendingEvents) {
        if (err) {
            error('COULD NOT RETRIEVE WEBHOOKS')
            return callback(err);
        }
        const duration = (new Date().getTime() - now);
        debug(`processPendingWebhooks: Retrieved ${pendingEvents.length} events in ${duration}ms`);
        const onlyDelete = false;
        if (pendingEvents.length === 0)
            return callback(null, false);

        async.eachSeries(pendingEvents, (webhookData: WickedEvent, callback) => {
            const now = new Date().getTime();
            dispatchWebhookAction(webhookData, onlyDelete, function (err) {
                const duration = (new Date().getTime() - now);
                debug(`processPendingWebhooks: Processed ${webhookData.action} ${webhookData.entity} event in ${duration}ms`);
                if (err)
                    return callback(err);
                return callback(null);
            });
        }, function (err) {
            if (err) {
                error('An error occurred during dispatching events.');
                error(err);
                return callback(err);
            }
            return callback(null, true);
        });
    });
開發者ID:Haufe-Lexware,項目名稱:wicked.portal-kong-adapter,代碼行數:29,代碼來源:main.ts

示例4: callback

 function (err, results) {
     if (err) {
         error(err);
         error(err.stack);
         return callback(err);
     }
     debug('getKongConsumers() succeeded.');
     return callback(null, results as ConsumerInfo[]);
 });
開發者ID:Haufe-Lexware,項目名稱:wicked.portal-kong-adapter,代碼行數:9,代碼來源:kong.ts


注:本文中的wicked-sdk.Callback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。