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';
|
|
|
|
|
|
|
|
main() async {
|
2019-07-18 11:08:46 +00:00
|
|
|
var app = Angel();
|
2018-11-06 06:04:37 +00:00
|
|
|
var db = await databaseFactoryIo.openDatabase('todos.db');
|
|
|
|
|
|
|
|
app
|
2019-07-18 11:08:46 +00:00
|
|
|
..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());
|
|
|
|
|
2019-07-18 11:08:46 +00:00
|
|
|
var http = AngelHttp(app);
|
2018-11-06 06:04:37 +00:00
|
|
|
var server = await http.startServer('127.0.0.1', 3000);
|
|
|
|
var uri =
|
2019-07-18 11:08:46 +00:00
|
|
|
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');
|
|
|
|
}
|