style(): update formatting, minor changes

This commit is contained in:
Kamil Myśliwiec
2019-10-31 13:33:50 +01:00
parent 396febcb87
commit 1ea7091d35
8 changed files with 28 additions and 25 deletions

View File

@@ -1,11 +1,11 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ExpressAdapter } from '@nestjs/platform-express';
import { Test, TestingModule } from '@nestjs/testing';
import { expect } from 'chai';
import * as express from 'express';
import { AppModule } from '../src/app.module';
import { randomPort } from './utils';
describe('Get-Url (Express Application)', () => {
describe('Get URL (Express Application)', () => {
let testModule: TestingModule;
let port: number;
@@ -42,7 +42,9 @@ describe('Get-Url (Express Application)', () => {
try {
await app.getUrl();
} catch (err) {
expect(err).to.be.eql('app.listen needs to be called before calling app.getUrl');
expect(err).to.be.eql(
'app.listen needs to be called before calling app.getUrl',
);
}
});
});

View File

@@ -1,10 +1,10 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FastifyAdapter } from '@nestjs/platform-fastify';
import { Test, TestingModule } from '@nestjs/testing';
import { expect } from 'chai';
import { AppModule } from '../src/app.module';
import { randomPort } from './utils';
describe('Get-Url (Fastify Application)', () => {
describe('Get URL (Fastify Application)', () => {
let testModule: TestingModule;
let port: number;
@@ -35,7 +35,9 @@ describe('Get-Url (Fastify Application)', () => {
try {
await app.getUrl();
} catch (err) {
expect(err).to.be.eql('app.listen needs to be called before calling app.getUrl');
expect(err).to.be.eql(
'app.listen needs to be called before calling app.getUrl',
);
}
});
});

View File

@@ -14,4 +14,4 @@ export async function randomPort(): Promise<number> {
resolve(port);
});
});
}
}

View File

@@ -3,11 +3,10 @@ import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.sayHello();
}
}
}

View File

@@ -6,4 +6,4 @@ import { AppService } from './app.service';
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
export class AppModule {}

View File

@@ -5,4 +5,4 @@ export class AppService {
sayHello(): string {
return 'Hello World!';
}
}
}

View File

@@ -4,7 +4,8 @@ export const MESSAGES = {
MICROSERVICE_READY: `Nest microservice successfully started`,
UNKNOWN_EXCEPTION_MESSAGE: 'Internal server error',
ERROR_DURING_SHUTDOWN: 'Error happened during shutdown',
CALL_LISTEN_FIRST: 'app.listen needs to be called before calling app.getUrl',
CALL_LISTEN_FIRST:
'app.listen() needs to be called before calling app.getUrl()',
};
export const APP_INTERCEPTOR = 'APP_INTERCEPTOR';

View File

@@ -15,6 +15,7 @@ import { Logger } from '@nestjs/common/services/logger.service';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { isObject, validatePath } from '@nestjs/common/utils/shared.utils';
import iterate from 'iterare';
import { platform } from 'os';
import { AbstractHttpAdapter } from './adapters';
import { ApplicationConfig } from './application-config';
import { MESSAGES } from './constants';
@@ -25,7 +26,6 @@ import { MiddlewareModule } from './middleware/middleware-module';
import { NestApplicationContext } from './nest-application-context';
import { Resolver } from './router/interfaces/resolver.interface';
import { RoutesResolver } from './router/routes-resolver';
import { platform } from 'os';
const { SocketModule } = optionalRequire(
'@nestjs/websockets/socket-module',
@@ -269,18 +269,6 @@ export class NestApplication extends NestApplicationContext
});
}
private host(): string | undefined {
const address = this.httpServer.address();
if (typeof address === 'string') {
return undefined;
}
return address && address.address;
}
private getProtocol(): 'http' | 'https' {
return this.appOptions && this.appOptions.httpsOptions ? 'https' : 'http';
}
public setGlobalPrefix(prefix: string): this {
this.config.setGlobalPrefix(prefix);
return this;
@@ -329,6 +317,17 @@ export class NestApplication extends NestApplicationContext
this.httpAdapter.setViewEngine(engineOrOptions);
return this;
}
private host(): string | undefined {
const address = this.httpServer.address();
if (typeof address === 'string') {
return undefined;
}
return address && address.address;
}
private getProtocol(): 'http' | 'https' {
return this.appOptions && this.appOptions.httpsOptions ? 'https' : 'http';
}
private async registerMiddleware(instance: any) {
await this.middlewareModule.registerMiddleware(