Skip to content
Snippets Groups Projects
Commit 4816d198 authored by Pierre Viara's avatar Pierre Viara
Browse files

feat(express-app): add environment configuration

parent c74f6111
Branches
No related tags found
No related merge requests found
PORT=
\ No newline at end of file
import { ExpressServer } from './express-server';
import * as dotenv from 'dotenv';
export class ExpressApplication {
private server = new ExpressServer('3000');
private server: ExpressServer;
constructor() {
this.configureEnvironment();
const port = this.getPort();
this.server = new ExpressServer(port);
}
bootstrap(): void {
this.server.bootstrap();
}
private configureEnvironment(): void {
dotenv.config({
path: '.env',
});
}
private getPort(): string {
const port = process.env.PORT;
if (!port) {
throw new Error('No port was found in env file.');
}
return port;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment