https://github.com/carlosjs23/evy
Dart 2 Web Framework, with an ExpressJS like API.
https://github.com/carlosjs23/evy
dart dart2 express flutter framework
Last synced: about 1 month ago
JSON representation
Dart 2 Web Framework, with an ExpressJS like API.
- Host: GitHub
- URL: https://github.com/carlosjs23/evy
- Owner: carlosjs23
- License: mit
- Created: 2018-08-01T05:16:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-08-16T22:35:29.000Z (7 months ago)
- Last Synced: 2025-10-22T23:41:59.591Z (5 months ago)
- Topics: dart, dart2, express, flutter, framework
- Language: Dart
- Size: 59.6 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Evy
[](https://gitter.im/evy-dart/evy)
Evy is a Dart 2 Web Framework, with an ExpressJS like API.
## Getting Started
For start using Evy in your project you need to clone this repo and add it to dependencies section in your pubspec.yaml file:
```yaml
# pubspec.yaml
name: example_app
description: My app
dependencies:
evy:
path: /path/to/evy
```
### Prerequisites
* [Dart 2 SDK](https://www.dartlang.org/tools/sdk#install)
## Example code
```dart
import 'package:evy/evy.dart';
void main() {
var app = Evy();
/// This middleware will match all routes.
app.use(handler: logRequest);
/// This middleware will be called only for '/greet/:name' routes.
app.use(path: '/greet/:name', handler: checkName);
/// This middleware will be called only for '/greet/:name' routes.
/// It will be executed after checkName middleware.
app.use(path: '/greet/:name', handler: changeName);
/// Or just pass the middleware callbacks as a list.
/// app.use(path: '/greet/:name', callback: [checkName, changeName]);
///Routes can have a callback for process the request.
app.get(path: '/greet/:name', handler: sayHello);
///Path can be a RegExp, this route will match /evy, /evyhi, /whateverevy... .
app.get(path: RegExp('/.*evy'), handler: sayHello);
///Path can be a List of Strings, this will match /users, /user and /client.
app.get(path: ['/users', '/user', '/client'], handler: sayHello);
app.listen(
port: 3000,
callback: (error) {
if (error != null) {
print(error);
} else {
print('Server listening on port 3000');
}
});
}
void changeName(Request req, Response res, next) {
if (req.params['name'] == 'Alberto') {
req.params['name'] = 'Carlos';
}
next();
}
void checkName(Request req, Response res, next) {
if (req.params['name'] != 'Alberto') {
res.send('Only Alberto is allowed to use this action');
} else {
next();
}
}
void logRequest(Request req, Response res, next) {
/// Do your logging stuff and then call next()
print('${req.ip} - - [${DateTime.now()}] "${req.method} ${req.originalUrl}"');
next();
}
void sayHello(Request req, Response res, next) {
if (req.params['name'] != null) {
res.send('Hello ${req.params['name']}');
} else {
res.send('Hello');
}
}
```
### Todo
- [X] Implement basic HTTP methods (~~POST~~, PUT, etc).
- [X] Create Request and Response wrappers.
- [X] Per Route Middlewares.
- [X] Global Middlewares.
- [X] Sub-apps ``app.use(path: '/billing', app: billingApp)``.
- [ ] ~~Serve static files~~ (Use a package instead).
- [ ] ~~Content body parsing~~ (Use a package instead).
- [ ] Routes group.
- [ ] Publish package to Dart Packages.
- [ ] Testing.
- [ ] Logo design.