{"id":13395802,"url":"https://github.com/Scorpiion/Vane","last_synced_at":"2025-03-13T22:30:56.394Z","repository":{"id":16130369,"uuid":"18875639","full_name":"Scorpiion/vane","owner":"Scorpiion","description":"Server-side framework for Dart/Dartlang with a built-in middleware system.","archived":false,"fork":false,"pushed_at":"2019-03-17T19:01:42.000Z","size":202,"stargazers_count":59,"open_issues_count":14,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-07-31T18:15:54.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","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/Scorpiion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-04-17T11:10:09.000Z","updated_at":"2024-03-03T13:35:41.000Z","dependencies_parsed_at":"2022-09-24T06:30:26.359Z","dependency_job_id":null,"html_url":"https://github.com/Scorpiion/vane","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scorpiion%2Fvane","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scorpiion%2Fvane/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scorpiion%2Fvane/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Scorpiion%2Fvane/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Scorpiion","download_url":"https://codeload.github.com/Scorpiion/vane/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243493262,"owners_count":20299619,"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-07-30T18:00:32.380Z","updated_at":"2025-03-13T22:30:56.121Z","avatar_url":"https://github.com/Scorpiion.png","language":"Dart","readme":"Vane\n=========\n\nVane is server side framework written and optimized for the Dart programming \nlanguage. Vane comes bundled with a lightweight and performant middleware \nsystem and strives to provide commonly used parameters and objects in an easy\nto use manner such as query parameters or json body data. \n\n## Summary\n* Supports three handler types; Func, Podo and Vane\n* Class based, easy to make your own standard classes by extending any Podo or Vane class and adding your own behavior\n* Simple top level access to commonly used data such as query parameters, json body or file uploads\n* Out of the box websocket support\n* Any Vane class can run as the main controller or as a middleware\n* Middlewares can be defined to run synchronously or asynchronously, before or after the main controller\n* Built in \"plug and play\" support for Mongodb\n\n## Handlers\nVane supports three different types of handlers:\n\n1. Vane handlers - Classes that extend the Vane class\n2. Podo handlers - \"Plain Old Dart Objects\", normal classes that have one or more\nfunctions with the @Route annotation\n3. Func handlers - Function handlers, normal dart function with the @Route annotation \n\n### Vane handler \nA vane handler is any class that extends the Vane class. When you extend the Vane class your \nhandler functions get access to many helpers and features that are part of the Vane framework.\nIn a vane handler you have access to a set of top level helpers to make life easier, some \nexample of these are a ready to use parsed version of incoming json data called \"json\". \n\nA Vane class can either run on it's own or in a pipeline of a set of Vane controllers. When \nmulitple a Vane controller is used in a pipeline to process a request those other than the \nmain controller are called middleware controllers, but it's not a different type of controller\nand middleware controllers can themself also have their own middleware controllers. Inside a \nVane controller you can either end the controller by returning `next()` or `close()`, if you \nreturn with `next()` the next middleware controller will run (if there is one, otherwise the \ncall will be changed to a `close()` call). If you call `close()` that will end the request \neven if there are middleware controllers that have yet not run.  \n\nVane classes registered to as middleware can run either before or after \nthe main controller. Middleware controllers can run synchronously or asynchronously and \nyou are guaranteed that they execute in the order you define. Per default middleware controllers\nrun synchronously and the next controller only starts when the current one has finished. You\ncan choose to run one or more middleware controllers in async and also combine both a set of \nsynchronous and asynchronous controller to create more complex pipelines for processing.\n\nHello World Example:\n```dart\nclass HelloVane extends Vane {\n  @Route(\"/\")\n  Future World() { \n    return close(\"Hello world! (from vane handler)\");\n  }\n}\n```\n\nMiddleware Example:\n```dart\nclass HelloVane extends Vane {\n  var pipeline = [MyMiddleware, This]\n  @Route(\"/\")\n  Future World() { \n    return close(\"Hello world! (from vane handler)\");\n  }\n}\n\nclass MyMiddleware extends Vane {\n  Future main() { \n    write(\"Hello from middleware!\");\n    return next();\n  }\n}\n```\n\n### Podo handler \nA podo handler is a \"Plain Old Dart Object\", basically any Dart class that have 1 or more\nfunction handlers with declared with the @Route annotation.\n\nHello World Example:\n```dart\nclass HelloPodo {\n  @Route(\"/\")\n  void World(HttpRequest request) {\n    request.response.write(\"Hello World! (from podo handler)\");\n    request.response.close();\n  }\n}\n```\n\n### Func handler \nA function handler is simple a function that takes at least 1 HttpRequest parameter and \noptionally 1 or more parameters that can be mapped from the url.\n\nHello World Example:\n```dart\n@Route(\"/\")\nvoid helloFuncWorld(HttpRequest request) {\n  request.response.write(\"Hello World! (from func handler)\");\n  request.response.close();\n}\n```\n\n## Vane server (server.dart)\nWith Vane you don't have to worry about writing a dart/web server, you focus on writing your \ncontrollers/handlers and Vane serves them for you automatically based on your @Route annotations.  \nAll you need to do is to make sure they are in the same library and that you start the serve function. \n\n### Hello World with a Vane handler  \n```dart\nimport 'dart:async';\nimport 'package:vane/vane.dart';\n\nclass HelloWorld extends Vane {\n  @Route(\"/\")\n  Future Hello() {\n    return close(\"Hello world\");\n  }\n}\n\nvoid main() =\u003e serve();\n```\n\n### Example with all three types of handlers \n```dart\nimport 'dart:io';\nimport 'dart:async';\nimport 'package:vane/vane.dart';\n\nclass HelloVane extends Vane {\n  @Route(\"/\")\n  @Route(\"/vane\")\n  Future World() {\n    return close(\"Hello world! (from vane handler)\");\n  }\n\n  @Route(\"/{user}\")\n  @Route(\"/vane/{user}\")\n  Future User(String user) {\n    return close(\"Hello ${user}! (from vane handler)\");\n  }\n}\n\nclass HelloPodo {\n  @Route(\"/podo\")\n  void World(HttpRequest request) {\n    request.response.write(\"Hello World! (from podo handler)\");\n    request.response.close();\n  }\n\n  @Route(\"/podo/{user}\")\n  void User(HttpRequest request, String user) {\n    request.response.write(\"Hello World $user! (from podo handler)\");\n    request.response.close();\n  }\n}\n\n@Route(\"/func\")\nvoid helloFuncWorld(HttpRequest request) {\n  request.response.write(\"Hello World! (from func handler)\");\n  request.response.close();\n}\n\n@Route(\"/func/{user}\")\nvoid helloFuncUser(HttpRequest request, String user) {\n  request.response.write(\"Hello World $user! (from func handler)\");\n  request.response.close();\n}\n\nvoid main() =\u003e serve();\n```\n\n## Documentation, examples and roadmap\n* [Official project page and documentation](http://www.dartvoid.com/vane/)\n* [API documentation](http://www.dartvoid.com/docs/vaneapi/)\n* [Github project](https://github.com/DartVoid/Vane)\n\n","funding_links":[],"categories":["Server Frameworks","服务端框架","Libraries"],"sub_categories":["Server Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScorpiion%2FVane","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FScorpiion%2FVane","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScorpiion%2FVane/lists"}