shelf_simple_session 0.1.3

  • README.md
  • Installing
  • Versions
  • 34

shelf_simple_session

A very simple cookie based session handler for dart Shelf middleware.

Here is an example of usage (see example/session_example.dart)

    // simple handler that increments a counter stored in the session
      shelf.Response pingHandler(shelf.Request request) {
      
        // session() function gets a reference to the session map
        var map = session(request);
        var c = map['counter'];
        int counter = ( c == null ? 0 : c) +1;
        //store counter in the session
        map['counter'] = counter;
    
        return new shelf.Response.ok("ping counter=$counter");
      }
    
    
      var handler = const shelf.Pipeline()
          .addMiddleware(shelf.logRequests())
          .addMiddleware(sessionMiddleware(new SimpleSessionStore()))
          .addHandler(pingHandler);
    
      // listen on port 7001
      io.serve(handler, InternetAddress.ANY_IP_V4, 7001);

TO DO

This is super simple, and there are lots of enhancements that should be made:

  • The session maintenance / timeout code is not efficient
  • This wont work in a multi-isolate environment (needs some of way of sharing session data between isolates)
  • When Shelf gets proper cookie handling, the cookie code in here should be replaced
  • Tests. Could use some
  • Implement session data encryption

Use this package as a library

1. Depend on it

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


dependencies:
  shelf_simple_session: "^0.1.3"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:shelf_simple_session/shelf_simple_session.dart';
  
Version Uploaded Documentation Archive
0.1.3 Dec 8, 2016 Go to the documentation of shelf_simple_session 0.1.3 Download shelf_simple_session 0.1.3 archive
0.1.2 Oct 10, 2014 Go to the documentation of shelf_simple_session 0.1.2 Download shelf_simple_session 0.1.2 archive
0.1.1 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.1 Download shelf_simple_session 0.1.1 archive
0.1.0 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.0 Download shelf_simple_session 0.1.0 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, other

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

Suggestions

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 9 hints.

    Strong-mode analysis of lib/src/session.dart failed with the following error:

    line: 183 col: 58
    The argument type '(Response) → Response' can't be assigned to the parameter type '(dynamic) → FutureOr<dynamic>'.

    Run dartfmt to format lib/shelf_simple_session.dart.

    Similar analysis of the following files failed:

    • lib/src/cookie.dart (hint)
    • lib/src/shelf_simple_session.dart (hint)
  • Package is getting outdated.

    The package was released 79 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use shelf_simple_session.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.5.0 <2.0.0
crypto >=0.9.0 <1.0.0 0.9.2+1 2.0.5
logging >=0.9.1 <1.0.0 0.11.3+1
shelf >=0.5.4 <0.7.0 0.6.8 0.7.3+1
Transitive dependencies
async 1.13.3 2.0.7
charcode 1.1.1
collection 1.14.10
convert 1.1.1 2.0.1
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
typed_data 1.1.5