import dotenv from "dotenv" ; import fs from "fs" ; import deliver from "./deliver" ; import front from "./front" ; dotenv . config ( ) ; const { APP_SCHEME : scheme = "http" , APP_DOMAIN : domain = "chess.test" , APP_ADMIN_URL : adminUrl = "" , APP_ADMIN_EMAIL : adminEmail = "" , APP_KEY_FILE : keyFile = "signing-key" , APP_HMAC_SECRET : hmacSecret = "INSECURE" , NODE_ENV : env = "development" , PORT : port = "5080" , } = process . env ; const privateKeyPem = fs . readFileSync ( keyFile , "utf-8" ) ; const publicKeyPem = fs . readFileSync ( `${ keyFile }.pub` , "utf-8" ) ; const config = { env , scheme , domain , adminUrl , adminEmail , publicKeyPem , privateKeyPem , hmacSecret , } ; front ( config ) . then ( ( instance ) => { const server = instance . listen ( parseInt ( port , 10 ) , ( ) => { const addr = server . address ( ) ; const desc = typeof addr === "string" ? addr : addr ? addr . port : "<unknown>" ; console . log ( `Listening on port ${ desc }` ) ; } ) ; } ) ; deliver ( config ) ;