Skip to content

Commit

Permalink
fix(all): fix the failing build for fastify
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Mcdoniel authored and jmcdo29 committed Sep 2, 2020
1 parent 3794150 commit f166eab
Show file tree
Hide file tree
Showing 7 changed files with 499 additions and 465 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-sonarjs": "^0.5.0",
"express": "^4.17.0",
"fastify": "^2.13.0",
"fastify": "^3.3.0",
"graphql": "^15.3.0",
"graphql-tools": "^6.0.14",
"grpc": "^1.24.2",
Expand Down Expand Up @@ -138,5 +138,8 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"resolutions": {
"axios": "^0.19.0"
}
}
4 changes: 2 additions & 2 deletions packages/platform-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"@nestjs/core": "^7.0.6",
"@nestjs/platform-fastify": "7.4.4",
"@ogma/nestjs-module": "^0.2.2",
"fastify": "^2.13.0",
"fastify": "^3.3.0",
"rxjs": "^6.5.4"
},
"peerDependencies": {
"@nestjs/platform-fastify": "^7.0.0",
"@ogma/nestjs-module": "^0.2.0",
"fastify": "^2.13.0"
"fastify": ">=2.13.0"
}
}
7 changes: 3 additions & 4 deletions packages/platform-fastify/src/fastify-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ExecutionContext, HttpException, Injectable } from '@nestjs/common';
import { HTTP_CODE_METADATA } from '@nestjs/common/constants';
import { AbstractInterceptorService } from '@ogma/nestjs-module';
import { FastifyReply, FastifyRequest } from 'fastify';
import { ServerResponse } from 'http';

@Injectable()
export class FastifyParser extends AbstractInterceptorService {
Expand Down Expand Up @@ -33,7 +32,7 @@ export class FastifyParser extends AbstractInterceptorService {
): string {
let status;
const res = this.getResponse(context);
status = res.res.statusCode;
status = res.statusCode;
const reflectStatus = this.reflector.get<number>(
HTTP_CODE_METADATA,
context.getHandler(),
Expand All @@ -49,8 +48,8 @@ export class FastifyParser extends AbstractInterceptorService {
return context.switchToHttp().getRequest<FastifyRequest>();
}

getResponse(context: ExecutionContext): FastifyReply<ServerResponse> {
return context.switchToHttp().getResponse<FastifyReply<ServerResponse>>();
getResponse(context: ExecutionContext): FastifyReply {
return context.switchToHttp().getResponse<FastifyReply>();
}

private determineStatusCodeFromError(error: HttpException | Error): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { FastifyParser } from '../src';

const resMock = (status: number) => ({
getResponse: () => ({
res: {
statusCode: status,
},
statusCode: status,
}),
});

Expand Down
1 change: 1 addition & 0 deletions packages/platform-graphql-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"devDependencies": {
"@nestjs/common": "^7.0.6",
"@nestjs/core": "^7.0.6",
"@nestjs/graphql": "^7.0.6",
"@ogma/nestjs-module": "^0.2.2",
"@ogma/platform-fastify": "^0.2.2",
"apollo-server-fastify": "^2.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GraphQLFastifyParser extends FastifyParser {
return this.getContext(context).getContext().request;
}

getResponse(context: ExecutionContext): FastifyReply<any> {
getResponse(context: ExecutionContext): FastifyReply {
return this.getContext(context).getContext().reply;
}
}
Loading

0 comments on commit f166eab

Please sign in to comment.