jaguar 0.6.22 jaguar: ^0.6.22 copied to clipboard
Jaguar is a production ready HTTP server framework built for speed, simplicity and extensiblity
Jaguar #
Jaguar is a production ready server framework built for speed, simplicity and extensiblity
Advantages of Jaguar #
- Batteries included
- Database
- Fluent query builder
- ORM
- Migration support
- Various databases support
- Mongo
- PostgreSQL (Query)
- MySQL (Query)
- OracleDB
- MS SQL
- Authentication and Authorization
- OAuth
- Session management
- Database
- Build your routes the way you prefer
- Controller based
- Reflect
- Generate
- Mux based
- Controller based
- Extensible interceptor infrastructure
- Extensive respository of examples
Usage #
Swiftly build REST Api #
Below example shows how to add routes to Jaguar.dart server.
@Api(path: '/api')
class ExampleApi {
/// This route shows how to write JSON response in jaguar.dart.
/// [Response] class has a static constructor method called [json]. This
/// method encodes the given Dart built-in object to JSON string
@Get(path: '/hello')
Response<String> sayHello(Context ctx) => Response.json({
"greeting": "Hello",
});
/// This route shows how to read JSON request and write JSON response in
/// jaguar.dart.
@Post(path: '/math')
Future<Response<String>> math(Context ctx) async {
/// [bodyAsJsonMap] method on [Request] object can be used to decode JSON
/// body of the request into Dart built-in object
final Map body = await ctx.req.bodyAsJsonMap();
final int a = body['a'];
final int b = body['b'];
return Response.json({
'addition': a + b,
'subtraction': a - b,
'multiplication': a * b,
'division': a ~/ b,
});
}
}
JSON serialization with little effort #
TODO
Connect to MongoDB #
TODO
Connect to PostgreSQL #
TODO
Add user authentication #
TODO