{"id":16527210,"url":"https://github.com/zignis/deflight","last_synced_at":"2026-04-09T04:02:56.188Z","repository":{"id":80852488,"uuid":"606105650","full_name":"zignis/deflight","owner":"zignis","description":"Bypass express middlewares for pre-flight requests","archived":false,"fork":false,"pushed_at":"2026-02-07T08:40:04.000Z","size":184,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-07T13:29:59.705Z","etag":null,"topics":["express","middleware","preflight"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/deflight","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/zignis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-24T16:00:29.000Z","updated_at":"2026-02-07T08:38:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"58468df2-b9ab-4b36-bf13-b78efcfdf557","html_url":"https://github.com/zignis/deflight","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":"0.18181818181818177","last_synced_commit":"f7babee1d9b877dda25a32a302b6ff93eb8d2a18"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/zignis/deflight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fdeflight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fdeflight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fdeflight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fdeflight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zignis","download_url":"https://codeload.github.com/zignis/deflight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zignis%2Fdeflight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31584820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["express","middleware","preflight"],"created_at":"2024-10-11T17:34:02.505Z","updated_at":"2026-04-09T04:02:56.172Z","avatar_url":"https://github.com/zignis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [De-flight](https://npmjs.com/package/deflight)\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/deflight\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Package version\" src=\"https://badgen.net/npm/v/deflight\" /\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"Package downloads\" src=\"https://badgen.net/npm/dm/deflight\" /\u003e\n  \u003ca href=\"./LICENSE\"\u003e\n    \u003cimg alt=\"Package license\" src=\"https://badgen.net/npm/license/deflight\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nA middleware wrapper for [express](https://expressjs.com/) that skips calling the middleware for pre-flight requests.\n\n## Installation\n\n```shell\n# Yarn\nyarn add deflight\n\n# NPM\nnpm install deflight\n```\n\nThe package exports both a named and a default export:\n\n```js\nimport { deflight } from \"deflight\";\n// Or\nimport deflight from \"deflight\";\n\napp.use(deflight(someMiddleware));\n```\n\n## When to use it?\n\nIf your app serves requests coming from a different origin than your server is hosted on, and you need to do something specifically with the pre-flight requests, for example, sending the `Access-Control-Allow-Methods` header on a per-route basis:\n\n```js\napp.use(deflight(someExpensiveMiddleware));\n\napp.all('/example', (req, res, next) =\u003e {\n  if ((req.method || '').toLowerCase() === 'options') {\n    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');\n    res.setHeader('Content-Length', '0');\n\n    return res.status(204).end();\n  }\n  \n  // Route logic\n});\n```\n\n## Gotchas\n\n### Using with the [CORS](https://expressjs.com/en/resources/middleware/cors.html) middleware\n\nYou need to enable the `preflightContinue` option to let the CORS middleware pass the pre-flight request\nto subsequent middlewares and not return early.\n\n```js\napp.use(\n  cors({\n    origin: \"https://example.com\",\n    preflightContinue: true, // Required\n  })\n);\n```\n\n### TypeScript\n\nThe wrapper uses the default `Request` type from the express package.\nIf you have extended the request object, or your middleware expects a different request object:\n\n```ts\ninterface ExtendedRequest extends Request {\n    customProp: string;\n}\n\napp.use(deflight\u003cExtendedRequest\u003e(someMiddleware));\n```\n\n## License\n\nDeflight is released under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzignis%2Fdeflight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzignis%2Fdeflight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzignis%2Fdeflight/lists"}