Serinus minimal application

From francescovallone/serinus · View interactive version

Serinus minimal application is an AI agent skill from the GitHub repository francescovallone/serinus. Use when the user is building a Serinus app with serinus.createMinimalApplication() and wants functional route registration, direct provider/module imports, or middleware configuration without defining full controller classes.

How to use this skill

Skill file

Serinus Minimal Application

Guidelines

Prefer This Pattern

import 'package:serinus/serinus.dart';

class AuthMiddleware extends Middleware {
  @override
  Future<void> use(ExecutionContext context, NextFunction next) async {
    if (context.switchToHttp().request.headers['authorization'] == null) {
      return next('Unauthorized');
    }
    return next();
  }
}

Future<void> main() async {
  final app = await serinus.createMinimalApplication(
    host: '0.0.0.0',
    port: 3000,
  );

  app.provide(Provider.forValue<String>('1.0.0', name: 'APP_VERSION'));

  app.get<String, dynamic>('/', (context) async {
    final version = context.use<String>('APP_VERSION');
    return 'Serinus $version';
  });

  app.post<Map<String, dynamic>, Map<String, dynamic>>('/echo', (context) async {
    return context.body;
  });

  app.useMiddleware(
    AuthMiddleware(),
    exclude: [RouteInfo('/', method: HttpMethod.get)],
  );

  await app.serve();
}

Avoid

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.