jaguar_boilerplate 2.4.1

  • Readme
  • Changelog
  • Installing
  • 46

boilerplate for Jaguar projects #

This project contains a simple example shows how to add routes to Jaguar using Controller classes.

The repository can be found at: https://github.com/jaguar-examples/boilerplate. One would typically want to clone it and edit it in IntelliJ IDE.

Server description #

It exposes four routes for demonstration purposes:

  1. A simple GET route
  2. A simple POST route that uses query parameters
  3. A simple JSON GET route
  4. A simple JSON POST route that has JSON body
@Controller(path: '/api')
class ExampleApi {
  // A simple get route
  @Get(path: '/version')
  double version(_) => 0.1;

  // A simple post route
  @Post(path: '/add')
  int add(Context ctx) => ctx.query.getInt('a') + ctx.query.getInt('b');

  // A simple get JSON route
  @GetJson(path: '/info')
  Map info(_) => {
    'server': 'Jaguar',
    'motto': 'Simple. Fast. Flexible. Extensible.',
  };

  // A simple post JSON route
  @PostJson(path: '/sub')
  Future<Map> sub(Context ctx) async {
    Map body = await ctx.bodyAsJsonMap();
    return {'result': body['a'] - body['b']};
  }
}

Client description #

Contains code to access the example server.

Future<Null> execVersion() async {
  String url = "http://$kHostname:$kPort/api/version";
  http.Response resp = await _client.get(url);
  print(resp.body);
}

Future<Null> execAdd() async {
  http.Response resp = await _client.post(
      new Uri.http('$kHostname:$kPort', '/api/add', {'a': '5', 'b': '20'}));
  print(resp.body);
}

Future<Null> execInfo() async {
  String url = "http://$kHostname:$kPort/api/info";
  http.Response resp = await _client.get(url);
  print(resp.body);
}

Future<Null> execSubtract() async {
  String url = "http://$kHostname:$kPort/api/sub";
  http.Response resp = await _client.post(url, body: '{"a": 10, "b": 5}');
  print(resp.body);
}

main() async {
  await execVersion();
  await execAdd();
  await execInfo();
  await execSubtract();
}

2.2.0 #

Upgraded to Jaguar 2.2.0 #

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate jaguar_boilerplate

2. Use it

The package has the following executables:


$ jaguar_boilerplate_client
$ jaguar_boilerplate_server
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
82
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

Format bin/server.dart.

Run dartfmt to format bin/server.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

Package is getting outdated. (-7.67 points)

The package was last published 56 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.11.3 0.11.3+17 0.12.0+2
jaguar ^2.4.4 2.4.36
jaguar_reflect ^2.4.0 2.4.6
Transitive dependencies
async 2.4.0
auth_header 2.1.4
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
http_parser 3.1.3
http_server 0.9.8+3
jaguar_common 2.1.4
jaguar_serializer 2.2.12
logging 0.11.3+2
meta 1.1.7
mime 0.9.6+3
path 1.6.4
path_tree 2.2.2
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6