@auios/response-codes
v2.0.0
Published
Typed HTTP status codes aligned with MDN, with editor autocomplete
Maintainers
Readme
ResponseCode
Typed HTTP status codes aligned 1:1 with MDN. Node.js 20 or later. ESM-only.
Installation
npm install @auios/response-codesUsage
import { ResponseCode, ResponseCodeName } from '@auios/response-codes';
return Response.json(
{ error: 'User not found.' },
{ status: ResponseCode.NotFound_404 },
);
ResponseCodeName[404]; // "NotFound_404"Your editor should autocomplete from the name or JSDoc description.
Common codes
| Key | Status |
| ------------------------- | ------ |
| OK_200 | 200 |
| Created_201 | 201 |
| NoContent_204 | 204 |
| MovedPermanently_301 | 301 |
| BadRequest_400 | 400 |
| Unauthorized_401 | 401 |
| Forbidden_403 | 403 |
| NotFound_404 | 404 |
| InternalServerError_500 | 500 |
The rest are on the ResponseCode object (with JSDoc) and on MDN HTTP status.
License
This project is licensed under the MIT License.
