2024-10-13 01:45:27 +00:00
|
|
|
import 'package:protevus_cache/protevus_cache.dart';
|
|
|
|
import 'package:protevus_framework/protevus_framework.dart';
|
|
|
|
import 'package:protevus_framework/http.dart';
|
2018-04-02 03:41:43 +00:00
|
|
|
|
2021-06-22 10:42:26 +00:00
|
|
|
void main() async {
|
2024-10-12 10:35:14 +00:00
|
|
|
var app = Protevus();
|
2018-04-02 03:41:43 +00:00
|
|
|
|
|
|
|
app.use(
|
|
|
|
'/api/todos',
|
2021-02-14 05:22:25 +00:00
|
|
|
CacheService(
|
2021-06-22 10:42:26 +00:00
|
|
|
cache: MapService(),
|
|
|
|
database: AnonymousService(index: ([params]) {
|
|
|
|
print(
|
|
|
|
'Fetched directly from the underlying service at ${DateTime.now()}!');
|
|
|
|
return ['foo', 'bar', 'baz'];
|
|
|
|
}, read: (dynamic id, [params]) {
|
|
|
|
return {id: '$id at ${DateTime.now()}'};
|
|
|
|
})),
|
2018-04-02 03:41:43 +00:00
|
|
|
);
|
|
|
|
|
2024-10-12 10:35:14 +00:00
|
|
|
var http = ProtevusHttp(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}');
|
|
|
|
}
|