58 lines
2.0 KiB
Dart
58 lines
2.0 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// ignore_for_file: type=lint, implicit_dynamic_list_literal
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:dart_frog/dart_frog.dart';
|
|
|
|
import '../main.dart' as entrypoint;
|
|
import '../routes/index.dart' as index;
|
|
import '../routes/create_room.dart' as create_room;
|
|
import '../routes/room/[roomCode]/join.dart' as room_$room_code_join;
|
|
import '../routes/auth/index.dart' as auth_index;
|
|
|
|
import '../routes/_middleware.dart' as middleware;
|
|
import '../routes/room/[roomCode]/_middleware.dart' as room_$room_code_middleware;
|
|
|
|
void main() async {
|
|
final address = InternetAddress.tryParse('') ?? InternetAddress.anyIPv6;
|
|
final port = int.tryParse(Platform.environment['PORT'] ?? '8080') ?? 8080;
|
|
hotReload(() => createServer(address, port));
|
|
}
|
|
|
|
Future<HttpServer> createServer(InternetAddress address, int port) {
|
|
final handler = Cascade().add(buildRootHandler()).handler;
|
|
return entrypoint.run(handler, address, port);
|
|
}
|
|
|
|
Handler buildRootHandler() {
|
|
final pipeline = const Pipeline().addMiddleware(middleware.middleware);
|
|
final router = Router()
|
|
..mount('/auth', (context) => buildAuthHandler()(context))
|
|
..mount('/room/<roomCode>', (context,roomCode,) => buildRoom$roomCodeHandler(roomCode,)(context))
|
|
..mount('/', (context) => buildHandler()(context));
|
|
return pipeline.addHandler(router);
|
|
}
|
|
|
|
Handler buildAuthHandler() {
|
|
final pipeline = const Pipeline();
|
|
final router = Router()
|
|
..all('/', (context) => auth_index.onRequest(context,));
|
|
return pipeline.addHandler(router);
|
|
}
|
|
|
|
Handler buildRoom$roomCodeHandler(String roomCode,) {
|
|
final pipeline = const Pipeline().addMiddleware(room_$room_code_middleware.middleware);
|
|
final router = Router()
|
|
..all('/join', (context) => room_$room_code_join.onRequest(context,roomCode,));
|
|
return pipeline.addHandler(router);
|
|
}
|
|
|
|
Handler buildHandler() {
|
|
final pipeline = const Pipeline();
|
|
final router = Router()
|
|
..all('/', (context) => index.onRequest(context,))..all('/create_room', (context) => create_room.onRequest(context,));
|
|
return pipeline.addHandler(router);
|
|
}
|
|
|