Files
core/src/app.controller.ts
2021-08-30 20:26:17 +08:00

29 lines
600 B
TypeScript

import { Controller, Get } from '@nestjs/common'
import PKG from '../package.json'
import { execSync } from 'child_process'
@Controller()
export class AppController {
@Get()
async appInfo(): Promise<IAppInfo> {
const cmd = `git log --pretty=oneline | head -n 1 | cut -d' ' -f1`
const hash = execSync(cmd, { encoding: 'utf-8' }).split('\n')[0]
return {
// hash: hash.stdout,
name: PKG.name,
version: PKG.version,
hash,
}
}
@Get('/ping')
ping(): 'pong' {
return 'pong'
}
}
interface IAppInfo {
version: string
hash: string
name: string
}