feat(app): add handling for app port from environment variable
This commit imports the `process` module from `node:process` and changes the app to listen on a port specified by an environment variable (APP_PORT). It also adds an error handler to stop the server and log the error message if the server fails to start. Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
parent
c024770b4a
commit
4ff1aa852d
10
src/app.ts
10
src/app.ts
@ -6,6 +6,7 @@ import helmet from "helmet";
|
||||
import AuthRouter from "@routes/auth/authRouter";
|
||||
import CatalogRouter from "@routes/catalog/catalogRouter";
|
||||
import RentRouter from "@routes/rent/rentRouter";
|
||||
import * as process from "node:process";
|
||||
|
||||
|
||||
const logger = new Logger({ name: "App" });
|
||||
@ -43,5 +44,10 @@ try {
|
||||
throw null;
|
||||
}
|
||||
|
||||
//app.listen(3333)
|
||||
logger.info('Server is running !')
|
||||
try {
|
||||
app.listen(process.env["APP_PORT"])
|
||||
logger.info('Server is running !')
|
||||
} catch (error) {
|
||||
logger.error(`Server failed to start: ${error}`);
|
||||
process.exit(1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user