2024-10-13 01:45:27 +00:00
|
|
|
import 'package:protevus_container/mirrors.dart';
|
|
|
|
import 'package:protevus_framework/protevus_framework.dart';
|
|
|
|
import 'package:protevus_mongo/protevus_mongo.dart';
|
2018-10-18 23:01:58 +00:00
|
|
|
import 'package:mongo_dart/mongo_dart.dart';
|
|
|
|
|
2021-06-18 10:17:13 +00:00
|
|
|
void main() async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var app = Protevus(reflector: MirrorsReflector());
|
2024-07-02 16:13:02 +00:00
|
|
|
var db = Db('mongodb://localhost:27017/testDB');
|
2018-10-18 23:01:58 +00:00
|
|
|
await db.open();
|
2024-07-04 16:04:58 +00:00
|
|
|
await db.authenticate("root", "Qwerty", authDb: "admin");
|
2018-10-18 23:01:58 +00:00
|
|
|
|
2021-06-18 10:17:13 +00:00
|
|
|
var service = app.use('/api/users', MongoService(db.collection('users')));
|
2018-10-18 23:01:58 +00:00
|
|
|
|
|
|
|
service.afterCreated.listen((event) {
|
2021-06-18 10:17:13 +00:00
|
|
|
print('New user: ${event.result}');
|
2018-10-18 23:01:58 +00:00
|
|
|
});
|
|
|
|
}
|