platform/packages/sembast/example/main.dart

22 lines
748 B
Dart
Raw Normal View History

2018-11-06 06:04:37 +00:00
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_framework/http.dart';
import 'package:angel_sembast/angel_sembast.dart';
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');
}