當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。