{"id":24302882,"url":"https://github.com/digipolitan/perfect-blink","last_synced_at":"2025-07-09T08:04:36.067Z","repository":{"id":98675584,"uuid":"93209235","full_name":"Digipolitan/perfect-blink","owner":"Digipolitan","description":"Perfect Blink middleware swift is a request parser","archived":false,"fork":false,"pushed_at":"2017-06-05T09:14:05.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-09T08:04:26.286Z","etag":null,"topics":["blink","body-parser","middleware","perfect","perfect-server","query-parser","swift","urlparams"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Digipolitan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2017-06-02T22:46:35.000Z","updated_at":"2019-05-03T18:24:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ddb30cb-3e69-4823-a99c-6e8fb6ad447d","html_url":"https://github.com/Digipolitan/perfect-blink","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Digipolitan/perfect-blink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Digipolitan%2Fperfect-blink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Digipolitan%2Fperfect-blink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Digipolitan%2Fperfect-blink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Digipolitan%2Fperfect-blink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Digipolitan","download_url":"https://codeload.github.com/Digipolitan/perfect-blink/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Digipolitan%2Fperfect-blink/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264419452,"owners_count":23605197,"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":["blink","body-parser","middleware","perfect","perfect-server","query-parser","swift","urlparams"],"created_at":"2025-01-17T00:19:59.085Z","updated_at":"2025-07-09T08:04:36.030Z","avatar_url":"https://github.com/Digipolitan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"PerfectBlink\n=================================\n\n[![Twitter](https://img.shields.io/badge/twitter-@Digipolitan-blue.svg?style=flat)](http://twitter.com/Digipolitan)\n\nPerfect Blink middleware swift is a request parser\n\nParse incoming request body, query, url parameters before the route handler, data available under the context.blink.\n\n## Installation\n\n### Swift Package Manager\n\nTo install PerfectBlink with SPM, add the following lines to your `Package.swift`.\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"XXX\",\n    dependencies: [\n        .Package(url: \"https://github.com/Digipolitan/perfect-blink-swift.git\", majorVersion: 1)\n    ]\n)\n```\n\n## The Basics\n\nCreate a RouterMiddleware and register the blink middleware before all routes handlers\n\n```swift\nlet server = HTTPServer()\n\nlet router = RouterMiddleware()\n\nrouter.use(event: .beforeAll, middleware: Blink.shared)\n\nrouter.post(path: \"/\").bind { (context) in\n  guard let body = context.blink.body as? [String: Any],\n        let name = body[\"name\"] as? String else {\n        context.next()\n        return\n    }\n    context.response.setBody(string: name).completed()\n    context.next()\n}\n\nserver.use(router: router)\n\nserver.serverPort = 8887\n\ndo {\n    try server.start()\n    print(\"Server listening on port \\(server.serverPort)\")\n} catch PerfectError.networkError(let err, let msg) {\n    print(\"Network error thrown: \\(err) \\(msg)\")\n}\n```\n\nIt's possible to register a specific type to parse for only one route as follow :\n```swift\nrouter.post(path: \"/\")\n  .bind(Blink.shared.json())\n  .bind { (context) in\n    guard let body = context.blink.body as? [String: Any] {\n      context.next()\n      return\n    }\n    print(body)\n    context.next()\n}\n```\n\nYou can parse query parameters and url parameters for only one route as follow :\n```swift\nrouter.get(path: \"/\")\n  .bind(Blink.shared.query())\n  .bind(Blink.shared.params())\n  .bind { (context) in\n    guard let query = context.blink.query,\n      let name = query[\"name\"] {\n      context.next()\n      return\n    }\n    context.response.setBody(string: name).completed()\n    context.next()\n}\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more details!\n\nThis project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).\nBy participating, you are expected to uphold this code. Please report\nunacceptable behavior to [contact@digipolitan.com](mailto:contact@digipolitan.com).\n\n## License\n\nPerfectBlink is licensed under the [BSD 3-Clause license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigipolitan%2Fperfect-blink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigipolitan%2Fperfect-blink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigipolitan%2Fperfect-blink/lists"}