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


TypeScript nats-hemera.ready函數代碼示例

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


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

示例1: it

    it('Should be able to add two numbers', function (done) {
        const nats = require('nats').connect();

        const hemera = new Hemera(nats, { logLevel: 'info' });
        hemera.use(Plugin1);

        hemera.ready(() => {
            hemera.ext('onServerPreRequest', async function (ctx, req, res) {
                await Promise.resolve();
            });

            hemera.act({
                topic,
                cmd: 'add',
                a: 1,
                b: 0,
            }, async function (err, resp) {
                try {
                    await resp;
                    expect(err).toBeNull();
                    expect(resp.result).toEqual(1);
                    hemera.close(done);
                } catch (err) {
                    hemera.close(done.fail);
                }

            });
        });

    });
開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:30,代碼來源:example-asyncplugin.test.ts

示例2: Hemera

 server = HemeraTestSuite.start_server(PORT, () => {
     const nats = Nats.connect(authUrl);
     hemera = new Hemera(nats, {});
     hemera.use(require('hemera-safe-promises'));
     hemera.use(HemeraSqlStore, {
         knex: {
             dialect: 'mysql',
             connection: {
                 host: process.env.DB_HOST,
                 user: process.env.DB_USER,
                 password: process.env.DB_PASSWORD,
                 database: testDatabase,
             },
             pool: {
                 min: 0,
                 max: 7,
             },
         },
     });
     hemera.ready(async () => {
         await createCounter(hemera.sqlStore.useDb(testDatabase));
         repo = new CounterRemoteRepository(hemera);
         done();
     });
 });
開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:25,代碼來源:counter-hemera-repository.test.ts

示例3: Hemera

import * as Hemera from 'nats-hemera';
const nats = {};
const hemera: any = new Hemera(nats, {});
hemera.ready(() => {
  hemera.add({
    topic: 'math',
    cmd: 'add'
  }, (req: any, cb: any) => {
  });
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:10,代碼來源:nats-hemera-tests.ts

示例4: catch

            dialect: process.env.DB_TYPE,
            connection: {
                host: process.env.DB_HOST,
                user: process.env.DB_USER,
                password: process.env.DB_PASSWORD,
                database: process.env.DB_DATABASE,
            },
        },
    });
    hemera.use(HemeraZipkin, {
        host: process.env.ZIPKIN_URL,
        port: process.env.ZIPKIN_PORT,
        sampling: 1,
    });
    hemera.use(ContainerHemera, {
    });

    // hemera.setOption('payloadValidator', 'hemera-joi');

    hemera.ready(() => {
        // let Joi = hemera.exposition['hemera-joi'].joi;


    });
} catch (err) {
    logger.error('hemera publish was failed due to ');
    logger.error(err);
}


開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:28,代碼來源:index.ts


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