ServerApp.fromMeta constructor

ServerApp.fromMeta(
  1. MetaAppConfig app
)

Implementation

factory ServerApp.fromMeta(MetaAppConfig app) {
  final observers = ServerAppObservers();

  app.annotationsFor(
    onMatch: [
      OnMatch(
        classType: Observer,
        package: 'revali_router_core',
        convert: (object, annotation) {
          observers.mimics
              .add(ServerMimic.fromDartObject(object, annotation));
        },
      ),
      OnMatch(
        classType: Observers,
        package: 'revali_router_annotations',
        convert: (object, annotation) {
          observers.types.add(
            ServerTypeReference.fromElement(object, superType: Observer),
          );
        },
      ),
    ],
  );

  return ServerApp(
    className: app.className,
    isSecure: app.isSecure,
    importPath: ServerImports([app.importPath]),
    constructor: app.constructor,
    params: app.params.map(ServerParam.fromMeta).toList(),
    appAnnotation: ServerAppAnnotation.fromMeta(app.appAnnotation),
    globalRouteAnnotations: ServerRouteAnnotations.fromApp(app),
    observers: observers,
  );
}