angel_file_service 2.0.1

file_service #

Pub build status

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 #

configureServer(Angel app) async {
  // Just like a normal service
  app.use(
    '/api/todos',
    new JsonFileService(
      const LocalFileSystem().file('todos_db.json')
    ),
  );
}

2.0.1 #

  • Pass everything through _jsonifyToSD when returning responses.

2.0.0 #

  • Dart/Angel 2 update.
  • Remove package:dart2_constant
  • Update package:file to ^5.0.0.

1.1.2 #

  • Added tests, because tests.

1.1.1 #

  • Dart 2 fixes.

1.1.0+2 #

  • create now uses the underlying store, instead of manually patching

1.1.0+1 #

  • Analyzer nitpick for pana

1.1.0 #

  • Updated to framework v1.1.x
  • Use package:file
  • Allow a custom store

example/main.dart

import 'package:angel_file_service/angel_file_service.dart';
import 'package:angel_framework/angel_framework.dart';
import 'package:file/local.dart';

configureServer(Angel app) async {
  // Just like a normal service
  app.use(
    '/api/todos',
    new JsonFileService(const LocalFileSystem().file('todos_db.json')),
  );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  angel_file_service: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:angel_file_service/angel_file_service.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
91
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:angel_file_service/angel_file_service.dart with components: io.

Health suggestions

Fix lib/angel_file_service.dart. (-4.41 points)

Analysis of lib/angel_file_service.dart reported 9 hints, including:

line 15 col 27: Use = to separate a named parameter from its default value.

line 15 col 51: Use = to separate a named parameter from its default value.

line 109 col 5: DO use curly braces for all flow control structures.

line 111 col 5: DO use curly braces for all flow control structures.

line 113 col 5: DO use curly braces for all flow control structures.

Maintenance suggestions

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
angel_framework ^2.0.0-alpha 2.0.4
file ^5.0.0 5.0.8+1
pool ^1.0.0 1.4.0
Transitive dependencies
angel_container 1.0.4
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.0.6
async 2.3.0
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.11
combinator 1.1.0
convert 2.1.1
crypto 2.0.6
dart2_constant 1.0.2+dart2
http2 1.0.0
http_parser 3.1.3
http_server 0.9.8+3
intl 0.15.8
logging 0.11.3+2
matcher 0.12.5
merge_map 1.0.2
meta 1.1.7
mime 0.9.6+3
mock_request 1.0.6
path 1.6.2
pedantic 1.8.0+1
quiver 2.0.3
quiver_hashcode 2.0.0
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
term_glyph 1.1.0
tuple 1.0.2
typed_data 1.1.6
uuid 2.0.2
Dev dependencies
test ^1.0.0

Admin