platform/packages/sembast/example/main.dart

22 lines
753 B
Dart
Raw Normal View History

2021-06-21 06:16:06 +00:00
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:angel3_sembast/angel3_sembast.dart';
2018-11-06 06:04:37 +00:00
import 'package:logging/logging.dart';
import 'package:sembast/sembast_io.dart';
2021-06-20 12:37:20 +00:00
void main() async {
var app = Angel();
2018-11-06 06:04:37 +00:00
var db = await databaseFactoryIo.openDatabase('todos.db');
app
..logger = (Logger('angel_sembast_example')..onRecord.listen(print))
..use('/api/todos', SembastService(db, store: 'todos'))
2018-11-06 06:04:37 +00:00
..shutdownHooks.add((_) => db.close());
var http = AngelHttp(app);
2018-11-06 06:04:37 +00:00
var server = await http.startServer('127.0.0.1', 3000);
var uri =
Uri(scheme: 'http', host: server.address.address, port: server.port);
2018-11-06 06:04:37 +00:00
print('angel_sembast example listening at $uri');
}