dart_express 0.1.0 copy "dart_express: ^0.1.0" to clipboard
dart_express: ^0.1.0 copied to clipboard

outdated

A express-like HTTP framework built in Dart

An express-like web server framework for Dart developers.

Created from templates made available by Stagehand under a BSD-style license.

Usage #

A simple usage example:

import 'package:dart_express/dart_express.dart';

main() {
  var app = express();

  app.get('/', (req, res, _) {
    res.json({
      'hello': 'world',
      'test': true,
    });
  });

  app.listen(3000, (port) => print('Listening on port $port');
}

With Body parsing Middleware:

import 'package:dart_express/dart_express.dart';

main() {
  var app = express();

  app.use(BodyParser.json());

  app.post('/post', (req, res, _) {
    print(req.body);

    res.send({
      'request_body': req.body,
    });
  });

  app.listen(3000, (port) => print('Listening on port $port');
}

Using the mustache templating engine

import 'package:dart_express/dart_express.dart';

main() {
  var app = express();

  app.use(BodyParser.json());
  app.engine(MustacheEngine.use());

  app.settings.viewsPath = 'custom_views_path';
  app.settings.viewEngine = 'mustache';

  app.get('/', (req, res, _) {
    res.render('index', {
      'app_name': 'My Test App',
    });
  });

  app.listen(3000, (port) => print('Listening on port $port');
}

Currently supported View Engines #

  • Basic HTML
  • Mustache
  • Jael

Roadmap #

  • ✅ Basic Routing
  • ✅ Easily build Middleware
  • ✅ Add & use view engines easily
  • [] Add in-depth testing
  • [] Add support for routes with params like express supports. example: "/posts/:postId"
  • [] Clean up imports and extract middleware to separate packages
  • [] Add Dart "morgan" middleware package for logging HTTP requests
  • [] Add CORS middleware package
16
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A express-like HTTP framework built in Dart

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http, jael, meta, mustache4dart, path

More

Packages that depend on dart_express