sevr 1.0.2+3 copy "sevr: ^1.0.2+3" to clipboard
sevr: ^1.0.2+3 copied to clipboard

outdated

A library to easily create http servers with Dart and perform Http requests.

A library for building REST APIs easily with Dart modeled after Express JS for Node Js.

The library is still a work in progress and open to contribution.

Created with StageHand - license.

Inspiration #

Our inspiration is the simplicity of express js 👏.

Usage #

A simple usage example:

import 'package:sevr/sevr.dart';

main() {
  var serv = Sevr();

  //first notify **sevr** of your directory of static files
  serv.use(Sevr.static('./web'));

  //create controller,middleware classes etc, put them in a list and pass them into the router methods

  //serve files from the port
  serv.get('/file', [
    (ServRequest req, ServResponse res) {
      return res.status(200).sendFile(p.absolute('web/index.html'));
    }
  ]);

  // get request that returns json
  serv.get('/test', [
    (ServRequest req, ServResponse res) {
      return res.status(200).json({'status': 'ok'});
    }
  ]);

  //post request
  serv.post('/post', [
    (ServRequest req, ServResponse res) async {
      return res.status(200).json(req.body);
    }
  ]);

  //create server connection
  serv.listen(4000, callback: () {
    print('Listening on port: ${4000}');
  });
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Contributing #

Fork the repo, clone and raise your pull requests against the dev branch, We look forward to your your commits! 😀

16
likes
0
pub points
42%
popularity

Publisher

unverified uploader

A library to easily create http servers with Dart and perform Http requests.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

body_parser, dart2_constant, mime, path, pedantic

More

Packages that depend on sevr