import HTML from '../public/index.html' ; import * as dog from 'dog' ; import type { Bindings } from './types' ; export { Lobby } from './lobby' ; export { Room } from './room' ; const worker = { async fetch ( req , env , ctx ) { let { pathname } = new URL ( req . url ) ; if ( ! /^(HEAD|GET)$/ . test ( req . method ) ) { return new Response ( 'Method not allowed' , { status : 405 } ) ; } if ( pathname === '/' ) { return new Response ( HTML , { headers : { 'Content-Type' : 'text/html;charset=utf-8' } } ) ; } let { searchParams } = new URL ( req . url ) ; let reqid = searchParams . get ( 'u' ) || 'anon' ; let gid = env . LOBBY . idFromName ( 'lobby-id' ) ; let room = await dog . identify ( gid , reqid , { parent : env . LOBBY , child : env . ROOM , } ) ; return room . fetch ( req ) ; } } ; export default worker ;