An open API service indexing awesome lists of open source software.

https://github.com/pyrestudios/steward

A flexible server-side web framework for Dart.
https://github.com/pyrestudios/steward

api-framework dart hacktoberfest mvc-framework router web-framework

Last synced: 7 months ago
JSON representation

A flexible server-side web framework for Dart.

Awesome Lists containing this project

README

          


Steward

A helpful framework for building server-side experiences with Dart.

-----------

[![pub version](https://img.shields.io/pub/v/steward)](https://pub.dev/packages/steward)
[![codecov](https://codecov.io/gh/PyreStudios/steward/branch/main/graph/badge.svg?token=CAK5MR60ZI)](https://codecov.io/gh/PyreStudios/steward)
[![points](https://img.shields.io/pub/points/steward)](https://pub.dev/packages/steward)
[![likes](https://img.shields.io/github/stars/pyrestudios/steward)](https://img.shields.io/github/stars/pyrestudios/steward)
[![build status](https://img.shields.io/github/checks-status/pyrestudios/steward/main?label=main%20build)](https://img.shields.io/github/checks-status/pyrestudios/steward/main?label=main%20build)
[![Documentation](https://img.shields.io/badge/Documentation-Online-blueviolet)](https://pyrestudios.github.io/steward)

Steward features a command line interface for starting a new Steward project! Check it out!

```
dart pub global activate steward
```

**Note: Steward uses a config yml file that is generated by the CLI. If you choose to not use the CLI, you'll need to generate a matching config.yml file.**

The best examples for how to use Steward are captured in the test folder. Eventually, we'll refactor this out into tests and examples separately, but for now, they live together :)

Using the Steward framework gives you the following (but not limited to) benefits:
- A modular system with light Dependency Injection, Routing, and more.
- Easy HTTP request/response management.
- Config parsing into the DI container at application boot.
- Templating via the Mustache template specification.

Here's an example of how you can use Steward!

```dart
import 'package:steward/steward.dart';

Future main() async {
final router = Router();
final container = Container();

// Setup a DI binding for UserService
container.bind('UserService', (_) => UserService());

// Replace the default DI container implementation
router.setContainer(container);

// Bare route handler example
router.get('/hello', (_) {
return Response.Ok('Hello World!');
});

// Plucking things out of the container example
router.get('/config', (Context context) {
print(context.make('@config.app.name'));
return Response.Ok(context.make('@config.app.name'));
});

// Path Params example
router.get('/:name', (Context context) {
return Response.Ok(context.request.pathParams['name']);
});

var app = App(router: router);
return app.start();
}
```