2021-05-30 00:46:13 +00:00
|
|
|
import 'package:angel3_cache/angel3_cache.dart';
|
|
|
|
import 'package:angel3_framework/angel3_framework.dart';
|
|
|
|
import 'package:angel3_framework/http.dart';
|
2018-04-02 03:41:43 +00:00
|
|
|
|
|
|
|
main() async {
|
2021-02-14 05:22:25 +00:00
|
|
|
var app = Angel();
|
2018-04-02 03:41:43 +00:00
|
|
|
|
|
|
|
app.use(
|
|
|
|
'/api/todos',
|
2021-02-14 05:22:25 +00:00
|
|
|
CacheService(
|
|
|
|
cache: MapService(),
|
|
|
|
database: AnonymousService(index: ([params]) {
|
2018-10-21 09:35:04 +00:00
|
|
|
print(
|
|
|
|
'Fetched directly from the underlying service at ${new DateTime.now()}!');
|
|
|
|
return ['foo', 'bar', 'baz'];
|
2021-05-30 00:46:13 +00:00
|
|
|
}, read: (dynamic id, [params]) {
|
2018-10-21 09:35:04 +00:00
|
|
|
return {id: '$id at ${new DateTime.now()}'};
|
|
|
|
}),
|
2018-04-02 03:41:43 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2021-02-14 05:22:25 +00:00
|
|
|
var http = AngelHttp(app);
|
2018-04-02 03:41:43 +00:00
|
|
|
var server = await http.startServer('127.0.0.1', 3000);
|
|
|
|
print('Listening at http://${server.address.address}:${server.port}');
|
|
|
|
}
|