{"id":26498771,"url":"https://github.com/fennec-framework/fennec","last_synced_at":"2025-03-20T14:40:13.132Z","repository":{"id":37622471,"uuid":"502611488","full_name":"Fennec-Framework/fennec","owner":"Fennec-Framework","description":"Fennec is a multi-threaded, robust Dart Server-Side Framework.","archived":false,"fork":false,"pushed_at":"2023-07-06T10:33:04.000Z","size":306,"stargazers_count":42,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-08-09T13:40:50.880Z","etag":null,"topics":["backend","dart","http","serverside","webserver","websocket"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fennec-Framework.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":"2022-06-12T12:35:54.000Z","updated_at":"2023-07-28T05:25:50.000Z","dependencies_parsed_at":"2023-02-08T12:01:35.978Z","dependency_job_id":null,"html_url":"https://github.com/Fennec-Framework/fennec","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fennec-Framework%2Ffennec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fennec-Framework%2Ffennec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fennec-Framework%2Ffennec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fennec-Framework%2Ffennec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fennec-Framework","download_url":"https://codeload.github.com/Fennec-Framework/fennec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244631867,"owners_count":20484646,"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":["backend","dart","http","serverside","webserver","websocket"],"created_at":"2025-03-20T14:40:12.366Z","updated_at":"2025-03-20T14:40:13.127Z","avatar_url":"https://github.com/Fennec-Framework.png","language":"Dart","readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/55693316/173706793-0666f8a8-67d6-4d1b-8b79-78fa4808e72e.png\" height=\"500\" /\u003e\n\u003c/p\u003e\n\n# Fennec is a multi-threaded, robust Dart Server-Side Framework.\n\n# Packages\n\n| Packages                |                                     pub                                     |\n| :---------------------- | :-------------------------------------------------------------------------: |\n| fennec (core framework) |                  [fennec](https://pub.dev/packages/fennec)                  |\n| fennec_pg               |               [fennec_pg](https://pub.dev/packages/fennec_pg)               |\n| fennec_jwt              |              [fennec_jwt](https://pub.dev/packages/fennec_jwt)              |\n| fennec_socket_io_server | [fennec_socket_io_server](https://pub.dev/packages/fennec_socket_io_server) |\n\n# installation:\n\n1. create a simple dart project. you can use terminal for that **dart create 'projectname'**\n2. install the framework from [pub.dev](https://pub.dev/packages/fennec)\n\n# supported features by fennec:\n\n1. Multi-threaded http request.\n2. Sharing Data between Isolates if using multiples Isolates.\n3. WebSocket request.\n4. Handling requests with a simple and solid Router logic.\n5. Handling dynamic path routes.\n6. Middlewares at level of every request and Router level.\n7. Templates rendering system with html extension.\n8. Handling Form Data.\n\n# make your first request:\n\nyou can make a request by creating a [Route] and add it to [Application] instance or create\na [Router] and add it to [application] instance.\n\n# create a Router.\n\n```dart\nRouter testRouter() {\n  Router router = Router();\n\n  router.get(\n      path: \"/test\",\n      requestHandler: (context, req, res) async {\n        return res.ok(body: \"hello world\");\n      });\n\n  return router;\n}\n\n\n```\n\n## Middleware\n\nit must be a typedef **MiddlewareHandler** and must return always **MiddleWare**. here an example\nhow to implement it:\n\n```dart\n  Future\u003cMiddleware\u003e testMiddleware(ServerContext serverContext, Request req, Response res) async {\n  if (1 == 2) {\n    return Next();\n  }\n  return Stop(res.forbidden(body: {\"error\": \"not allowed\"}).json());\n}\n\n\n```\n\n## Add Middleware to a Router\n\nyou can use also define a Router Middleware by.\n\n```dart\n\nrouter.useMiddleware((\nserverContext, req, res) {\nif (1 == 2) {\nreturn Next();\n}\nreturn Stop(res.forbidden(body: {\"error\": \"not allowed\"}).json());\n});\n\n\n```\n\n## Sharing Data between Isolates if using multiples Isolates.\n\nIsolate is an isolated environment, inside which there is memory allocated to it and its EventLoop. but sometimes you want to share Data between Isolates or have the same Data content on all Isolates.\n\nFennec let you do that by using Actor Concept.\n\nfirst you need to create your Actor customized class that is a subclass of Actor.\n\nexample how to implement it.\n```dart\n\nclass CustomisedActor extends Actor {\nfinal List\u003cString\u003e _strings = [];\n\nCustomisedActor(String name) : super(name);\n\n@override\nFutureOr\u003cvoid\u003e execute(String action,\n{Map\u003cString, dynamic\u003e data = const {}}) {\nif (action == 'insert') {\n_strings.add(\" new item\");\n} else {\nif (_strings.isNotEmpty) {\n_strings.removeLast();\n}\n}\n}\n\n@override\nFutureOr get(String action, {Map\u003cString, dynamic\u003e data = const {}}) {\nif (action == \"get\") {\nreturn _strings;\n}\nreturn null;\n}\n}\n\n\n```\n\nafter implementing of your needed subclasses of [Actor], you need just to add it/them to your [Application] by using addActor or addActors in [Application] instance.\n\nwith [ServerContext] instance you can have access to your Actor/Actors by their name and you can call get and execute methods to return some Data from Actor or execute some operations.\n\n\n## dynamic routes\n\nhere is an example how to use dynamic path routes\n\n```dart\nrouter.get(path: \"\n/test/{id}\n\"\n,\nrequestHandler: (\ncontext, req, res) {\nreturn res.ok(body: {\"id\": req.pathParams['id']}).json();\n});\n\n```\n\n## File System Routing\n\nan example how to handle files\n\n```dart\nrouter.get(path: \"\n/getFile\n\"\n,\nrequestHandler: (\ncontext, req, res) {\nreturn res.ok(body: req.files.first.filename);\n});\n\n```\n\n## Template with html extension\n\nyou can render also html templates with fennec Framework. you need to determine the path for your\nhtml files. application.setViewPath(path.current + '/example');\n\nan example how to use it.\n\n```dart\n\nrouter.get(path: \"\n/template\n\"\n,\nrequestHandler: (\ncontext, req, res) {\nreturn res.render(\"file\");\n});\n\n```\n\n## WebSocket\n\nWebSocket is already integrated in the core of Framework. firstly to use Websocket . you need to\nmake the useWebSocket object at [Application] instance true.\n\nhow to use it :\n\n```dart\n  router.ws(path: \"\n/connect\n\"\n,\nwebsocketHandler: (\ncontext, websocket) {\n/// handle new connected websocket client.\n});\n\n\n```\n\n## Multithreading\n\nFennec Framework supports also Multithreading over isolates. To increase the number of used isolates\njust call the function setNumberOfIsolates. the default number of isolates is 1\n\n**example**\n\n```dart\n\napplication.setNumberOfIsolates(1\n);\n\n```\n\n## Start your Server and test your first Request\n\n```dart\nimport 'package:fennec/fennec.dart';\n\n\nvoid main(List\u003cString\u003e arguments) async {\n  Application application = Application();\n\n  application.setNumberOfIsolates(1);\n  application.useWebSocket(true);\n  application.setPort(8000);\n  application.addRouters([testRouter()]);\n\n  ServerInfo serverInfo = await application.runServer();\n  print(\"Server is running at Port ${serverInfo.port}\");\n}}\n```\n\n# deploy\n\n- **heroku cloud:** [here](https://github.com/Fennec-Framework/heroku-buildpack) is heroku-buildpack\n  for dart and inside it an example how to deploy Fennec Framework on heroku cloud for free. to test\n  an example you can try this two endpoints:\n\n    - https://fennec-deploy.herokuapp.com/healthcheck/servercheck\n\n    - https://fennec-deploy.herokuapp.com/healthcheck\n\n- for next days, another example for aws and goolge run will be uploaded.\n\n# Benchmarks using [wrk](https://github.com/wg/wrk)\n\nafter running this endpoint using Fennec Framework on local machine (MacBook Pro (13-inch, 2019, Two\nThunderbolt 3 ports), we could gets this data:\n\n- t: number of threads\n- c: number of open connections\n- d: duration of test\n\n```dart\n  router.get(path: \"\n/test\n\"\n,\nrequestHandler: (\ncontext, req, res) async {\nreturn res.ok(body: \"hello world\");\n});\n\n```\n\n**wrk -t1 -c100 -d60s http://localhost:8000/example/test**\n\n- Running 1m test @ http://localhost:8000/example/test\n- 1 threads and 100 connections\n- Thread Stats Avg Stdev Max +/- Stdev\n- Latency 6.63ms 1.83ms 86.51ms 96.81%\n- Req/Sec 15.30k 1.38k 16.52k 91.17%\n- 913472 requests in 1.00m, 177.72MB read\n- Requests/sec: 15209.67\n- Transfer/sec: 2.96MB\n\n**wrk -t10 -c100 -d60s http://localhost:8000/example/test**\n\n- Running 1m test @ http://localhost:8000/example/test\n- 10 threads and 100 connections\n- Thread Stats Avg Stdev Max +/- Stdev\n- Latency 6.50ms 1.27ms 104.08ms 96.71%\n- Req/Sec 1.55k 124.24 2.41k 87.15%\n- 926903 requests in 1.00m, 180.33MB read\n- Requests/sec: 15435.91\n- Transfer/sec: 3.00MB\n\n## import information\n\nFennec Framework after with version \u003e= 1.0.0 doesn't support more annotations because the big\ndiscussions about the library mirrors. as alernatives you can use Route or Route as showed in this\nexample.\n\n# License\n\n[MIT](https://github.com/Fennec-Framework/fennec/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffennec-framework%2Ffennec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffennec-framework%2Ffennec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffennec-framework%2Ffennec/lists"}