2018-08-04 03:05:51 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
|
|
|
import 'package:angel_hot/angel_hot.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:star_wars/src/pretty_logging.dart' as star_wars;
|
|
|
|
import 'package:star_wars/star_wars.dart' as star_wars;
|
|
|
|
|
|
|
|
main() async {
|
|
|
|
Future<Angel> createServer() async {
|
2019-03-29 01:33:21 +00:00
|
|
|
hierarchicalLoggingEnabled = true;
|
2019-04-11 17:05:47 +00:00
|
|
|
var logger = Logger.detached('star_wars')
|
2019-03-29 01:33:21 +00:00
|
|
|
..onRecord.listen(star_wars.prettyLog);
|
2019-04-11 17:05:47 +00:00
|
|
|
var app = Angel(logger: logger);
|
2018-08-04 03:05:51 +00:00
|
|
|
await app.configure(star_wars.configureServer);
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
2019-04-11 17:05:47 +00:00
|
|
|
var hot = HotReloader(createServer, [Directory('lib')]);
|
2018-08-04 03:05:51 +00:00
|
|
|
|
|
|
|
var server = await hot.startServer('127.0.0.1', 3000);
|
|
|
|
var serverUrl =
|
2019-04-11 17:05:47 +00:00
|
|
|
Uri(scheme: 'http', host: server.address.address, port: server.port);
|
2018-08-04 03:05:51 +00:00
|
|
|
var graphiQLUrl = serverUrl.replace(path: '/graphiql');
|
|
|
|
print('Listening at $serverUrl');
|
|
|
|
print('GraphiQL endpoint: $graphiQLUrl');
|
|
|
|
}
|