{"id":18535289,"url":"https://github.com/tinyhttp/unless","last_synced_at":"2025-04-09T15:32:02.118Z","repository":{"id":57166682,"uuid":"391013880","full_name":"tinyhttp/unless","owner":"tinyhttp","description":"🚦 Unless middleware for tinyhttp","archived":false,"fork":false,"pushed_at":"2023-10-27T13:54:01.000Z","size":177,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:47:05.583Z","etag":null,"topics":["http","middleware","node-js","nodejs","tinyhttp","unless","unless-middleware"],"latest_commit_sha":null,"homepage":"https://tinyhttp.v1rtl.site/mw/@tinyhttp/unless","language":"TypeScript","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/tinyhttp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"v1rtl","liberapay":"v1rtl","custom":["https://stakes.social/0x14308514785B216904a41aB817282d25425Cce39","https://giveth.io/project/tinyhttp","https://paypal.me/v1rtl","https://qiwi.com/n/V1RTL","https://yoomoney.ru/to/410014774355272"],"issuehunt":"talentlessguy"}},"created_at":"2021-07-30T09:49:38.000Z","updated_at":"2023-10-27T13:53:10.000Z","dependencies_parsed_at":"2022-08-30T15:21:33.127Z","dependency_job_id":null,"html_url":"https://github.com/tinyhttp/unless","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"tinyhttp/repo-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Funless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Funless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Funless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Funless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/unless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248058069,"owners_count":21040688,"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":["http","middleware","node-js","nodejs","tinyhttp","unless","unless-middleware"],"created_at":"2024-11-06T19:21:50.460Z","updated_at":"2025-04-09T15:32:02.112Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\n# @tinyhttp/unless\n\n[![npm][npm-img]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Coverage][cov-img]][cov-url]\n\n\u003c/div\u003e\n\nUnless middleware for tinyhttp that executes a middleware conditionally.\n\n## Install\n\n```sh\npnpm i @tinyhttp/unless\n```\n\n## API\n\n### `unless(middleware, (UnlessMiddlewareOptions | CustomUnless))`\n\nThe `UnlessMiddlewareOptions` object can include:\n\n- `method` - string or array of strings that describe forbidden http methods such as GET, POST, PUT etc...\n- `path` - array of strings, Regex and objects that include `url` and `methods` properties, which will be compared against the request.\n- `ext` - string or array of strings that describe forbidden path ends (e.g. in `/user/123` it will check against `/123`).\n\nThe `CustomUnless` is a function that receives a Request object and returns a boolean. The result of the function will determine if the execution of the middleware is skipped.\n\n## Example\n\n```ts\nimport { App } from '@tinyhttp/app'\nimport { unless } from '@tinyhttp/unless'\nimport { cors } from '@tinyhttp/cors'\n\nconst app = new App()\n\napp\n  .use(unless(cors(),  { method: ['GET', 'POST'] }))\n  .use(unless(cors(), { ext: '/public' }))\n  .use(unless(cors(), (req) =\u003e req.method === 'GET')\n  .use(unless(cors(), { path: ['/content/public', /user/, { url: '/public', methods: ['GET'] }] })\n  .listen(3000)\n```\n\n[npm-url]: https://npmjs.com/package/@tinyhttp/unless\n[github-actions]: https://github.com/tinyhttp/unless/actions\n[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/unless/ci.yml?branch=master\u0026style=for-the-badge\u0026logo=github\u0026label=\u0026color=hotpink\n[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/unless?style=for-the-badge\u0026color=hotpink\u0026\n[cov-url]: https://coveralls.io/github/tinyhttp/unless\n[npm-img]: https://img.shields.io/npm/dt/@tinyhttp/unless?style=for-the-badge\u0026color=hotpink\n","funding_links":["https://ko-fi.com/v1rtl","https://liberapay.com/v1rtl","https://stakes.social/0x14308514785B216904a41aB817282d25425Cce39","https://giveth.io/project/tinyhttp","https://paypal.me/v1rtl","https://qiwi.com/n/V1RTL","https://yoomoney.ru/to/410014774355272","https://issuehunt.io/r/talentlessguy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Funless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinyhttp%2Funless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Funless/lists"}