json_server 1.0.0+3

JSON Server #

Launch JSON server for web and mobile apps development from CLI without complicated backend setup.

Usage #

jserver --data=<path to JSON file>

Available options you can use:

  • -d, --data: path to JSON database file. Required.
  • -h, --host: specify the IP address to serve. Default to 127.0.0.1.
  • -p, --port: specify the port to use. Default to 1711.

JSON Format #

Typically, for JSON database, you need to use following structure.

{
  "API_PATH_1": RESPONSE_OBJECT_1,
  "API_PATH_2": RESPONSE_OBJECT_2,
}

API_PATH must start with a slash / to mark it as a serving path for API. RESPONSE_OBJECT: should be either Array or Object.

Examples #

To start a default server, which binds to 127.0.0.1:1711, using database.json.

$ jserver -d database.json

To start server at localhost:8888 using api.json for database.

$ jserver -h localhost -p 8888 -d api.json

LICENSE #

MIT @ 2019 Pete Houston.

1.0.0 #

First release

1.0.0+2 #

  • Add example.

1.0.0+3 #

  • Fix issue when parsing arguments.
  • Provide internal log util.

example/README.md

Examples #

To start a default server, which binds to 127.0.0.1:1711, using database.json.

$ jserver -d database.json
$ jserver --data database.json

To start server at localhost:8888 using api.json for database.

$ jserver -h localhost -p 8888 -d api.json

Alternatively, you can use:

$ jserver --host localhost --port 8888 -d api.json

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate json_server

2. Use it

The package has the following executables:


$ jserver

Use this package as a library

1. Depend on it

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


dependencies:
  json_server: ^1.0.0+3

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:json_server/json_server.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

20 out of 20 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format bin/main.dart.

Run dartfmt to format bin/main.dart.

Format lib/json_server.dart.

Run dartfmt to format lib/json_server.dart.

Format lib/src/json_server.dart.

Run dartfmt to format lib/src/json_server.dart.

Format lib/src/utils.dart.

Run dartfmt to format lib/src/utils.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
args ^1.5.2 1.5.2
path ^1.6.0 1.6.4
Dev dependencies
pedantic ^1.8.0
test ^1.6.0