forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
61 lines (52 loc) · 1.64 KB
/
Copy pathmain.ts
File metadata and controls
61 lines (52 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
import { ValidationPipe } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
/**
* Bootstrap the NestJS application
*
* Features:
* - Port 3001 (configurable via PORT env var)
* - CORS enabled for frontend (localhost:3000)
* - Global validation pipe for DTOs
*/
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Get config service
const configService = app.get(ConfigService);
// Enable CORS for frontend
const corsOrigin = configService.get("app.corsOrigin");
app.enableCors({
origin: corsOrigin,
credentials: true,
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
allowedHeaders: [
"Content-Type",
"Authorization",
"X-Correlation-ID",
"X-Request-ID",
],
exposedHeaders: ["X-Correlation-ID"],
});
// Global validation pipe
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
transform: true,
forbidNonWhitelisted: true,
}),
);
// Get port from config
const port = configService.get("app.port");
await app.listen(port);
const stellarConfig = configService.get("stellar");
const network = stellarConfig?.networkPassphrase?.includes("Test")
? "testnet"
: "mainnet";
console.log(`🚀 Invoisio Backend running on: http://localhost:${port}`);
console.log(`📡 Health check: http://localhost:${port}/health`);
console.log(`🧾 Invoices API: http://localhost:${port}/invoices`);
console.log(`🌐 Stellar Network: ${network}`);
console.log(`\n✨ Ready for Stellar payments!`);
}
bootstrap();