Skip to content

Instantly share code, notes, and snippets.

@fieldju
Created May 29, 2020 20:44
Show Gist options
  • Save fieldju/981935d5a57051a09978ce717c00b5a8 to your computer and use it in GitHub Desktop.
Save fieldju/981935d5a57051a09978ce717c00b5a8 to your computer and use it in GitHub Desktop.
import { Controller, Get } from '@nestjs/common';
import HealthCheckResponse from '../domain/HealthCheckResponse';
import STS from 'aws-sdk/clients/sts';
import { ArcUnhealthyException } from '../error/ArchUnhealthyException';
@Controller('/health')
export default class HealthCheckController {
private readonly secureTokenService: STS;
constructor(secureTokenService: STS) {
this.secureTokenService = secureTokenService;
}
@Get()
async getHealth(): Promise<HealthCheckResponse> {
try {
const getCallerIdentityResponse = await this.secureTokenService.getCallerIdentity().promise()
return {
status: 'healthy',
arn: getCallerIdentityResponse.Arn
}
} catch (e) {
throw new ArcUnhealthyException({
status: 'unhealthy',
msg: e
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment