@@ -24,15 +24,12 @@ struct Config {
2424 env : String ,
2525 secret_key : String ,
2626 database_url : String ,
27- bind_address : String ,
27+ port : String ,
2828}
2929
3030impl Config {
3131 fn from_env ( ) -> Self {
32- // Currently, we need the DATABASE_URL to be loaded in through the .env.
33- // In the future, if we use any other configuration (say Github Secrets), we
34- // can allow dotenv() to err.
35- dotenv:: dotenv ( ) . expect ( ".ENV file must be set up." ) ;
32+ let _ = dotenv:: dotenv ( ) ;
3633 Self {
3734 // RUST_ENV is used to check if it's in production to avoid unnecessary logging and exposing the
3835 // graphiql interface. Make sure to set it to "production" before deployment.
@@ -41,8 +38,8 @@ impl Config {
4138 secret_key : std:: env:: var ( "ROOT_SECRET" ) . expect ( "ROOT_SECRET must be set." ) ,
4239 // DATABASE_URL provides the connection string for the PostgreSQL database.
4340 database_url : std:: env:: var ( "DATABASE_URL" ) . expect ( "DATABASE_URL must be set." ) ,
44- // BIND_ADDRESS is used to determine the IP address for the server's socket to bind to.
45- bind_address : std:: env:: var ( "BIND_ADDRESS " ) . expect ( "BIND_ADDRESS must be set." ) ,
41+ // ROOT_PORT is used to determine the port that root binds to
42+ port : std:: env:: var ( "ROOT_PORT " ) . expect ( "ROOT_PORT must be set." ) ,
4643 }
4744 }
4845}
@@ -63,7 +60,7 @@ async fn main() {
6360 let router = setup_router ( schema, cors, config. env == "development" ) ;
6461
6562 info ! ( "Starting Root..." ) ;
66- let listener = tokio:: net:: TcpListener :: bind ( config. bind_address )
63+ let listener = tokio:: net:: TcpListener :: bind ( format ! ( "0.0.0.0:{}" , config. port ) )
6764 . await
6865 . unwrap ( ) ;
6966 axum:: serve ( listener, router) . await . unwrap ( ) ;
0 commit comments