From 3b6981918a2eb1cd667ac5cdcca1f677f20d0432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Thu, 22 Mar 2018 19:05:38 +0100 Subject: [PATCH] format(@nestjs) run prettier, format existing codebase --- .../{multicast-mqtt.spec.ts => broadcast-mqtt.spec.ts} | 8 ++++---- .../{multicast-nats.spec.ts => broadcast-nats.spec.ts} | 8 ++++---- ...multicast-redis.spec.ts => broadcast-redis.spec.ts} | 8 ++++---- ...cast.controller.ts => mqtt-broadcast.controller.ts} | 10 +++++----- ...cast.controller.ts => nats-broadcast.controller.ts} | 10 +++++----- ...ast.controller.ts => redis-broadcast.controller.ts} | 10 +++++----- src/core/scanner.ts | 6 +++++- src/websockets/web-sockets-controller.ts | 7 ++----- 8 files changed, 34 insertions(+), 33 deletions(-) rename integration/microservices/e2e/{multicast-mqtt.spec.ts => broadcast-mqtt.spec.ts} (82%) rename integration/microservices/e2e/{multicast-nats.spec.ts => broadcast-nats.spec.ts} (82%) rename integration/microservices/e2e/{multicast-redis.spec.ts => broadcast-redis.spec.ts} (81%) rename integration/microservices/src/mqtt/{mqtt-multicast.controller.ts => mqtt-broadcast.controller.ts} (71%) rename integration/microservices/src/nats/{nats-multicast.controller.ts => nats-broadcast.controller.ts} (71%) rename integration/microservices/src/redis/{redis-multicast.controller.ts => redis-broadcast.controller.ts} (70%) diff --git a/integration/microservices/e2e/multicast-mqtt.spec.ts b/integration/microservices/e2e/broadcast-mqtt.spec.ts similarity index 82% rename from integration/microservices/e2e/multicast-mqtt.spec.ts rename to integration/microservices/e2e/broadcast-mqtt.spec.ts index 9b9c5d67f1a..4506b93870c 100644 --- a/integration/microservices/e2e/multicast-mqtt.spec.ts +++ b/integration/microservices/e2e/broadcast-mqtt.spec.ts @@ -3,7 +3,7 @@ import * as request from 'supertest'; import { Test } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import { Transport } from '@nestjs/microservices'; -import { MqttMulticastController } from '../src/mqtt/mqtt-multicast.controller'; +import { MqttBroadcastController } from '../src/mqtt/mqtt-broadcast.controller'; describe('MQTT transport', () => { let server; @@ -11,7 +11,7 @@ describe('MQTT transport', () => { beforeEach(async () => { const module = await Test.createTestingModule({ - controllers: [MqttMulticastController], + controllers: [MqttBroadcastController], }).compile(); server = express(); @@ -26,9 +26,9 @@ describe('MQTT transport', () => { await app.init(); }); - it(`Multicast (2 subscribers)`, () => { + it(`Broadcast (2 subscribers)`, () => { return request(server) - .get('/multicast') + .get('/broadcast') .expect(200, '2'); }); diff --git a/integration/microservices/e2e/multicast-nats.spec.ts b/integration/microservices/e2e/broadcast-nats.spec.ts similarity index 82% rename from integration/microservices/e2e/multicast-nats.spec.ts rename to integration/microservices/e2e/broadcast-nats.spec.ts index a46f8c56627..803a3ba80ad 100644 --- a/integration/microservices/e2e/multicast-nats.spec.ts +++ b/integration/microservices/e2e/broadcast-nats.spec.ts @@ -3,7 +3,7 @@ import * as request from 'supertest'; import { Test } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import { Transport } from '@nestjs/microservices'; -import { NatsMulticastController } from '../src/nats/nats-multicast.controller'; +import { NatsBroadcastController } from '../src/nats/nats-broadcast.controller'; describe('NATS transport', () => { let server; @@ -11,7 +11,7 @@ describe('NATS transport', () => { beforeEach(async () => { const module = await Test.createTestingModule({ - controllers: [NatsMulticastController], + controllers: [NatsBroadcastController], }).compile(); server = express(); @@ -27,9 +27,9 @@ describe('NATS transport', () => { await app.init(); }); - it(`Multicast (2 subscribers)`, () => { + it(`Broadcast (2 subscribers)`, () => { return request(server) - .get('/multicast') + .get('/broadcast') .expect(200, '2'); }); diff --git a/integration/microservices/e2e/multicast-redis.spec.ts b/integration/microservices/e2e/broadcast-redis.spec.ts similarity index 81% rename from integration/microservices/e2e/multicast-redis.spec.ts rename to integration/microservices/e2e/broadcast-redis.spec.ts index 5dc371f0d1e..0a69016c492 100644 --- a/integration/microservices/e2e/multicast-redis.spec.ts +++ b/integration/microservices/e2e/broadcast-redis.spec.ts @@ -4,7 +4,7 @@ import { Test } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import { Transport } from '@nestjs/microservices'; import { RedisController } from '../src/redis/redis.controller'; -import { RedisMulticastController } from '../src/redis/redis-multicast.controller'; +import { RedisBroadcastController } from '../src/redis/redis-broadcast.controller'; describe('REDIS transport', () => { let server; @@ -12,7 +12,7 @@ describe('REDIS transport', () => { beforeEach(async () => { const module = await Test.createTestingModule({ - controllers: [RedisMulticastController], + controllers: [RedisBroadcastController], }).compile(); server = express(); @@ -27,9 +27,9 @@ describe('REDIS transport', () => { await app.init(); }); - it(`Multicast (2 subscribers)`, () => { + it(`Broadcast (2 subscribers)`, () => { return request(server) - .get('/multicast') + .get('/broadcast') .expect(200, '2'); }); diff --git a/integration/microservices/src/mqtt/mqtt-multicast.controller.ts b/integration/microservices/src/mqtt/mqtt-broadcast.controller.ts similarity index 71% rename from integration/microservices/src/mqtt/mqtt-multicast.controller.ts rename to integration/microservices/src/mqtt/mqtt-broadcast.controller.ts index 4e286b41967..a9d1eb42631 100644 --- a/integration/microservices/src/mqtt/mqtt-multicast.controller.ts +++ b/integration/microservices/src/mqtt/mqtt-broadcast.controller.ts @@ -9,19 +9,19 @@ import { Observable } from 'rxjs/Observable'; import { scan, take } from 'rxjs/operators'; @Controller() -export class MqttMulticastController { +export class MqttBroadcastController { @Client({ transport: Transport.MQTT }) client: ClientProxy; - @Get('multicast') + @Get('broadcast') multicats() { return this.client - .send({ cmd: 'multicast' }, {}) + .send({ cmd: 'broadcast' }, {}) .pipe(scan((a, b) => a + b), take(2)); } - @MessagePattern({ cmd: 'multicast' }) - replyMulticast(): Observable { + @MessagePattern({ cmd: 'broadcast' }) + replyBroadcast(): Observable { return new Observable(observer => observer.next(1)); } } diff --git a/integration/microservices/src/nats/nats-multicast.controller.ts b/integration/microservices/src/nats/nats-broadcast.controller.ts similarity index 71% rename from integration/microservices/src/nats/nats-multicast.controller.ts rename to integration/microservices/src/nats/nats-broadcast.controller.ts index 7fdee86d395..58f527b3303 100644 --- a/integration/microservices/src/nats/nats-multicast.controller.ts +++ b/integration/microservices/src/nats/nats-broadcast.controller.ts @@ -9,19 +9,19 @@ import { Observable } from 'rxjs/Observable'; import { scan, take } from 'rxjs/operators'; @Controller() -export class NatsMulticastController { +export class NatsBroadcastController { @Client({ transport: Transport.NATS }) client: ClientProxy; - @Get('multicast') + @Get('broadcast') multicats() { return this.client - .send({ cmd: 'multicast' }, {}) + .send({ cmd: 'broadcast' }, {}) .pipe(scan((a, b) => a + b), take(2)); } - @MessagePattern({ cmd: 'multicast' }) - replyMulticast(): Observable { + @MessagePattern({ cmd: 'broadcast' }) + replyBroadcast(): Observable { return new Observable(observer => observer.next(1)); } } diff --git a/integration/microservices/src/redis/redis-multicast.controller.ts b/integration/microservices/src/redis/redis-broadcast.controller.ts similarity index 70% rename from integration/microservices/src/redis/redis-multicast.controller.ts rename to integration/microservices/src/redis/redis-broadcast.controller.ts index 8d9045d6d19..8fcddef6239 100644 --- a/integration/microservices/src/redis/redis-multicast.controller.ts +++ b/integration/microservices/src/redis/redis-broadcast.controller.ts @@ -9,21 +9,21 @@ import { Observable } from 'rxjs/Observable'; import { scan, take } from 'rxjs/operators'; @Controller() -export class RedisMulticastController { +export class RedisBroadcastController { @Client({ transport: Transport.REDIS }) client: ClientProxy; - @Get('multicast') + @Get('broadcast') multicats() { - return this.client.send({ cmd: 'multicast' }, {}) + return this.client.send({ cmd: 'broadcast' }, {}) .pipe( scan((a, b) => a + b), take(2), ); } - @MessagePattern({ cmd: 'multicast' }) - replyMulticast(): Observable { + @MessagePattern({ cmd: 'broadcast' }) + replyBroadcast(): Observable { return new Observable((observer) => observer.next(1)); } } diff --git a/src/core/scanner.ts b/src/core/scanner.ts index 9f6800e9fdb..0764b1009b6 100644 --- a/src/core/scanner.ts +++ b/src/core/scanner.ts @@ -66,7 +66,11 @@ export class DependenciesScanner { }); } - public reflectRelatedModules(module: Type, token: string, context: string) { + public reflectRelatedModules( + module: Type, + token: string, + context: string, + ) { const modules = [ ...this.reflectMetadata(module, metadata.MODULES), ...this.container.getDynamicMetadataByToken( diff --git a/src/websockets/web-sockets-controller.ts b/src/websockets/web-sockets-controller.ts index ee9043f5032..9620cb1f1ec 100644 --- a/src/websockets/web-sockets-controller.ts +++ b/src/websockets/web-sockets-controller.ts @@ -9,10 +9,7 @@ import { } from './gateway-metadata-explorer'; import { Subject } from 'rxjs/Subject'; import { SocketServerProvider } from './socket-server-provider'; -import { - PORT_METADATA, - GATEWAY_OPTIONS, -} from './constants'; +import { PORT_METADATA, GATEWAY_OPTIONS } from './constants'; import { Type } from '@nestjs/common/interfaces/type.interface'; import { MetadataScanner } from '@nestjs/core/metadata-scanner'; import { NestContainer } from '@nestjs/core/injector/container'; @@ -47,7 +44,7 @@ export class WebSocketsController { ) { const options = Reflect.getMetadata(GATEWAY_OPTIONS, metatype) || {}; const port = Reflect.getMetadata(PORT_METADATA, metatype) || 0; - + if (!Number.isInteger(port)) { throw new InvalidSocketPortException(port, metatype); }