mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-07 09:55:43 -04:00

This should help to make clear why code is executed when the TokenAuthGuard is encountered by a request. Currently, one has to connect both files via the string 'token', which is a bit cryptic Signed-off-by: Philip Molares <philip.molares@udo.edu>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
import {
|
|
ApiForbiddenResponse,
|
|
ApiOkResponse,
|
|
ApiProduces,
|
|
ApiSecurity,
|
|
ApiTags,
|
|
ApiUnauthorizedResponse,
|
|
} from '@nestjs/swagger';
|
|
|
|
import { TokenAuthGuard } from '../../../auth/token.strategy';
|
|
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
|
import { ServerStatusDto } from '../../../monitoring/server-status.dto';
|
|
import {
|
|
forbiddenDescription,
|
|
unauthorizedDescription,
|
|
} from '../../utils/descriptions';
|
|
|
|
@ApiTags('monitoring')
|
|
@ApiSecurity('token')
|
|
@Controller('monitoring')
|
|
export class MonitoringController {
|
|
constructor(private monitoringService: MonitoringService) {}
|
|
|
|
@UseGuards(TokenAuthGuard)
|
|
@Get()
|
|
@ApiOkResponse({
|
|
description: 'The server info',
|
|
type: ServerStatusDto,
|
|
})
|
|
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
|
@ApiForbiddenResponse({ description: forbiddenDescription })
|
|
getStatus(): Promise<ServerStatusDto> {
|
|
// TODO: toServerStatusDto.
|
|
return this.monitoringService.getServerStatus();
|
|
}
|
|
|
|
@UseGuards(TokenAuthGuard)
|
|
@Get('prometheus')
|
|
@ApiOkResponse({
|
|
description: 'Prometheus compatible monitoring data',
|
|
})
|
|
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
|
@ApiForbiddenResponse({ description: forbiddenDescription })
|
|
@ApiProduces('text/plain')
|
|
getPrometheusStatus(): string {
|
|
return '';
|
|
}
|
|
}
|