{"id":16189307,"url":"https://github.com/caolan/quip","last_synced_at":"2025-04-10T02:29:30.456Z","repository":{"id":44004070,"uuid":"749916","full_name":"caolan/quip","owner":"caolan","description":"A chainable API for response objects in node","archived":false,"fork":false,"pushed_at":"2022-12-10T16:55:36.000Z","size":231,"stargazers_count":91,"open_issues_count":8,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T01:11:40.799Z","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/caolan.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":"2010-06-30T20:43:30.000Z","updated_at":"2025-01-02T01:11:45.000Z","dependencies_parsed_at":"2023-01-26T04:15:25.753Z","dependency_job_id":null,"html_url":"https://github.com/caolan/quip","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/caolan%2Fquip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fquip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fquip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caolan%2Fquip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caolan","download_url":"https://codeload.github.com/caolan/quip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144083,"owners_count":21054866,"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-10-10T07:35:00.773Z","updated_at":"2025-04-10T02:29:30.430Z","avatar_url":"https://github.com/caolan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quip\n\nA convenient chainable API for HTTP ServerResponse objects in node.\n\n* Suited to quick and easy prototyping\n* Works as a [Connect](http://github.com/extjs/Connect) middleware\n* Allows you to pipe streams to the response, while easily setting up\n  the headers and status code beforehand\n\n\n## Examples\n\n#### responding with different status codes\n\n```javascript\nres.ok('\u003ch1\u003eHello World!\u003c/h1\u003e');\nres.notFound('Not found');\n```\n\n#### responding with different mime types\n\n```javascript\nres.text('plain text');\nres.json({'stringify': 'this object'});\n```\n\n#### chaining the two together (in any order)\n\n```javascript\nres.error().json({error: 'something broke'});\nres.xml().badRequest('\u003ctest\u003e\u003c/test\u003e');\n```\n\n#### redirection\n\n```javascript\nres.moved('http://permanent/new/location');\nres.redirect('http://temporary/new/location');\n```\n\n#### custom headers\n\n```javascript\nres.headers({'custom': 'header'}).text('some data');\n```\n\n#### piping data to a response object\n\n```javascript\n// read posts.xml and pipe to response with mime type application/atom+xml\nvar feed = fs.createReadStream('posts.xml');\nfeed.pipe(res.atom());\n```\n\nThe response is completed when data is passed to a status code or mime-type\nfunction, when a redirect is performed, or when a stream is piped to the\nresponse.\n\n\n## Usage\n\nUse quip for specific responses:\n\n    var quip = require('quip'),\n        http = require('http');\n\n    http.createServer(function (req, res) {\n        quip(res).ok('example');\n    });\n\nEnable for all response objects by using quip as a\n[Connect](http://www.senchalabs.org/connect/) middleware:\n\n    var connect = require('connect'),\n        quip = require('quip'),\n\n    var app = connect(\n        quip,\n        function (req, res, next) {\n            res.ok('example');\n        }\n    );\n\n\n## API\n\n* headers - add custom headers to response, returns updated response object\n* status - set status code of response manually, returns updated response\n\n### Status Codes\n\nBy default, the response will have the status code 200 (OK), this can\nbe updated using the following methods. Note that by passing some data\nto these methods, the response will complete. If you don't pass data it will\nreturn an updated response object, allowing you to chain calls together. If\nthe data passed is an object then it will be treated as JSON and the mime\ntype of the response will be updated accordingly.\n\n#### Success\n* res.ok\n* res.created\n* res.accepted\n* res.noContent\n\n#### Redirection\n* res.moved\n* res.redirect\n* res.found - alias for redirect\n* res.notModified\n\n#### Client Error\n* res.badRequest\n* res.unauthorized\n* res.forbidden\n* res.notFound\n* res.notAllowed\n* res.conflict\n* res.gone\n\n#### Server Error\n* res.error\n\n### Mime Types\n\nBy default, the response will have the mime-type text/html, this can\nbe updated using the following methods. Note that by passing some data\nto these methods, the response will complete. If you don't pass data it will\nreturn an updated response object, allowing you to chain calls together.\nYou can pass an object to the json and jsonp methods and it will be\nstringified before sending.\n\n* res.text\n* res.plain\n* res.html\n* res.xhtml\n* res.css\n* res.xml\n* res.atom\n* res.rss\n* res.javascript\n* res.json\n\n* res.jsonp -- JSONP is a special case that __always__ completes the request,\n  and overrides any previous status code calls. There is no reliable way for\n  a browser to interpret JSONP responses with a status code other than 200.\n  Any error or status information should be included in the JSONP response\n  itself. The jsonp method accepts 2 arguments, a callback name (string) and\n  some JSON data (either a string or an object literal).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fquip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaolan%2Fquip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaolan%2Fquip/lists"}