Giter Site home page Giter Site logo

fastify-code-failure's Introduction

NestJS Fastify Code Failure

Stumbled upon this recently, it appears that if true is returned from a guard when using NestJS Fastify, there is a problem with using response.code inside the @nestjs/platform-fastify adapter.

Reproduction

git clone [email protected]:jmcdo29/fastify-code-failure.git
npm i 
# OR
yarn
npm run start:dev
# OR
yarn start:dev
curl http://localhost:3000 # this method should succeed and return { success: true }
curl http://localhost:3000/fail # this method should return an InternalServerExceptiom

Work Around

Currently as a workaround I can go to the fastify adapter and change response.code(statusCode) to be response.statusCode = statusCode and I get the response as expected. It seems that the res.res object is being used (the server response) instead of res (the FastifyReply<ServerResponse>). Haven't tracked back any further than that.

Environment

nest info

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Linux 5.0
NodeJS Version : v13.14.0
YARN Version    : 1.22.4 

[Nest CLI]
Nest CLI Version : 7.2.0 

[Nest Platform Information]
platform-fastify version : 7.1.1
common version           : 7.1.1
core version             : 7.1.1

fastify-code-failure's People

Contributors

dependabot[bot] avatar jmcdo29 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.