{"id":16223701,"url":"https://github.com/lykmapipo/express-respond","last_synced_at":"2025-03-19T12:30:32.679Z","repository":{"id":1208881,"uuid":"41319245","full_name":"lykmapipo/express-respond","owner":"lykmapipo","description":"HTTP response methods with auto content negotiation for expressjs","archived":false,"fork":false,"pushed_at":"2023-02-11T21:51:57.000Z","size":4217,"stargazers_count":7,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T11:33:31.350Z","etag":null,"topics":["expressjs","http","response"],"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/lykmapipo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null}},"created_at":"2015-08-24T18:14:03.000Z","updated_at":"2025-01-20T20:50:28.000Z","dependencies_parsed_at":"2023-02-18T13:00:41.070Z","dependency_job_id":null,"html_url":"https://github.com/lykmapipo/express-respond","commit_stats":{"total_commits":150,"total_committers":4,"mean_commits":37.5,"dds":"0.040000000000000036","last_synced_commit":"9d948b6b9cedce114927aeef9b66a17971dcd7a8"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fexpress-respond","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fexpress-respond/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fexpress-respond/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lykmapipo%2Fexpress-respond/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lykmapipo","download_url":"https://codeload.github.com/lykmapipo/express-respond/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244426357,"owners_count":20450949,"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":["expressjs","http","response"],"created_at":"2024-10-10T12:19:48.162Z","updated_at":"2025-03-19T12:30:32.330Z","avatar_url":"https://github.com/lykmapipo.png","language":"JavaScript","readme":"express-respond\n=====================\n\n[![Build Status](https://app.travis-ci.com/lykmapipo/express-respond.svg?branch=master)](https://app.travis-ci.com/lykmapipo/express-respond)\n[![Dependencies Status](https://david-dm.org/lykmapipo/express-respond.svg)](https://david-dm.org/lykmapipo/express-respond)\n[![Coverage Status](https://coveralls.io/repos/github/lykmapipo/express-respond/badge.svg?branch=master)](https://coveralls.io/github/lykmapipo/express-respond?branch=master)\n[![GitHub License](https://img.shields.io/github/license/lykmapipo/express-respond)](https://github.com/lykmapipo/express-respond/blob/master/LICENSE)\n\n[![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)\n[![npm version](https://img.shields.io/npm/v/express-respond)](https://www.npmjs.com/package/express-respond)\n\nHTTP response methods with auto content negotiation for [expressjs](https://github.com/strongloop/express/)\n\n## Installation\n```sh\n$ npm install --save express-respond\n```\n\n## Usage\n```js\nimport express from 'express';\nimport respond from 'express-respond';\n\nconst app = express();\napp.use(respond);\n\n// respond with 200\napp.get('/', (request, response) =\u003e {\n  response.ok({ name: 'lykmapipo' });\n});\n\n// respond with error\napp.use((error, request, response, next) =\u003e {\n  response.error(error);\n});\n```\n\n## API\nAll response methods accept optional response `body` based on response type, as some of response are not must to have response body.\n\n### 2xx methods\n\n#### `ok(body: Any)`\nSend JSON response with `200 http status code`.\n\nExample\n```js\nresponse.ok(body);\n```\n\n#### `created(body: Any)`\nSend JSON response with `201 http status code`.\n\nExample\n```js\nresponse.created(body);\n```\n\n#### `accepted([body: Any])`\nSend JSON response with `202 http status code`.\n\nExample\n```js\nresponse.accepted(body);\n```\n\n### `noContent()`\nSend JSON response with `204 http status code`.\n\nExample\n```js\nresponse.noContent();\n```\n\n### 3xx methods\n\n#### `notModified([body: Any])`\nSend JSON response with `304 http status code`.\n\nExample\n```js\nresponse.notModified(body);\n```\n\n### 4xx methods\n\n#### `badRequest([body: Any])`\nSend JSON response with `400 http status code`.\n\nExample\n```js\nresponse.badRequest(body);\n```\n\n#### `unauthorized([body: Any])`\nSend JSON response with `401 http status code`.\n\nExample\n```js\nresponse.unauthorized(body);\n```\n\n#### `paymentRequired([body])`\nSend JSON response with `402 http status code`.\n\nExample\n```js\nresponse.paymentRequired(body);\n```\n\n#### `forbidden([body: Any])`\nSend JSON response with `403 http status code`.\n\nExample\n```js\nresponse.forbidden(body);\n```\n\n#### `notFound([body: Any])`\nSend JSON response with `404 http status code`.\n\nExample\n```js\nresponse.notFound(body);\n```\n\n#### `methodNotAllowed([body: Any])`\nSend JSON response with `405 http status code`.\n\nExample\n```js\nresponse.methodNotAllowed(body);\n```\n\n#### `conflict([body: Any])`\nSend JSON response with `409 http status code`.\n\nExample\n```js\nresponse.conflict(body);\n```\n\n### 5xx methods\n\n#### `internalServerError([body: Any])`\nSend JSON response with `500 http status code`.\n\nExample\n```js\nresponse.internalServerError(body);\n```\n\n#### `notImplemented([body: Any])`\nSend JSON response with `501 http status code`.\n\nExample\n```js\nresponse.notImplemented(body);\n```\n\n#### `badGateway([body: Any])`\nSend JSON response with `502 http status code`.\n\nExample\n```js\nresponse.badGateway(body);\n```\n\n#### `serviceUnavailable([body: Any])`\nSend JSON response with `503 http status code`.\n\nExample\n```js\nresponse.serviceUnavailable(body);\n```\n\n### Error methods\n\n#### `error([body: Error])`\nSend `error` as JSON response with `http status code` obtained from `error.status` property.\n\nExample\n```js\nresponse.error(error);\n```\n\n\n## Testing\n\n* Clone this repository\n\n* Install all development dependencies\n\n```sh\n$ npm install\n```\n* Then run test\n\n```sh\n$ npm test\n```\n\n## Contribute\n\nFork this repo and push in your ideas. \nDo not forget to add a bit of test(s) of what value you adding.\n\n## Licence\n\nThe MIT License (MIT)\n\nCopyright (c) lykmapipo \u0026 Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fexpress-respond","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flykmapipo%2Fexpress-respond","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flykmapipo%2Fexpress-respond/lists"}