-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathapp.controller.ts
More file actions
74 lines (70 loc) · 2.04 KB
/
Copy pathapp.controller.ts
File metadata and controls
74 lines (70 loc) · 2.04 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
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Controller, Get, UseGuards } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import {
ApiOperation,
ApiResponse,
ApiSecurity,
ApiTags,
} from "@nestjs/swagger";
import { JwtAuthGuard } from "../../auth/auth.guard";
import { FrontendConfigResponseDto } from "./dto/frontend-config-response.dto";
/**
* Main application controller
*/
@ApiTags("App")
@Controller()
export class AppController {
constructor(private readonly configService: ConfigService) {}
/**
* Main endpoint providing service info
*/
@Get()
main() {
return {
service: "EUDIPLO",
documentation:
"https://openwallet-foundation.github.io/eudiplo/docs/latest/",
};
}
/**
* Returns the running service version. Requires authentication.
*/
@Get("version")
@UseGuards(JwtAuthGuard)
@ApiSecurity("oauth2")
@ApiOperation({ summary: "Get service version" })
@ApiResponse({ status: 200, description: "Service version info" })
getVersion() {
return {
version: process.env.VERSION ?? "main",
};
}
/**
* Returns runtime configuration for the frontend client.
*/
@Get("frontend-config")
@UseGuards(JwtAuthGuard)
@ApiSecurity("oauth2")
@ApiOperation({ summary: "Get frontend runtime configuration" })
@ApiResponse({
status: 200,
description: "Frontend configuration",
type: FrontendConfigResponseDto,
})
getFrontendConfig(): FrontendConfigResponseDto {
const grafanaUrl = this.configService.get<string>("GRAFANA_URL");
return {
grafana: {
url: grafanaUrl || undefined,
tempoUid: this.configService.get<string>(
"GRAFANA_DATASOURCE_TEMPO_UID",
"tempo",
),
lokiUid: this.configService.get<string>(
"GRAFANA_DATASOURCE_LOKI_UID",
"loki",
),
},
};
}
}