// User-facing script
// ignore_for_file: avoid_print

import "package:shared/generator.dart";
import "package:shared/graph.dart";
import "package:shared/server.dart" as handlers;

import "package:shelf_router/shelf_router.dart";
import "package:shelf/shelf_io.dart" as io;

Future<void> init() async {
  print("Initializing...");
  StopState.stops = await Generator.stops.parse();
  StopState.routes = await Generator.routes.parse();
}

void main() async {
  await init();
  final router = Router();
  router.get("/path", handlers.getPath);
  router.get("/stops", handlers.getStops);
  router.get("/routes", handlers.getRoutes);
  await io.serve(router.call, "localhost", 8001);
  print("Listening on localhost:8001");
}
