Having "success" or "statusCode" method in handler like "error" to response 201/204 status code.
drsmile1001 opened this issue · comments
What is the problem this feature would solve?
For now, response 201/204 can be:
new Elysia().get(
"/",
({ set }) => {
set.status = 204;
},
{
response: {
204: t.Void({
description: "No Content",
}),
},
}
);
but set.status will not check match response constraint.
new Elysia().get(
"/",
({ set }) => {
set.status = 201; //Not warning here
},
{
response: {
204: t.Void({
description: "No Content",
}),
},
}
);
but error
can warn.
new Elysia().get(
"/",
({ error }) => {
return error(201, "123"); // Error
},
{
response: {
204: t.Void({
description: "No Content",
}),
},
}
);
What is the feature you are proposing to solve the problem?
Having a success / statusCode method in handle.
new Elysia().get(
"/",
({ success, statusCode }) => {
return success(204);
return statusCode(204) // more neutral
},
{
response: {
204: t.Void({
description: "No Content",
}),
},
}
);
What alternatives have you considered?
No response