Open Char2sGu opened 3 years ago
is there a way to change the response code though options or something?
I'm handling this way:
import { Delete, HttpCode, HttpStatus } from '@nestjs/common';
@Delete(':id')
@HttpCode(HttpStatus.NO_CONTENT)
...
Would be nice if @Delete
default was 204
with the option to override
Hi everyone,
Just passing by, but I was thinking that this issue could be nicely handled with a custom decorator. For example:
import { Delete, HttpCode, HttpStatus, applyDecorators } from '@nestjs/common';
export const DeleteWithNoContent = (path?: string | string[]) =>
applyDecorators(Delete(path), HttpCode(HttpStatus.NO_CONTENT));
This way, you can consistently return 204 No Content for DELETE actions without needing to manually specify the status code each time.
According to the REST specification, a 204 should be returned if a DELETE action is successfully performed, but now the lib returns a 200 instead.