shelf_modular 2.0.0-dev.2 copy "shelf_modular: ^2.0.0-dev.2" to clipboard
shelf_modular: ^2.0.0-dev.2 copied to clipboard

outdated

Smart project structure with dependency injection and route management

2.0.0 - 2022/05/25 #

  • [BREAK CHANGE]: Update to new Dart 2.17. Preview version will no longer be supported.

  • [BREAK CHANGE]: New auto-dispose configuration. Starting with version 2.0, Modular will provide the Bind.onDispose property for calls to destroy, close or dispose methods FOR EACH BIND. This will make the dispose settings more straightforward and less universal. Therefore, Modular will manage the destruction of Binds that implement Disposable only. This is the new configuration:

@override
final List<Bind> binds = [
  Bind.singleton((i) => MyBloc(), onDispose: (bloc) => bloc.close()),
];

The Bind.onDispose CANNOT be used in Bind type factory. You can choose to use Bind.onDispose or implement the Disposable class.

  • [BREAK CHANGE] Bind.export works only after imported.

  • feat: Added new Middleware system:

class AuthGuard extends ModularMiddleware {
  @override
  Handler call(Handler handler, ModularRoute route) {
    return (request) {
      final accessToken = request.headers['Authorization']?.split(' ').last;
      if (accessToken == null || accessToken.isEmpty || accessToken != '1234') {
        return Response.forbidden(jsonEncode({'error': 'Not authorized'}));
      }
      return handler(request);
    };
  }
}

1.0.2 - 2022/04/05 #

  • Update modular_core

1.0.1 - 2021/12/31 #

  • Fixed "bind replaced" bug

1.0.0 - 2021/10/20 #

  • initial release.
  • New doc!
34
likes
0
pub points
72%
popularity

Publisher

unverified uploader

Smart project structure with dependency injection and route management

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http_parser, meta, mime, modular_core, shelf, shelf_web_socket, web_socket_channel

More

Packages that depend on shelf_modular