platform/packages/file_service/README.md

34 lines
1.3 KiB
Markdown
Raw Normal View History

2021-06-10 08:47:05 +00:00
# angel3_file_service
2021-06-11 00:18:24 +00:00
[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_file_service)
2021-06-10 08:47:05 +00:00
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/file_service/LICENSE)
2018-07-12 20:29:16 +00:00
2017-06-13 16:55:07 +00:00
Angel service that persists data to a file on disk, stored as a JSON list. It uses a simple
mutex to prevent race conditions, and caches contents in memory until changes
are made.
The file will be created on read/write, if it does not already exist.
This package is useful in development, as it prevents you from having to install
an external database to run your server.
When running a multi-threaded server, there is no guarantee that file operations
will be mutually excluded. Thus, try to only use this one a single-threaded server
if possible, or one with very low load.
While not necessarily *slow*, this package makes no promises about performance.
# Usage
```dart
configureServer(Angel app) async {
// Just like a normal service
2017-12-21 06:37:03 +00:00
app.use(
'/api/todos',
new JsonFileService(
const LocalFileSystem().file('todos_db.json')
),
);
2017-06-13 16:55:07 +00:00
}
```