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


TypeScript common.INestApplication类代码示例

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


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

示例1: describe

describe('NATS transport', () => {
  let server;
  let app: INestApplication;

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      controllers: [NatsBroadcastController],
    }).compile();

    server = express();
    app = module.createNestApplication(server);
    app.connectMicroservice({
      transport: Transport.NATS,
    });
    app.connectMicroservice({
      transport: Transport.NATS,
    });
    await app.startAllMicroservicesAsync();
    await app.init();
  });

  it(`Broadcast (2 subscribers)`, () => {
    return request(server)
      .get('/broadcast')
      .expect(200, '2');
  });

  afterEach(async () => {
    await app.close();
  });
});
开发者ID:SARAVANA1501,项目名称:nest,代码行数:31,代码来源:broadcast-nats.spec.ts

示例2: describe

describe('Cats', () => {
  let app: INestApplication;
  let catsService = { findAll: () => ['test'] };

  beforeAll(async () => {
    const module = await Test.createTestingModule({
      imports: [CatsModule],
    })
      .overrideProvider(CatsService)
      .useValue(catsService)
      .compile();

    app = module.createNestApplication();
    await app.init();
  });

  it(`/GET cats`, () => {
    return request(app.getHttpServer())
      .get('/cats')
      .expect(200)
      .expect({
        data: catsService.findAll(),
      });
  });

  afterAll(async () => {
    await app.close();
  });
});
开发者ID:SARAVANA1501,项目名称:nest,代码行数:29,代码来源:cats.e2e-spec.ts

示例3: beforeEach

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      imports: [AsyncOptionsClassModule],
    }).compile();

    app = module.createNestApplication();
    server = app.getHttpServer();
    await app.init();
  });
开发者ID:SARAVANA1501,项目名称:nest,代码行数:9,代码来源:async-class-options.spec.ts

示例4: AuthGuard

 it(`should prevent access (unauthorized)`, async () => {
   app = (await createTestModule(
     new AuthGuard(),
   )).createNestApplication();
 
   await app.init();
   return request(app.getHttpServer())
     .get('/hello')
     .expect(401);
 });
开发者ID:SARAVANA1501,项目名称:nest,代码行数:10,代码来源:guards.spec.ts

示例5: OverrideInterceptor

 it(`should transform response (sync)`, async () => {
   app = (await createTestModule(
     new OverrideInterceptor(),
   )).createNestApplication();
 
   await app.init();
   return request(app.getHttpServer())
     .get('/hello')
     .expect(200, RETURN_VALUE);
 });
开发者ID:SARAVANA1501,项目名称:nest,代码行数:10,代码来源:interceptors.spec.ts

示例6: TransformInterceptor

 it(`should map response (stream)`, async () => {
   app = (await createTestModule(
     new TransformInterceptor(),
   )).createNestApplication();
 
   await app.init();
   return request(app.getHttpServer())
     .get('/hello/async')
     .expect(200, { data: 'Hello world!' });
 });
开发者ID:SARAVANA1501,项目名称:nest,代码行数:10,代码来源:interceptors.spec.ts

示例7: beforeEach

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      controllers: [ErrorsController],
    })
      .compile();

    app = module.createNestApplication();
    server = app.getHttpServer();
    await app.init();
  });
开发者ID:a1r0,项目名称:nest,代码行数:10,代码来源:exceptions.spec.ts

示例8: beforeEach

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      imports: [ApplicationModule],
    }).compile();

    server = express();
    app = module.createNestApplication(server);
    app.connectMicroservice({
      transport: Transport.TCP,
    });
    await app.startAllMicroservicesAsync();
    await app.init();
  });
开发者ID:a1r0,项目名称:nest,代码行数:13,代码来源:sum-rpc.spec.ts

示例9: beforeEach

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      controllers: [RedisController],
    }).compile();

    server = express();
    app = module.createNestApplication(server);
    app.connectMicroservice({
      transport: Transport.REDIS,
    });
    await app.startAllMicroservicesAsync();
    await app.init();
  });
开发者ID:a1r0,项目名称:nest,代码行数:13,代码来源:sum-redis.spec.ts

示例10: request

 it('/ (GET)', () => {
   return request(app.getHttpServer())
     .get('/users')
     .auth('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Im1hcnRpbkB0ZWxlcmlrYWNhZGVteS5jb20iLCJpc0FkbWluIjp0cnVlLCJpYXQiOjE1NDQzOTYxMzcsImV4cCI6MTU0NTAwMDkzN30.fqmWkUcrADb2c5XeyO6FIerau10VWvqSdkSeHWnuqq0', { type: 'bearer' })
     .expect(200)
     .expect('[{"id":1,"email":"martin@telerikacademy.com","password":"123","avatarUrl":"public\\\\images\\\\default.png","isAdmin":true}]');
 });
开发者ID:mbechev,项目名称:Feedback,代码行数:7,代码来源:app.e2e-spec.ts


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