-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…stify` support Since `@nestjs/common@9` update, throwing `HttpException` in `createParamDecorator` does not work, and just always be consired as `InternalServerException`. Therefore, every validation decorators just had thrown 500 status error instead of 400. In such reason, I've changed my custom validation decorators to send 400 status error directly through `express.Response` or `FastifyReply` instance. Also, from now on, `@nestia/core` fully supports `fastify`.
- Loading branch information
Showing
79 changed files
with
2,018 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type express from "express"; | ||
import type { FastifyRequest } from "fastify"; | ||
import raw from "raw-body"; | ||
|
||
export const get_text_body = async ( | ||
request: express.Request | FastifyRequest, | ||
): Promise<string> => | ||
isExpressRequest(request) | ||
? (await raw(request)).toString("utf8") | ||
: (request.body as string); | ||
|
||
const isExpressRequest = ( | ||
request: express.Request | FastifyRequest, | ||
): request is express.Request => (request as express.Request).app !== undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { BadRequestException, ExecutionContext } from "@nestjs/common"; | ||
import type express from "express"; | ||
import type { FastifyReply } from "fastify"; | ||
|
||
export const send_bad_request = | ||
(context: ExecutionContext) => | ||
(error: BadRequestException): void => { | ||
const response: express.Response | FastifyReply = context | ||
.switchToHttp() | ||
.getResponse(); | ||
response.status(error.getStatus()).send(error.getResponse()); | ||
}; |
Oops, something went wrong.