feat(backoffice): standardize root response root json format
This commit is contained in:
parent
caede0cfc7
commit
fee83f52f6
2 changed files with 8 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get, Req } from '@nestjs/common';
|
||||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ export class AppController {
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOperation({ summary: 'API Status' })
|
@ApiOperation({ summary: 'API Status' })
|
||||||
getStatus() {
|
getStatus(@Req() req: any) {
|
||||||
return this.appService.getStatus();
|
return this.appService.getStatus(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@ import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppService {
|
export class AppService {
|
||||||
getStatus() {
|
getStatus(req: any) {
|
||||||
|
const ip = req.headers['x-forwarded-for'] || req.socket?.remoteAddress || req.ip;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: '🐴 GoHorseJobs Backoffice API is running!',
|
|
||||||
docs: '/docs',
|
docs: '/docs',
|
||||||
health: '/health',
|
health: '/health',
|
||||||
|
ip: ip ? ip.split(',')[0].trim() : 'unknown',
|
||||||
|
message: '🐴 GoHorseJobs API is running!',
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
env: process.env.NODE_ENV || 'development',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue