dart_express 0.5.3 dart_express: ^0.5.3 copied to clipboard
An unopinionated express-like HTTP framework built in Dart, includes the ability to render Mustache, Jael and HTML files, and simple routing.
example/dart_express_example.dart
import 'package:dart_express/dart_express.dart';
import 'package:path/path.dart' as path;
import './api_routes.dart';
import './view_routes.dart';
const int PORT = 5000;
void main() {
final app = express();
app.use(BodyParser.json());
app.use(CorsMiddleware.use());
app.use(LoggerMiddleware.use(includeImmediate: true));
app.engine(MarkdownEngine.use());
app.engine(MustacheEngine.use());
app.engine(JaelEngine.use());
app.set('print routes', true);
app.set('views', path.join(path.current, 'example/views'));
app.set('view engine', 'mustache');
app.useRouter('/api/', apiRouter());
app.useRouter('/', viewRouter());
app.listen(port: PORT, cb: (int port) => print('Listening on port $port'));
}