Skip to content

Commit 10ce2eb

Browse files
authored
Merge pull request #8 from khode-io/feature/module-router
feat: Add module to support router by using GoRouter.
2 parents aeb4fac + a45f4a8 commit 10ce2eb

24 files changed

+741
-167
lines changed

README.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ A NestJS-inspired dependency injection framework for Dart, bringing modular arch
88
- 💉 **Dependency Injection** - Type-safe service resolution with GetIt
99
- 🔒 **Access Control** - Services are private by default, must be explicitly exported
1010
- 🔧 **Multi-Platform** - Works with Flutter, Dart Frog, and pure Dart applications
11+
- 🚦 **Module-Based Routing** - GoRouter integration with automatic route collection
1112

1213
## Packages
1314

14-
- **nest_core** - Core dependency injection and module system
15-
- **nest_flutter** - Flutter integration with provider support
16-
- **nest_frog** - Dart Frog backend integration
15+
| Package | Version | Description |
16+
|---------|---------|-------------|
17+
| **[nest_core](packages/nest_core)** | ![pub version](https://img.shields.io/pub/v/nest_core.svg) | Core dependency injection and module system |
18+
| **[nest_flutter](packages/nest_flutter)** | ![pub version](https://img.shields.io/pub/v/nest_flutter.svg) | Flutter integration with GoRouter and provider support |
19+
| **[nest_frog](packages/nest_frog)** | ![pub version](https://img.shields.io/pub/v/nest_frog.svg) | Dart Frog backend integration with middleware support |
1720

1821
## Quick Start
1922

23+
### Core Application
24+
2025
```dart
2126
import 'package:nest_core/nest_core.dart';
2227
@@ -26,22 +31,79 @@ class AppModule extends Module {
2631
2732
@override
2833
void providers(Locator locator) {
29-
// Register your services here
34+
locator.registerSingleton<UserService>(UserService());
3035
}
3136
3237
@override
33-
List<Type> get exports => []; // Export services to other modules
38+
List<Type> get exports => [UserService];
3439
}
3540
3641
// Initialize the application
37-
final container = ApplicationContainer(AppModule());
38-
await container.initialize();
42+
final container = ApplicationContainer();
43+
await container.registerModule(AppModule());
44+
```
45+
46+
### Flutter Integration
47+
48+
```dart
49+
import 'package:flutter/material.dart';
50+
import 'package:nest_flutter/nest_flutter.dart';
51+
52+
void main() {
53+
runApp(
54+
ModularApp(
55+
module: AppModule(),
56+
child: MyApp(),
57+
),
58+
);
59+
}
60+
61+
class MyApp extends StatelessWidget {
62+
@override
63+
Widget build(BuildContext context) {
64+
return MaterialApp.router(
65+
routerConfig: Modular.router((router) {
66+
return GoRouter(
67+
routes: router.configuration.routes,
68+
initialLocation: '/',
69+
);
70+
}),
71+
);
72+
}
73+
}
74+
```
75+
76+
### Module with Routes
77+
78+
```dart
79+
class UserModule extends Module {
80+
@override
81+
List<RouteBase> get routes => [
82+
GoRoute(
83+
path: '/users',
84+
builder: (context, state) => UserListPage(),
85+
),
86+
];
87+
88+
@override
89+
void providers(Locator locator) {
90+
locator.registerSingleton<UserService>(UserService());
91+
}
92+
}
3993
```
4094

4195
## Examples
4296

43-
- **Flutter App** - Mobile app with modular architecture
44-
- **Frog Backend** - REST API server with dependency injection
97+
- **[Flutter App](examples/flutter_app)** - Mobile app with modular architecture and GoRouter integration
98+
- **[Frog Backend](examples/frog_backend)** - REST API server with dependency injection and middleware
99+
100+
## Documentation
101+
102+
- 📖 **[Getting Started](https://khode-io.github.io/nest-dart/getting-started)** - Quick introduction to Nest Dart
103+
- 🎯 **[Core Guide](https://khode-io.github.io/nest-dart/core-guide)** - Dependency injection fundamentals
104+
- 📱 **[Flutter Guide](https://khode-io.github.io/nest-dart/flutter-guide)** - Flutter integration and routing
105+
- 🐸 **[Frog Guide](https://khode-io.github.io/nest-dart/frog-guide)** - Dart Frog backend development
106+
- 🔧 **[API Reference](https://khode-io.github.io/nest-dart/api-reference)** - Complete API documentation
45107

46108
## Development
47109

@@ -54,4 +116,8 @@ melos run test
54116

55117
# Format code
56118
melos run format
57-
```
119+
```
120+
121+
## License
122+
123+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)