返回 AiToEarn
app.controller.ts
根目录 / project / aitoearn-electron / server / src / app.controller.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-03-01 19:27:26
4 * @LastEditTime: 2025-03-19 15:34:32
5 * @LastEditors: nevin
6 * @Description: 应用
7 */
8 import { Controller, Get, Req } from '@nestjs/common';
9 import { AppService } from './app.service';
10 import { Public } from './auth/auth.guard';
11 import { Request as ExRequest } from 'express';
12
13 @Public()
14 @Controller()
15 export class AppController {
16 constructor(private readonly appService: AppService) {}
17
18 // 获取应用的下载链接
19 @Get('down')
20 getDownUrl() {
21 return this.appService.getDownUrl();
22 }
23
24 @Get()
25 getHello(): string {
26 return this.appService.getHello();
27 }
28
29 // 获取用户的IP地址
30 @Get('ip')
31 async getIp(@Req() request: ExRequest) {
32 return {
33 xForwardedFor: request.headers['x-forwarded-for'] || '',
34 ip: request.ip || '',
35 };
36 }
37 }
38
38 lines TYPESCRIPT