{"id":13527286,"url":"https://github.com/jshttp/http-assert","last_synced_at":"2025-05-16T06:02:19.607Z","repository":{"id":12735376,"uuid":"15408341","full_name":"jshttp/http-assert","owner":"jshttp","description":"assert with status codes","archived":false,"fork":false,"pushed_at":"2024-05-15T12:18:05.000Z","size":69,"stargazers_count":147,"open_issues_count":3,"forks_count":14,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-05-17T07:02:22.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/jshttp.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-24T01:17:57.000Z","updated_at":"2024-06-02T18:43:03.096Z","dependencies_parsed_at":"2024-06-02T18:42:58.545Z","dependency_job_id":"e2b9b972-62b8-48bd-bec9-37ebe8c7beb9","html_url":"https://github.com/jshttp/http-assert","commit_stats":{"total_commits":138,"total_committers":9,"mean_commits":"15.333333333333334","dds":"0.24637681159420288","last_synced_commit":"976df0b5017be9ee53d8d17ff0d2c03aa8b689e4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fhttp-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fhttp-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fhttp-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fhttp-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jshttp","download_url":"https://codeload.github.com/jshttp/http-assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478160,"owners_count":22077675,"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-08-01T06:01:45.012Z","updated_at":"2025-05-16T06:02:19.545Z","avatar_url":"https://github.com/jshttp.png","language":"JavaScript","readme":"# http-assert\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][ci-image]][ci-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nAssert with status codes. Like ctx.throw() in Koa, but with a guard.\n\n## Install\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```bash\n$ npm install http-assert\n```\n\n## Example\n```js\nvar assert = require('http-assert')\nvar ok = require('assert')\n\nvar username = 'foobar' // username from request\n\ntry {\n  assert(username === 'fjodor', 401, 'authentication failed')\n} catch (err) {\n  ok(err.status === 401)\n  ok(err.message === 'authentication failed')\n  ok(err.expose)\n}\n```\n\n## API\n\nThe API of this module is intended to be similar to the\n[Node.js `assert` module](https://nodejs.org/dist/latest/docs/api/assert.html).\n\nEach function will throw an instance of `HttpError` from\n[the `http-errors` module](https://www.npmjs.com/package/http-errors)\nwhen the assertion fails.\n\n### assert(value, [status], [message], [properties])\n\nTests if `value` is truthy. If `value` is not truthy, an `HttpError`\nis thrown that is constructed with the given `status`, `message`,\nand `properties`.\n\n### assert.deepEqual(a, b, [status], [message], [properties])\n\nTests for deep equality between `a` and `b`. Primitive values are\ncompared with the Abstract Equality Comparison (`==`). If `a` and `b`\nare not equal, an `HttpError` is thrown that is constructed with the\ngiven `status`, `message`, and `properties`.\n\n### assert.equal(a, b, [status], [message], [properties])\n\nTests shallow, coercive equality between `a` and `b` using the Abstract\nEquality Comparison (`==`). If `a` and `b` are not equal, an `HttpError`\nis thrown that is constructed with the given `status`, `message`,\nand `properties`.\n\n### assert.fail([status], [message], [properties])\n\nAlways throws an `HttpError` that is constructed with the given `status`,\n`message`, and `properties`.\n\n### assert.notDeepEqual(a, b, [status], [message], [properties])\n\nTests for deep equality between `a` and `b`. Primitive values are\ncompared with the Abstract Equality Comparison (`==`). If `a` and `b`\nare equal, an `HttpError` is thrown that is constructed with the given\n`status`, `message`, and `properties`.\n\n### assert.notEqual(a, b, [status], [message], [properties])\n\nTests shallow, coercive equality between `a` and `b` using the Abstract\nEquality Comparison (`==`). If `a` and `b` are equal, an `HttpError` is\nthrown that is constructed with the given `status`, `message`, and\n`properties`.\n\n### assert.notStrictEqual(a, b, [status], [message], [properties])\n\nTests strict equality between `a` and `b` as determined by the SameValue\nComparison (`===`). If `a` and `b` are equal, an `HttpError` is thrown\nthat is constructed with the given `status`, `message`, and `properties`.\n\n### assert.ok(value, [status], [message], [properties])\n\nTests if `value` is truthy. If `value` is not truthy, an `HttpError`\nis thrown that is constructed with the given `status`, `message`,\nand `properties`.\n\n### assert.strictEqual(a, b, [status], [message], [properties])\n\nTests strict equality between `a` and `b` as determined by the SameValue\nComparison (`===`). If `a` and `b` are not equal, an `HttpError`\nis thrown that is constructed with the given `status`, `message`,\nand `properties`.\n\n## Licence\n\n[MIT](LICENSE)\n\n[ci-image]: https://badgen.net/github/checks/jshttp/http-assert/master?label=ci\n[ci-url]: https://github.com/jshttp/http-assert/actions?query=workflow%3Aci\n[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-assert/master\n[coveralls-url]: https://coveralls.io/r/jshttp/http-assert?branch=master\n[node-version-image]: https://badgen.net/npm/node/http-assert\n[node-version-url]: https://nodejs.org/en/download\n[npm-downloads-image]: https://badgen.net/npm/dm/http-assert\n[npm-url]: https://npmjs.org/package/http-assert\n[npm-version-image]: https://badgen.net/npm/v/http-assert\n","funding_links":[],"categories":["Repository"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshttp%2Fhttp-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjshttp%2Fhttp-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshttp%2Fhttp-assert/lists"}