{"id":13493922,"url":"https://github.com/lohanbodevan/http-status-codes-responses","last_synced_at":"2025-03-28T13:31:24.598Z","repository":{"id":57268393,"uuid":"107422579","full_name":"lohanbodevan/http-status-codes-responses","owner":"lohanbodevan","description":"Don't spend time writing personalized response body for non-success requests.","archived":false,"fork":false,"pushed_at":"2018-11-22T11:39:26.000Z","size":35,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T05:19:38.007Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lohanbodevan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-18T14:50:54.000Z","updated_at":"2023-03-08T16:44:36.000Z","dependencies_parsed_at":"2022-08-25T02:51:44.375Z","dependency_job_id":null,"html_url":"https://github.com/lohanbodevan/http-status-codes-responses","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohanbodevan%2Fhttp-status-codes-responses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohanbodevan%2Fhttp-status-codes-responses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohanbodevan%2Fhttp-status-codes-responses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohanbodevan%2Fhttp-status-codes-responses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lohanbodevan","download_url":"https://codeload.github.com/lohanbodevan/http-status-codes-responses/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246037321,"owners_count":20713395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:20.046Z","updated_at":"2025-03-28T13:31:24.302Z","avatar_url":"https://github.com/lohanbodevan.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# HTTP Status Codes Responses \u003ca href=\"https://travis-ci.org/lohanbodevan/http-status-codes-responses\"\u003e\u003cimg alt=\"Travis Status\" src=\"https://travis-ci.org/lohanbodevan/http-status-codes-responses.svg?branch=master\"\u003e\u003c/a\u003e [![Coverage Status](https://coveralls.io/repos/github/lohanbodevan/http-status-codes-responses/badge.svg?branch=master)](https://coveralls.io/github/lohanbodevan/http-status-codes-responses?branch=master) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/lohanbodevan/http-status-codes-responses/blob/master/LICENSE)\n\n\nDon't spend time writing personalized response body for non-success requests.\n\n## How to use?\n1. Install lib\n```bash\nnpm install http-status-codes-responses\n```\n\n2. Use it\n```javascript\nconst {ok, notFound} = require('http-status-codes-responses');\n\nconst person = new Person();\nlet john = person.findOne(1);\nconst ctx = (john !== undefined) ? ok({}, john.json()) : notFound({});\n```\n\nIf John exists, the result will be as following with status code `200`:\n```json\n{\n    \"name\": \"John\",\n    \"occupation\": \"singer\",\n}\n```\n\nOtherwise the HTTP response status code will setted to `404` with body:\n```json\n{\n    \"message\": \"Not Found\"\n}\n```\n\n## Implemented Status Code\n| Function | Status Code | Default Message |\n|:---------|------------|--------------|\n| accepted | 202 | { message: 'Accepted' } |\n| badGateway | 502 | { message: 'Bad Gateway' } |\n| badRequest | 400 | { message: 'Bad Request' } |\n| conflict | 409 | { message: 'Conflict' } |\n| continue | 100 | { message: 'Continue' } |\n| created | 201 | { message: 'Created' } |\n| expectationFailed | 417 | { message: 'Expectation Failed' } |\n| failedDependency | 424 | { message: 'Failed Dependency' } |\n| forbidden | 403 | { message: 'Forbidden' } |\n| gatewayTimeout | 504 | { message: 'Gateway Timeout' } |\n| gone | 410 | { message: 'Gone' } |\n| httpVersionNotSupported | 505 | { message: 'HTTP Version Not Supported' } |\n| imATeapot | 418 | { message: 'I\\'m a teapot' } |\n| insufficientSpaceOnResource | 419 | { message: 'Insufficient Space on Resource' } |\n| insufficientStorage | 507 | { message: 'Insufficient Storage' } |\n| internalServerError | 500 | { message: 'Server Error' } |\n| lengthRequired | 411 | { message: 'Length Required' } |\n| locked | 423 | { message: 'Locked' } |\n| methodFailure | 420 | { message: 'Method Failure' } |\n| methodNotAllowed | 405 | { message: 'Method Not Allowed' } |\n| movedPermanently | 301 | { message: 'Moved Permanently' } |\n| movedTemporarily | 302 | { message: 'Moved Temporarily' } |\n| multiStatus | 207 | { message: 'Multi-Status' } |\n| multipleChoices | 300 | { message: 'Multiple Choices' } |\n| networkAuthenticationRequired | 511 | { message: 'Network Authentication Required' } |\n| noContent | 204 | { message: 'No Content' } |\n| nonAuthoritativeInformation | 203 | { message: 'Non Authoritative Information' } |\n| notAcceptable | 406 | { message: 'Not Acceptable' } |\n| notFound | 404 | { message: 'Not Found' } |\n| notImplemented | 501 | { message: 'Not Implemented' } |\n| notModified | 304 | { message: 'Not Modified' } |\n| ok | 200 | { message: 'OK' } |\n| partialContent | 206 | { message: 'Partial Content' } |\n| paymentRequired | 402 | { message: 'Payment Required' } |\n| permanentRedirect | 308 | { message: 'Permanent Redirect' } |\n| preconditionFailed | 412 | { message: 'Precondition Failed' } |\n| preconditionRequired | 428 | { message: 'Precondition Required' } |\n| processing | 102 | { message: 'Processing' } |\n| proxyAuthenticationRequired | 407 | { message: 'Proxy Authentication Required' } |\n| requestHeaderFieldsTooLarge | 431 | { message: 'Request Header Fields Too Large' } |\n| requestTimeout | 408 | { message: 'Request Timeout' } |\n| requestTooLong | 413 | { message: 'Request Entity Too Large' } |\n| requestUriTooLong | 414 | { message: 'Request-URI Too Long' } |\n| requestedRangeNotSatisfiable | 416 | { message: 'Requested Range Not Satisfiable' } |\n| resetContent | 205 | { message: 'Reset Content' } |\n| seeOther | 303 | { message: 'See Other' } |\n| serviceUnavailable | 503 | { message: 'Service Unavailable' } |\n| switchingProtocols | 101 | { message: 'Switching Protocols' } |\n| temporaryRedirect | 307 | { message: 'Temporary Redirect' } |\n| tooManyRequests | 429 | { message: 'Too Many Requests' } |\n| unauthorized | 401 | { message: 'Unauthorized' } |\n| unprocessableEntity | 422 | { message: 'Unprocessable Entity' } |\n| unsupportedMediaType | 415 | { message: 'Unsupported Media Type' } |\n| useProxy | 305 | { message: 'Use Proxy' } |\n\n## Tests\n```bash\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flohanbodevan%2Fhttp-status-codes-responses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flohanbodevan%2Fhttp-status-codes-responses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flohanbodevan%2Fhttp-status-codes-responses/lists"}