diff --git a/.idea/file_service.iml b/.idea/file_service.iml
index 1b1acc21..eae13016 100644
--- a/.idea/file_service.iml
+++ b/.idea/file_service.iml
@@ -5,7 +5,6 @@
-
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..fdc5dc8b
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,4 @@
+# 1.1.0
+* Updated to framework v1.1.x
+* Use `package:file`
+* Allow a custom `store`
\ No newline at end of file
diff --git a/README.md b/README.md
index d93697f2..1522410c 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,11 @@ While not necessarily *slow*, this package makes no promises about performance.
```dart
configureServer(Angel app) async {
// Just like a normal service
- app.use('/api/todos', new JsonFileService(new File('todos_db.json')));
+ app.use(
+ '/api/todos',
+ new JsonFileService(
+ const LocalFileSystem().file('todos_db.json')
+ ),
+ );
}
```
\ No newline at end of file
diff --git a/lib/angel_file_service.dart b/lib/angel_file_service.dart
index 0b658977..9f744eef 100644
--- a/lib/angel_file_service.dart
+++ b/lib/angel_file_service.dart
@@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:convert';
-import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
+import 'package:file/file.dart';
import 'package:pool/pool.dart';
/// Persists in-memory changes to a file on disk.
@@ -12,10 +12,11 @@ class JsonFileService extends Service {
final File file;
JsonFileService(this.file,
- {bool allowRemoveAll: false, bool allowQuery: true}) {
- _store = new MapService(
- allowRemoveAll: allowRemoveAll == true,
- allowQuery: allowQuery != false);
+ {bool allowRemoveAll: false, bool allowQuery: true, MapService store}) {
+ _store = store ??
+ new MapService(
+ allowRemoveAll: allowRemoveAll == true,
+ allowQuery: allowQuery != false);
}
_load() async {
@@ -46,6 +47,11 @@ class JsonFileService extends Service {
r.release();
}
+ @override
+ Future close() {
+ return _store.close();
+ }
+
@override
Future index([Map params]) async =>
_load().then((_) => _store.index(params));
diff --git a/pubspec.yaml b/pubspec.yaml
index be7af0fd..563a5fad 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,10 +1,11 @@
name: angel_file_service
-version: 1.0.0
+version: 1.1.0
description: Angel service that persists data to a file on disk.
author: Tobe O
homepage: https://github.com/angel-dart/file_service
environment:
sdk: ">=1.19.0"
dependencies:
- angel_framework: ^1.0.0-dev
+ angel_framework: ^1.1.0-alpha
+ file: ^2.0.0
pool: ^1.0.0
\ No newline at end of file