{"id":20664032,"url":"https://github.com/flutterando/dartion","last_synced_at":"2025-06-21T09:35:33.857Z","repository":{"id":40357576,"uuid":"259154810","full_name":"Flutterando/dartion","owner":"Flutterando","description":"Json Server RESTful, Up your backend in 5 Seconds!","archived":false,"fork":false,"pushed_at":"2023-05-24T21:05:36.000Z","size":2695,"stargazers_count":59,"open_issues_count":0,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-29T09:51:17.409Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/dartion","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/Flutterando.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-26T23:25:47.000Z","updated_at":"2025-03-08T19:02:26.000Z","dependencies_parsed_at":"2024-11-16T21:17:40.886Z","dependency_job_id":null,"html_url":"https://github.com/Flutterando/dartion","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdartion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdartion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdartion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flutterando%2Fdartion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flutterando","download_url":"https://codeload.github.com/Flutterando/dartion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249734684,"owners_count":21317872,"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-11-16T19:21:46.410Z","updated_at":"2025-04-19T16:12:43.914Z","avatar_url":"https://github.com/Flutterando.png","language":"Dart","readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\n\u003ch1 align=\"center\"\u003eDARTION\u003c/h1\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://pub.dev/packages/dartion\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Flutterando/dartion/master/readme_assets/logo-dartion.png\" alt=\"Dartion package Logo\" width=\"180\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    A RESTful mini web server based on JSON.\n    \u003cbr\u003e\nThis is not just a port of the popular json-server for Dart, it also adds some more features like JWT Authentication.\n    \u003cbr\u003e\n    \u003ca href=\"https://pub.dev/documentation/dartion/latest/\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003c!-- \u003ca href=\"https://link para o demo\"\u003eView Demo\u003c/a\u003e --\u003e\n    ·\n    \u003ca href=\"https://github.com/flutterando/dartion/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/flutterando/dartion/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003c!--  SHIELDS  ----\u003e\n\n[![Version](https://img.shields.io/github/v/release/flutterando/dartion?style=plastic)](https://pub.dev/packages/dartion)\n[![Pub Points](https://img.shields.io/pub/points/dartion?label=pub%20points\u0026style=plastic)](https://pub.dev/packages/dartion/score)\n[![Flutterando Analysis](https://img.shields.io/badge/style-flutterando__analysis-blueviolet?style=plastic)](https://pub.dev/packages/flutterando_analysis/)\n\n[![Pub Publisher](https://img.shields.io/pub/publisher/dartion?style=plastic)](https://pub.dev/publishers/flutterando.com.br/packages)\n\u003c/div\u003e\n\n\n\u003cbr\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#sponsors\"\u003eSponsors\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#how-to-use\"\u003eHow to Use\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nGet your backend up in 5 seconds!\nDartion aims to make it easier for those who take front-end video lessons in languages like Flutter and need a server to implement and test their codes.\nJust get the DartSDK, install Dartion, initialize the server and start it, that's all! \nIt comes with support to HTTP requests and JWT Authentication.  \nAfter installing, just populate the db.json file and you will have a simple and ready to use database.\n\n\u003c!-- PROJECT EXAMPLE (IMAGE) --\u003e\n\u003c!-- \u003cbr\u003e\n\u003cCenter\u003e\n\u003cimg src=\"readme_assets/project-readme-example.gif\" alt=\"Dartion package working gif\" width=\"400\"\u003e\n\u003c/Center\u003e --\u003e\n\n\u003cbr\u003e\n\n\u003ci\u003e This project is distributed under the MIT License. See `LICENSE.txt` for more information.\u003c/i\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- SPONSORS --\u003e\n## Sponsors\n\n\u003ca href=\"https://fteam.dev\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/Flutterando/flutterando-readme-template/master/readme_assets/sponsor-logo.png\" alt=\"Logo\" width=\"120\"\u003e\n  \u003c/a\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\u003cbr\u003e\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n1. Get the [Dart SDK](https://dart.dev/get-dart)\n\n2. Activate Dartion using pub:\n\n```\n dart pub global activate dartion\n```\n\n\u003cbr\u003e \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## How to Use\n\n\u003cbr\u003e\n\n### **Commands**\n\n\u003cbr\u003e\n\n**Upgrade**:\n\nUpdates Dartion's version:\n\n```\ndartion upgrade\n```\n\n\u003cbr\u003e\n\n**Init server**:\n\nExecute the command below in an empty folder, it will create the base configuration files for your server:\n\n```\ndartion init\n```\n\n\u003cbr\u003e\n\n**Start server**:\n\nThe command below will boot the server based on the settings configured in the `config.yaml` you have now on your created folder.\n\n```\ndartion serve\n```\n\nIf you want to change those settings, you can edit the `config.yaml` as you like. Refer to the documentation on the init and serve commands, and also the Database class, to know a little bit more about these configurations. \n\n\u003cbr\u003e\n\n### **Route system**\n\nWhen running Dartion we have a structure based on RESTful, while the data persists in a JSON file in the folder, named by default `db.json`.\n\n```\nGET    /products     -\u003e Get all products\nGET    /products/1   -\u003e Get one product\nPOST   /products     -\u003e Add more one product\nPUT    /products/1   -\u003e Edit one product\nPATCH  /products/1   -\u003e Edit one product\nDELETE /products/1   -\u003e Delete one product\n```\n\nPOST, PUT and PATH requests must have their **body** as JSON. It is not necessary to pass the ID, it is incremented automatically.\n\n\u003cbr\u003e\n\n### **File Upload**\n\nYou can configure Dartion to accept upload files such as images, pdf's, etc...\nAdds **storage** properties to config.yaml\n```yaml\nstorage:\n  name: \"file\"\n  folder: storage/\n```\n\nFile uploads work with \"Multipart-form\", so you can use the name property to **name** your upload.\nWe can choose which folder the uploaded files will be on the server using the **folder** property.\nThen you will have two reserved routes, one to upload files and the other to retrieve those binaries.\n```\nPOST /storage               -\u003e Send files in Multipart-form\nGET  /file/:your-file.ext   -\u003e Retrieve file \n```\n\nNOTE: The **/storage** route returns the file name.\n\n\u003cbr\u003e\n\n### **Authetication**\n\nYou can use JWT Authentication in two steps.\n\n1. Use the **auth** property in your `config.yaml`\n\n```yaml\nname: Test\nport: 3031\ndb: db.json\nstatics: public\n\nauth:\n  key: dajdi3cdj8jw40jv89cj4uybfg9wh9vcnvb\n  exp: 3600\n  escape:\n    - animals\n    - cities\n```\n\nThat's enough to protect your routes.\nThe auth property takes some configuration parameters:\n\n```yaml\nkey -\u003e To sign your token\nexp -\u003e Token expiration time in seconds\nescape -\u003e List of routes that will not be affected by token protection\n```\n\n2. Login using the **/auth** route:\n\nTo retrieve the token you need a credential.\nA credential is basically **base64(email:password)**\n\nSee an example in Dart:\n\n```dart\n\nString email = \"jose@gmail.com\";\nString password = \"123\";\nString info = \"$email:$password\";\nString encode = base64Encode(info.codeUnits);\n\nString credencials = \"Basic $encode\";\n\n```\n\nYou can now make a GET request to **/auth**, passing the **credentials** in the `authorization` header.\n\nexemple in dart\n\n```dart\n// Using the package http\n\nResponse response = await http.get(\n  'http://localhost:3031/auth',\n  headers: {'authorization': credencials},\n);\n```\n\nThis will return the token and some user information.\n\n```json\n{\n  \"user\": {\n    \"name\": \"Jose\",\n    \"email\": \"jose@gmail.com\"\n  },\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODc5NjQ1MTAsImlhdCI6MTU4Nzk2MDkxMCwiaXNzIjoiZGFydGlvIiwic3ViIjoibnVsbCJ9.5AeEIpYeu04fKINg6e8Ic5fpT0-KyZH8yPLOO6HoLVA\",\n  \"exp\": 3600\n}\n```\n\nThat's it! Now, just use the token to access the routes:\n\n```dart\nResponse response = await http.get(\n  'http://localhost:3031/products',\n  headers: {'authorization': \"Bearer $token\"},\n);\n```\n\n#### NOTE: \nWhen using Authentication, you will need to have a **users** property in your **db.json** with a user list containing at least **email** and **password** in order to access.\n\n#### NOTE 2: \nThe db.json on the root folder of this package was generated by running the tests contained on the `test` folder. \n\n\u003cbr\u003e\n\n_For more details, please refer to the_ [Documentation](https://pub.dev/documentation/dartion/latest/)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\n\u003c!-- FEATURES --\u003e\n## Features\n\n- ✅ Easy to install and use backend mock server \n- ✅ Database personalization through db.json\n- ✅ HTTP request handlers\n- ✅ AuthService mock \n- ✅ \n\nRight now this package has concluded all his intended features. If you have any suggestions or find something to report, see below how to contribute to it. \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the appropriate tag. \nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nRemember to include a tag, and to follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/) when uploading your commit and/or creating the issue. \n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nFlutterando Community\n- [Discord](https://discord.gg/qNBDHNARja)\n- [Telegram](https://t.me/flutterando)\n- [Website](https://www.flutterando.com.br)\n- [Youtube Channel](https://www.youtube.com.br/flutterando)\n- [Other useful links](https://linktr.ee/flutterando)\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n## Acknowledgements \n\nThank you to all the people who contributed to this project, whitout you this project would not be here today.\n\n\u003ca href=\"https://github.com/flutterando/dartion/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=flutterando/dartion\" /\u003e\n\u003c/a\u003e\n\u003c!-- Bot para Lista de contribuidores - https://allcontributors.org/  --\u003e\n\u003c!-- Opção (utilizada no momento): https://contrib.rocks/preview?repo=flutterando%2Fasuka --\u003e\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MANTAINED BY --\u003e\n## Maintaned by\n\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.flutterando.com.br\"\u003e\n    \u003cimg width=\"110px\" src=\"https://raw.githubusercontent.com/Flutterando/flutterando-readme-template/master/readme_assets/logo-flutterando.png\"\u003e\n  \u003c/a\u003e\n  \u003cp align=\"center\"\u003e\n    Built and maintained by \u003ca href=\"https://www.flutterando.com.br\"\u003eFlutterando\u003c/a\u003e.\n  \u003c/p\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Fdartion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflutterando%2Fdartion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutterando%2Fdartion/lists"}