fix(platform): revert fastify regression

This commit is contained in:
Kamil Myśliwiec
2020-01-28 12:10:41 +01:00
parent d084bee968
commit ea07fb7e16
4 changed files with 6 additions and 26 deletions

View File

@@ -1,3 +1,5 @@
/* Temporarily disabled due to various regressions
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
@@ -86,4 +88,4 @@ describe('Hello world (fastify adapter with multiple applications)', () => {
await Promise.all(apps.map(app => app.close()));
await adapter.close();
});
});
});*/

View File

@@ -5,7 +5,7 @@
"scripts": {
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec --retries 3 --require 'node_modules/reflect-metadata/Reflect.js' --exit",
"integration-test": "mocha \"integration/*/{,!(node_modules)/**/}/*.spec.ts\" --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js' --exit",
"integration-test": "mocha \"integration/hello-world/{,!(node_modules)/**/}/*.spec.ts\" --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js' --exit",
"lint": "concurrently 'npm run lint:packages' 'npm run lint:integration' 'npm run lint:spec'",
"lint:packages": "eslint 'packages/**/**.ts' --fix --ignore-pattern 'packages/**/*.spec.ts'",
"lint:integration": "eslint 'integration/*/{,!(node_modules)/**/}/*.ts' -c '.eslintrc.spec.js' --fix",

View File

@@ -41,16 +41,10 @@ export class ExpressAdapter extends AbstractHttpAdapter {
}
public setErrorHandler(handler: Function, prefix?: string) {
if (prefix) {
return this.use(prefix, handler);
}
return this.use(handler);
}
public setNotFoundHandler(handler: Function, prefix?: string) {
if (prefix) {
return this.use(prefix, handler);
}
return this.use(handler);
}

View File

@@ -70,30 +70,14 @@ export class FastifyAdapter<TInstance = any> extends AbstractHttpAdapter {
handler: Parameters<fastify.FastifyInstance['setErrorHandler']>[0],
prefix?: string,
) {
if (!prefix) {
return this.instance.setErrorHandler(handler);
}
return this.registerWithPrefix(
async (instance: fastify.FastifyInstance): Promise<void> => {
instance.setErrorHandler(handler);
},
prefix,
);
return this.instance.setErrorHandler(handler);
}
public setNotFoundHandler(
handler: Parameters<fastify.FastifyInstance['setNotFoundHandler']>[0],
prefix?: string,
) {
if (!prefix) {
return this.instance.setNotFoundHandler(handler);
}
return this.registerWithPrefix(
async (instance: fastify.FastifyInstance): Promise<void> => {
instance.setNotFoundHandler(handler);
},
prefix,
);
return this.instance.setNotFoundHandler(handler);
}
public getHttpServer<TServer = any>(): TServer {