diff --git a/back-end/dist/.env b/back-end/dist/.env index 75bdffd..8608def 100644 --- a/back-end/dist/.env +++ b/back-end/dist/.env @@ -12,7 +12,7 @@ APP_BASE_URL=https://bai-api.blv-oa.com # Database Configuration (Pocketbase) POCKETBASE_API_URL=https://bai-api.blv-oa.com/pb/ -POCKETBASE_AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJfcGJfdXNlcnNfYXV0aF8iLCJleHAiOjE3NzQzNjEzMzIsImlkIjoiazQ0aHI5MW90bnBydG10IiwicmVmcmVzaGFibGUiOmZhbHNlLCJ0eXBlIjoiYXV0aCJ9.qm4E6xYrDbEpAfdxZnHHRZs_EqiwHgDIIwSBz2k90Nk +POCKETBASE_AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJwYmNfMzE0MjYzNTgyMyIsImV4cCI6MTc3NDEwMTc4NiwiaWQiOiJmcnl2dG1qNnlwcHlmMXAiLCJyZWZyZXNoYWJsZSI6ZmFsc2UsInR5cGUiOiJhdXRoIn0.67DCKhqRQYF3ClPU_9mBgON_9ZDEy-NzqTeS50rGGZo # WeChat Configuration WECHAT_APPID=wx3bd7a7b19679da7a diff --git a/back-end/dist/build-info.json b/back-end/dist/build-info.json new file mode 100644 index 0000000..a5d6b0b --- /dev/null +++ b/back-end/dist/build-info.json @@ -0,0 +1,3 @@ +{ + "buildTime": "2026-03-20T14:36:26.964Z" +} \ No newline at end of file diff --git a/back-end/dist/spec/openapi.yaml b/back-end/dist/spec/openapi.yaml index c6647c3..55492fb 100644 --- a/back-end/dist/spec/openapi.yaml +++ b/back-end/dist/spec/openapi.yaml @@ -57,6 +57,11 @@ components: status: type: string example: success + build_time: + type: string + nullable: true + description: 最近一次构建时间;开发模式下若未执行构建则可能为空 + format: date-time WechatProfileRequest: type: object required: [users_name, users_phone_code, users_picture] @@ -197,7 +202,7 @@ paths: post: tags: [系统] summary: Test endpoint - description: Returns a hello world message + description: Returns a hello world message and build time responses: '200': description: Successful response diff --git a/back-end/dist/src/routes/apiRoutes.js b/back-end/dist/src/routes/apiRoutes.js index cf9e8b6..0514f4d 100644 --- a/back-end/dist/src/routes/apiRoutes.js +++ b/back-end/dist/src/routes/apiRoutes.js @@ -1,23 +1,29 @@ const express = require('express') const { success } = require('../utils/response') +const { getBuildTimestamp } = require('../utils/buildInfo') const wechatRoutes = require('./wechatRoutes') const router = express.Router() -router.post('/test-helloworld', (req, res) => { +function respondHelloWorld(req, res) { return success(res, '请求成功', { message: 'Hello, World!', timestamp: new Date().toISOString(), status: 'success', + build_time: getBuildTimestamp(), }) -}) +} -router.post('/health', (req, res) => { +function respondHealth(req, res) { return success(res, '服务运行正常', { status: 'healthy', timestamp: new Date().toISOString(), }) -}) +} + +router.post('/test-helloworld', respondHelloWorld) + +router.post('/health', respondHealth) router.use('/wechat', wechatRoutes) diff --git a/back-end/dist/src/utils/buildInfo.js b/back-end/dist/src/utils/buildInfo.js new file mode 100644 index 0000000..fecbbb0 --- /dev/null +++ b/back-end/dist/src/utils/buildInfo.js @@ -0,0 +1,30 @@ +const fs = require('fs') +const path = require('path') + +function getBuildInfoFilePath() { + return path.resolve(__dirname, '..', '..', 'build-info.json') +} + +function getBuildTimestamp() { + if (process.env.BUILD_TIME) { + return process.env.BUILD_TIME + } + + const filePath = getBuildInfoFilePath() + + if (!fs.existsSync(filePath)) { + return null + } + + try { + const content = fs.readFileSync(filePath, 'utf8') + const payload = JSON.parse(content) + return payload.buildTime || null + } catch { + return null + } +} + +module.exports = { + getBuildTimestamp, +} \ No newline at end of file