refactor: 完成静态网站转换,移除所有 CMS 和动态功能

- 删除数据库相关代码 (src/db/)
- 删除 API 路由 (src/app/api/)
- 删除认证相关代码 (src/lib/auth/, src/providers/)
- 删除监控和安全中间件 (src/lib/security/, src/lib/monitoring/)
- 删除 hooks (use-news, use-products, use-services)
- 更新组件为静态数据源
- 添加 nginx 静态配置和部署脚本
- 添加 static-link 组件
This commit is contained in:
张翔 committed 2026-04-21 07:53:56 +08:00
1 parent cd1d6aa28a
commit 6403489954
197 files changed
+654 -24762

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
import { NextResponse } from 'next/server';
import { db } from '@/db';
import { siteConfig } from '@/db/schema';
export async function GET() {
try {
const allConfigs = await db.select().from(siteConfig);
const configMap = allConfigs.reduce((acc, config) => {
acc[config.key] = config.value;
return acc;
}, {} as Record<string, any>);
return NextResponse.json({
success: true,
data: configMap
});
} catch (error) {
console.error('获取配置失败:', error);
return NextResponse.json(
{ success: false, error: '获取配置失败' },
{ status: 500 }
);
}
}
-132
View File
@@ -1,132 +0,0 @@
import { NextResponse } from 'next/server';
import { monitor } from '@/lib/monitoring';
/**
* @openapi
* /api/v1/health:
* get:
* tags:
* - Health
* summary: 健康检查 (v1)
* description: 检查应用程序的健康状态,包括数据库连接、内存使用等
* operationId: getHealthV1
* responses:
* 200:
* description: 服务健康
* content:
* application/json:
* schema:
* type: object
* properties:
* status:
* type: string
* example: ok
* version:
* type: string
* description: API版本
* example: v1
* timestamp:
* type: string
* format: date-time
* uptime:
* type: number
* description: 服务运行时间(秒)
* memory:
* type: object
* properties:
* heapUsed:
* type: integer
* description: 已使用堆内存(MB)
* heapTotal:
* type: integer
* description: 总堆内存(MB)
* rss:
* type: integer
* description: 常驻内存集大小(MB)
* checks:
* type: object
* properties:
* database:
* type: object
* properties:
* status:
* type: string
* latency:
* type: integer
* memory:
* type: object
* properties:
* status:
* type: string
* usage:
* type: integer
* 503:
* description: 服务不可用
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
export async function GET() {
const startTime = Date.now();
try {
const health = {
status: 'ok',
version: 'v1',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
memory: {
heapUsed: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
heapTotal: Math.round(process.memoryUsage().heapTotal / 1024 / 1024),
rss: Math.round(process.memoryUsage().rss / 1024 / 1024),
},
checks: {
database: await checkDatabase(),
memory: checkMemory(),
},
};
const responseTime = Date.now() - startTime;
monitor.recordMetric('response_time', responseTime);
return NextResponse.json(health, { status: 200 });
} catch (error) {
return NextResponse.json(
{
status: 'error',
version: 'v1',
timestamp: new Date().toISOString(),
error: error instanceof Error ? error.message : 'Unknown error',
},
{ status: 503 }
);
}
}
async function checkDatabase(): Promise<{ status: string; latency?: number }> {
try {
const start = Date.now();
return {
status: 'ok',
latency: Date.now() - start,
};
} catch (error) {
return {
status: 'error',
};
}
}
function checkMemory(): { status: string; usage: number } {
const memUsage = process.memoryUsage();
const heapUsedMB = memUsage.heapUsed / 1024 / 1024;
const heapTotalMB = memUsage.heapTotal / 1024 / 1024;
const usagePercent = (heapUsedMB / heapTotalMB) * 100;
return {
status: usagePercent > 90 ? 'warning' : 'ok',
usage: Math.round(usagePercent),
};
}