LogoRevali

Overview

What an AppConfig is, and every setting it controls

An app is a class annotated with @App() that extends AppConfig. It sets where the server listens (host, port, URL prefix), registers dependencies, and controls server behavior such as compression, health probes and shutdown. You override a getter or method to change one setting and leave the rest at their defaults.

routes/apps/main_app.dart
import 'package:revali_router/revali_router.dart';

@App()
final class MainApp extends AppConfig {
  const MainApp() : super(host: 'localhost', port: 8080);

  @override
  Future<void> configureDependencies(DI di) async {
    di.registerLazySingleton<UserRepository>(UserRepository.new);
  }
}

This server listens on http://localhost:8080/api. If there's no @App class under routes/, Revali uses the same defaults: localhost, port 8080, prefix api.

Reference#

Constructor parameters. See Create an App.

ParameterDefaultDescription
host required The address to bind. localhost is bound dual-stack on :: , so both IPv4 and IPv6 clients can connect. 0.0.0.0 binds every IPv4 interface.
port required The port to listen on. 0 picks a free port.
prefix 'api' The path prefix for every route. Write it without slashes. null or '' means no prefix.
workers 1 The number of isolates serving the port. See Worker Isolates .
backlog 0 The listen backlog. 0 uses the OS default.

Constructors:

ConstructorUse for
AppConfig(...)Plain HTTP
AppConfig.fromEnv(...) Host and port read from HOST and PORT . See Environment Variables .
AppConfig.secure(...) HTTPS with your own SecurityContext . See HTTPS .

Members you can override:

MemberDefaultPage
configureDependencies(DI di) registers nothing Configure Dependencies
defaultResponses plain-text 400/404/500 and CORS 403 Error Responses
compression gzip on, negotiated Compression
health /healthz and /readyz Health Probes
shutdownTimeout , drainDelay , handleShutdownSignals , onServerStopped() 15s, 0s, true, no-op Graceful Shutdown
createBroker() null (messaging off) Messaging
trustedProxy proxy headers ignored Create an App
onServerStarted(HttpServer server) prints Serving at …
runStartup(start) calls start() Wrap startup, for example in runZoned.

Related pages: Request Tracing (on by default, nothing to configure) and revali.yaml, which configures the CLI rather than the app.