Skip to content

Commit 5c5ee5e

Browse files
committed
✨feat(main): implementa código de inicialização da API | Parte 27
- Carrega variáveis de ambiente - Registra etapas da inicialização - Cria o servidor web HTTP
1 parent 466fdba commit 5c5ee5e

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/main/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import dotenv from 'dotenv';
2+
import { createHTTPServer } from './presentation/http/server';
3+
4+
async function bootstrap() {
5+
6+
//Carrega variáveis de ambiente do arquivo .env
7+
dotenv.config();
8+
9+
const api_name = process.env.API_NAME;
10+
const host_name = process.env.HOST_NAME;
11+
const port = process.env.PORT;
12+
13+
console.log(`[${api_name}] 🚀 Inicializando a API....`);
14+
15+
const httpServer = await createHTTPServer();
16+
17+
httpServer.listen({ port: port }, async () => {
18+
console.log(`[${api_name}] ✅ Servidor HTTP pronto e ouvindo em http://${host_name}:${port}`);
19+
});
20+
21+
}
22+
23+
bootstrap()
24+
.catch((error) => {
25+
console.error(error);
26+
});

0 commit comments

Comments
 (0)