SpryModule.vala 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. using InvercargillSqlInversion;
  2. using Inversion;
  3. namespace Spry {
  4. /**
  5. * Inversion module that registers Spry's user store: the `spry_users` and
  6. * `spry_user_permissions` schema (M0001 migration), the entity/projection
  7. * mappings, and the scoped {@link Spry.Authentication.UserService}.
  8. *
  9. * Register this module with the application container alongside
  10. * `StatumModule`; it registers no endpoints. Ready-made actions are bound
  11. * separately via {@link SpryAuth.register_actions} or
  12. * `StatumConfigurator.action`.
  13. */
  14. public class SpryModule : Object, Module {
  15. public void register_components(Container container) throws Error {
  16. // Sql table setup
  17. var sql = container.configure_with<DatabaseConfigurator>();
  18. sql.add_migration<Authentication.Migrations.M0001_Initial>();
  19. sql.add_entity<Authentication.UserEntity>(Authentication.UserEntity.entity_mapping);
  20. sql.add_entity<Authentication.UserPermissionEntity>(Authentication.UserPermissionEntity.entity_mapping);
  21. sql.add_projection<Authentication.UserProjection>(Authentication.UserProjection.projection_mapping);
  22. // Service setup
  23. container.register_scoped<Authentication.UserService>();
  24. }
  25. }
  26. }