Skip to content

Commit

Permalink
format(@nestjs) run prettier, format existing codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 22, 2018
1 parent 84f531c commit 3b69819
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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;
let app: INestApplication;

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

server = express();
Expand All @@ -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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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;
let app: INestApplication;

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

server = express();
Expand All @@ -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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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;
let app: INestApplication;

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

server = express();
Expand All @@ -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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>({ cmd: 'multicast' }, {})
.send<number>({ cmd: 'broadcast' }, {})
.pipe(scan((a, b) => a + b), take(2));
}

@MessagePattern({ cmd: 'multicast' })
replyMulticast(): Observable<number> {
@MessagePattern({ cmd: 'broadcast' })
replyBroadcast(): Observable<number> {
return new Observable(observer => observer.next(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>({ cmd: 'multicast' }, {})
.send<number>({ cmd: 'broadcast' }, {})
.pipe(scan((a, b) => a + b), take(2));
}

@MessagePattern({ cmd: 'multicast' })
replyMulticast(): Observable<number> {
@MessagePattern({ cmd: 'broadcast' })
replyBroadcast(): Observable<number> {
return new Observable(observer => observer.next(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>({ cmd: 'multicast' }, {})
return this.client.send<number>({ cmd: 'broadcast' }, {})
.pipe(
scan((a, b) => a + b),
take(2),
);
}

@MessagePattern({ cmd: 'multicast' })
replyMulticast(): Observable<number> {
@MessagePattern({ cmd: 'broadcast' })
replyBroadcast(): Observable<number> {
return new Observable((observer) => observer.next(1));
}
}
6 changes: 5 additions & 1 deletion src/core/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export class DependenciesScanner {
});
}

public reflectRelatedModules(module: Type<any>, token: string, context: string) {
public reflectRelatedModules(
module: Type<any>,
token: string,
context: string,
) {
const modules = [
...this.reflectMetadata(module, metadata.MODULES),
...this.container.getDynamicMetadataByToken(
Expand Down
7 changes: 2 additions & 5 deletions src/websockets/web-sockets-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 3b69819

Please sign in to comment.