shelf_easy 3.5.2 copy "shelf_easy: ^3.5.2" to clipboard
shelf_easy: ^3.5.2 copied to clipboard

This library includes a json model generator, a unified database operator interface, a server and client framework, a virtual machine for AOT code push, and a log module.

Language: English | 中文

This library is a comprehensive lightweight framework, each module can be used independently. Example code directory example Reading navigation:

1. Data model generation module for Json serialization #

Model generation #

The code to generate the Json serialized data model is in the generator.dart file in the example directory.

You can execute dart generator.dart in the example directory to generate the model, and the generated files are in the model directory.

Serialization Demo #

The code demonstrating Json serialization and deserialization is in the test/test_model.dart file in the example directory.

You can execute dart test/test_model.dart in the example directory to view the console output.

2. Unified data operation module for Database #

The code that demonstrates the unified operation of the database is in the test/test_database.dart file in the example directory.

You can execute dart test/test_database.dart in the example directory to view the console output.

Notice:

  1. The database auxiliary classes such as UserQuery generated by the serialization code generator combined with the unified database operation class EasyUniDb can take advantage of the language advantages of dart strong type and avoid Map<String, dynamic> or sql as much as possible Statements associated string key operations.

  2. The interface style of EasyUniDb is basically consistent with that of mongo shell. Currently, it only supports Mongodb, and plans to support postgre.

  3. The sample code is just a demonstration. The result returned by each interface of EasyUniDb is an object of type DbResult<T>. In real scenarios, the status of the database operation result can be judged according to the field of DbResult<T>. For details, please refer to the annotations of the relevant classes.

3. Web service module, Websocket service module, supporting client module #

Web server #

The sample code of the web server is in the test/test_webserver.dart file in the example directory.

The web server can be started by executing dart test/test_webserver.dart in the example directory.

Web client #

The sample code of the web client is in the test/test_webclient.dart file in the example directory.

You can execute dart test/test_webclient.dart in the example directory to initiate a web client call.

Websocket server #

The sample code of the Websocket server is in the test/test_wssserver.dart file in the example directory.

You can execute dart test/test_wssserver.dart in the example directory to start the Websocket server.

Websocket client #

The example code of the example Websocket client is in the test/test_wssclient.dart file in the example directory.

You can execute dart test/test_wssclient.dart in the example directory to initiate a Websocket client call.

4. Dart subset virtual machine module, which can be used in Flutter's AOT environment #

Because the flutter environment cannot push code in the AOT environment, hot update has become a problem. Fortunately, dart officially provides the dart:analyzer code analysis package, and this module is developed based on this package.

Generate virtual machine bridge type #

The code to generate the virtual machine bridge type is in the test/test_vmgen.dart file in the example directory.

Bridge types can be generated by executing dart test/test_vmgen.dart in the example directory. The generated files are in the bridge directory.

Dart subset virtual machine usage #

The code for Dart subset virtual machine usage is in the test/test_vmware.dart file in the example directory.

You can execute dart test/test_vmware.dart in the example directory to view the console output.

Dart code push solution in Flutter environment #

Dart network client library for ZyCloud service zycloud_client

Flutter widget library for ZyCloud service zycloud_widget

Notice:

  1. Some syntaxes of the current virtual machine are not yet compatible, but the compatible syntax is sufficient to meet most requirements.

  2. The author has used this solution to carry out project practice in the production environment. This practice project has achieved 99% of dart code push in the AOT environment.

5. Log module #

The code of the log module is in the test/test_logger.dart file in the example directory.

You can execute dart test/test_logger.dart in the example directory to view the console output information.

6. Language localization module #

The code of the language localization module is in the test/test_locale.dart file in the example directory.

You can execute dart test/test_locale.dart in the example directory to view the console output information.

7. Server and client in cluster environment #

Cluster server #

The code of the cluster server is in the app/app_server.dart file in the example directory.

Notice:

  1. The example server contains two environment configurations: develop and release. You can customize many environment configurations according to actual needs.

  2. The example server contains three service nodes, namely: Public Web service node http 、 Public Websocket service node outer 、 Internal business service node inner.

Cluster client #

The code of the cluster client is in the app/app_client.dart file in the example directory.

Test process #

  1. Open a new console window and execute dart app/app_server.dart in the example directory to start the server

  2. Open a new console window and execute dart app/app_client.dart 8001 in the example directory to start the persistent connection client of user aaa grouped by cat

  3. Open a new console window, and execute dart app/app_client.dart 8002 in the example directory to start the long-term connection client of user bbb grouped by cat

  4. Open a new console window and execute dart app/app_client.dart 8003 in the example directory to start the persistent connection client of user ccc of the dog group.

  5. At this point, you can observe the output of each console window.

  6. Open a new console window and execute dart app/app_client.dart 8080 in the example directory to start the http client to push data.

  7. At this point, you can observe the output of each console window.

6
likes
140
pub points
51%
popularity

Publisher

verified publishercszykj.com

This library includes a json model generator, a unified database operator interface, a server and client framework, a virtual machine for AOT code push, and a log module.

Repository (GitHub)
View/report issues

Topics

#client #server #shelf #eval #codepush

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, bson, crypto, dart_style, encrypt, fixnum, http, http_parser, meta, mime, mongo_dart, shelf, shelf_gzip, shelf_multipart, shelf_router, shelf_static, shelf_web_socket, uuid, web_socket_channel

More

Packages that depend on shelf_easy