Skip to content

Quickstart

This page gets a minimal API running. For the full walkthrough, with a database, auth and tests, follow the framework guides.

Terminal window
dart create -t console my_api
cd my_api
dart pub add gisila
dart pub add --dev build_runner
lib/hello_controller.dart
import 'package:gisila/gisila.dart';
part 'hello_controller.g.dart';
@Controller('/hello')
class HelloController {
@Get('/')
@Public()
Future<Map<String, Object?>> hello() async => {'message': 'Hello, Gisila'};
}

Every file that declares a @Controller needs a part directive. The generator writes the routing glue into it.

Terminal window
dart run build_runner build
bin/my_api.dart
import 'package:gisila/gisila.dart';
import 'package:my_api/hello_controller.dart';
Future<void> main() async {
final app = GisilaApp(config: AppConfig());
app.registerController(attacher: HelloController().attachToApp);
await app.start(host: '0.0.0.0', port: 8080);
}
Terminal window
dart run bin/my_api.dart
curl http://localhost:8080/hello/