当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript nats-hemera.use函数代码示例

本文整理汇总了TypeScript中nats-hemera.use函数的典型用法代码示例。如果您正苦于以下问题:TypeScript use函数的具体用法?TypeScript use怎么用?TypeScript use使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了use函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: 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

示例3: Hemera

    'url': process.env.NATS_URL,
    'user': process.env.NATS_USER,
    'pass': process.env.NATS_PW,
});

const logLevel = process.env.HEMERA_LOG_LEVEL as Hemera.LogLevel || process.env.LOG_LEVEL as Hemera.LogLevel || 'info';

try {
    const hemera = new Hemera(client, {
        logLevel: logLevel,
        childLogger: true,
        tag: require('../package.json').name,
        timeout: 10000,
    });

    hemera.use(HemeraJoi);
    hemera.use(HemeraSql, {
        knex: {
            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,
开发者ID:baotaizhang,项目名称:fullstack-pro,代码行数:31,代码来源:index.ts


注:本文中的nats-hemera.use函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。