Browse Source

feat:新加了一个后端,代码换成js了

0235645 1 day ago
parent
commit
7e1426bd50
37 changed files with 2717 additions and 347 deletions
  1. 1 1
      back-end/.env
  2. 29 5
      back-end/src/app.ts
  3. 62 0
      back-end/src/controllers/debug.controller.ts
  4. 46 0
      back-end/src/controllers/design.controller.ts
  5. 107 0
      back-end/src/database/designService.ts
  6. 91 40
      back-end/src/database/index.ts
  7. 18 0
      back-end/src/database/init.sql
  8. 0 44
      back-end/src/database/users.repository.ts
  9. 8 24
      back-end/src/main.ts
  10. 23 0
      back-end/src/routes/color-stats.route.ts
  11. 12 0
      back-end/src/routes/debug.route.ts
  12. 12 0
      back-end/src/routes/design.route.ts
  13. 6 3
      back-end/src/routes/index.ts
  14. 107 0
      back-end/src/services/design.service.ts
  15. 4 3
      back-end/tsconfig.json
  16. 4 0
      cloth-design/angular.json
  17. 10 0
      cloth-design/package-lock.json
  18. 1 0
      cloth-design/package.json
  19. 17 19
      cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.html
  20. 69 56
      cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.scss
  21. 123 152
      cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.ts
  22. 55 0
      cloth-design/src/app/services/color-mapping.service.ts
  23. 38 0
      cloth-design/src/app/services/design-api.service.ts
  24. 5 0
      cloth-design/src/environments/environment.prod.ts
  25. 5 0
      cloth-design/src/environments/environment.ts
  26. 6 0
      end-b/.env
  27. 42 0
      end-b/.gitignore
  28. 1392 0
      end-b/package-lock.json
  29. 18 0
      end-b/package.json
  30. 44 0
      end-b/src/app.js
  31. 12 0
      end-b/src/config.js
  32. 44 0
      end-b/src/controllers/design.controller.js
  33. 177 0
      end-b/src/database.js
  34. 10 0
      end-b/src/index.js
  35. 18 0
      end-b/src/routes/design.route.js
  36. 26 0
      end-b/src/routes/index.js
  37. 75 0
      end-b/src/services/design.service.js

+ 1 - 1
back-end/.env

@@ -1,7 +1,7 @@
 # PostgreSQL 配置
 DB_USER=user_HZJ7TG
 DB_HOST=110.42.109.119
-DB_NAME=cloth
+DB_NAME=design_usage
 DB_PASSWORD=password_kJJM8P
 DB_PORT=5455
 

+ 29 - 5
back-end/src/app.ts

@@ -1,22 +1,46 @@
-import express, { Application } from 'express';
+import express, { Application, Request, Response, NextFunction } from 'express';
 import bodyParser from 'body-parser';
 import cors from 'cors';
 import router from './routes/index';
 import { config } from './config/index';
+import { initializeDatabase } from './database';
 
 const app: Application = express();
 
 // 中间件
 app.use(cors());
 app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: true }));
+
+// 数据库初始化中间件
+app.use(async (req: Request, res: Response, next: NextFunction) => {
+  try {
+    await initializeDatabase();
+    next();
+  } catch (error) {
+    console.error('❌ 数据库初始化失败:', error);
+    res.status(500).json({ error: '数据库初始化失败' });
+  }
+});
 
 // 路由
 app.use('/api', router);
 
-// 全局错误处理
-app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
-  console.error(err.stack);
-  res.status(500).json({ error: 'Internal Server Error' });
+// 健康检查端点
+app.get('/health', (req: Request, res: Response) => {
+  res.status(200).json({ 
+    status: 'UP', 
+    timestamp: new Date().toISOString() 
+  });
+});
+
+// 404 处理
+app.use((req: Request, res: Response) => {
+  res.status(404).json({ 
+    error: '端点未找到' 
+  });
 });
 
+
+
 export default app;

+ 62 - 0
back-end/src/controllers/debug.controller.ts

@@ -0,0 +1,62 @@
+import { Request, Response } from 'express';
+import { designService, COLOR_MAPPING } from '../services/design.service';
+import { query, initializeDatabase } from '../database';
+
+export const debugController = {
+  initDb: async (req: Request, res: Response) => {
+    try {
+      await initializeDatabase();
+      res.json({ success: true, message: '数据库已初始化' });
+    } catch (error) {
+      console.error('数据库初始化错误:', error);
+      res.status(500).json({ success: false, error: '初始化失败' });
+    }
+  },
+
+  checkDb: async (req: Request, res: Response) => {
+    try {
+      const tableExists = await query(`
+        SELECT EXISTS (
+          SELECT 1 FROM information_schema.tables 
+          WHERE table_name = 'design_usage'
+        )
+      `);
+      res.json({ exists: tableExists.rows[0].exists });
+    } catch (error) {
+      console.error('数据库检查错误:', error);
+      res.status(500).json({ success: false, error: '检查失败' });
+    }
+  },
+
+  generateTestData: async (req: Request, res: Response) => {
+    try {
+      const count = parseInt(req.query.count as string) || 100;
+      const colorCodes = COLOR_MAPPING.map(c => c.code);
+      
+      for (let i = 0; i < count; i++) {
+        const design = {
+          part1: colorCodes[Math.floor(Math.random() * colorCodes.length)],
+          part2: colorCodes[Math.floor(Math.random() * colorCodes.length)],
+          part3: colorCodes[Math.floor(Math.random() * colorCodes.length)],
+          part4: colorCodes[Math.floor(Math.random() * colorCodes.length)],
+        };
+        await designService.saveDesign(design);
+      }
+      
+      res.json({ success: true, message: `已生成 ${count} 条记录` });
+    } catch (error) {
+      console.error('生成测试数据错误:', error);
+      res.status(500).json({ success: false, error: '生成失败' });
+    }
+  },
+
+  resetStatistics: async (req: Request, res: Response) => {
+    try {
+      await query('TRUNCATE TABLE design_usage');
+      res.json({ success: true, message: '统计数据已重置' });
+    } catch (error) {
+      console.error('重置统计数据错误:', error);
+      res.status(500).json({ success: false, error: '重置失败' });
+    }
+  }
+};

+ 46 - 0
back-end/src/controllers/design.controller.ts

@@ -0,0 +1,46 @@
+import { Request, Response } from 'express';
+import { designService } from '../services/design.service';
+
+class DesignController {
+  // 获取颜色统计数据
+  async getColorStatistics(req: Request, res: Response) {
+    try {
+      const stats = await designService.getAllColorsStatistics();
+      res.json({
+        success: true,
+        data: stats
+      });
+    } catch (error) {
+      const err = error as Error;
+      console.error('获取颜色统计失败:', err.message);
+      res.status(500).json({ 
+        success: false,
+        error: '获取颜色统计数据失败'
+      });
+    }
+  }
+  
+  // 记录设计使用
+  async recordDesignUsage(req: Request, res: Response) {
+    try {
+      const design = {
+        part1: req.body.part1,
+        part2: req.body.part2,
+        part3: req.body.part3,
+        part4: req.body.part4,
+      };
+      
+      await designService.saveDesign(design);
+      res.json({ success: true });
+    } catch (error) {
+      const err = error as Error;
+      console.error('记录设计使用失败:', err.message);
+      res.status(400).json({ 
+        success: false,
+        error: err.message
+      });
+    }
+  }
+}
+
+export const designController = new DesignController();

+ 107 - 0
back-end/src/database/designService.ts

@@ -0,0 +1,107 @@
+import {
+  getAllDesignUsage,
+  recordDesignUsage
+} from '../database';
+
+// 颜色映射配置
+const COLOR_MAPPING = [
+  { code: '00', hex: '#3498db', name: '天空蓝' },
+  { code: '01', hex: '#e74c3c', name: '热情红' },
+  { code: '02', hex: '#2ecc71', name: '森林绿' },
+  { code: '03', hex: '#f1c40f', name: '阳光黄' },
+  { code: '04', hex: '#9b59b6', name: '紫罗兰' },
+  { code: '05', hex: '#1abc9c', name: '碧波绿' },
+  { code: '06', hex: '#e67e22', name: '落日橙' },
+  { code: '07', hex: '#2c3e50', name: '午夜蓝' },
+  { code: '08', hex: '#ecf0f1', name: '云朵白' },
+  { code: '09', hex: '#e84393', name: '玫瑰粉' },
+  { code: '0A', hex: '#ffeaa7', name: '奶油黄' },
+  { code: '0B', hex: '#ffb6c1', name: '樱花粉' },
+  { code: '0C', hex: '#98ff98', name: '薄荷绿' },
+  { code: '0D', hex: '#b399d4', name: '薰衣草' },
+  { code: '0E', hex: '#ff7f50', name: '珊瑚橙' },
+  { code: '0F', hex: '#89cff0', name: '海洋蓝' },
+];
+
+class DesignService {
+  // 保存设计选择
+  async saveDesign(design: {
+    part1: string;
+    part2: string;
+    part3: string;
+    part4: string;
+  }) {
+    // 验证颜色代码
+    const isValid = Object.values(design).every(
+      color => /^[0-9A-Fa-f]{2}$/.test(color)
+    );
+    
+    if (!isValid) {
+      throw new Error('无效的颜色代码。必须是两位十六进制值 (00-FF)');
+    }
+    
+    // 转换为大写确保一致性
+    const normalizedDesign = {
+      part1: design.part1.toUpperCase(),
+      part2: design.part2.toUpperCase(),
+      part3: design.part3.toUpperCase(),
+      part4: design.part4.toUpperCase(),
+    };
+    
+    await recordDesignUsage(normalizedDesign);
+  }
+
+  // 获取所有颜色统计数据
+  async getAllColorsStatistics() {
+    try {
+      const allUsage = await getAllDesignUsage();
+      
+      // 按部件分组
+      const byPart: Record<number, Array<{
+        code: string;
+        hex: string;
+        name: string;
+        usageCount: number;
+      }>> = {};
+      
+      for (const item of allUsage) {
+        if (!byPart[item.partId]) {
+          byPart[item.partId] = [];
+        }
+        
+        const colorInfo = this.getColorInfo(item.colorCode);
+        byPart[item.partId].push({
+          code: item.colorCode,
+          hex: colorInfo.hex,
+          name: colorInfo.name,
+          usageCount: item.usageCount
+        });
+      }
+      
+      // 对每个部件的颜色按使用次数排序
+      for (const partId in byPart) {
+        byPart[partId].sort((a, b) => b.usageCount - a.usageCount);
+      }
+      
+      return {
+        byPart,
+        timestamp: new Date().toISOString()
+      };
+    } catch (error) {
+      const err = error as Error;
+      throw new Error(`获取颜色统计数据失败: ${err.message}`);
+    }
+  }
+  
+  // 根据颜色代码获取颜色信息
+  getColorInfo(code: string) {
+    const foundColor = COLOR_MAPPING.find(c => c.code === code);
+    return foundColor || {
+      code,
+      hex: '#CCCCCC',
+      name: '未知色'
+    };
+  }
+}
+
+export const designService = new DesignService();

+ 91 - 40
back-end/src/database/index.ts

@@ -1,7 +1,8 @@
 import { Pool } from 'pg';
 import { config } from '../config';
+import fs from 'fs';
+import path from 'path';
 
-// 创建连接池
 const pool = new Pool({
   user: config.db.user,
   host: config.db.host,
@@ -10,7 +11,7 @@ const pool = new Pool({
   port: config.db.port,
 });
 
-// 导出查询函数
+// 查询函数
 export const query = async (text: string, params?: any[]) => {
   try {
     return await pool.query(text, params);
@@ -20,61 +21,111 @@ export const query = async (text: string, params?: any[]) => {
   }
 };
 
-// 测试数据库连接
-export const testDbConnection = async () => {
-  try {
-    const result = await query('SELECT NOW()');
-    return { time: result.rows[0].now };
-  } catch (error) {
-    const err = error as Error;
-    throw new Error(`Database connection failed: ${err.message}`);
-  }
-};
-
-// 添加通用错误处理
-pool.on('error', (err: Error) => {
-  console.error('Unexpected database error', err);
-});
-
-// 初始化数据库 - 检查并创建 cloth 表
+// 初始化数据库
 export const initializeDatabase = async () => {
   try {
-    // 检查 cloth 表是否存在
+    // 检查 design_usage 表是否存在
     const tableExists = await query(
       `SELECT EXISTS (
         SELECT FROM information_schema.tables 
         WHERE table_schema = 'public' 
-        AND table_name = 'cloth'
+        AND table_name = 'design_usage'
       )`
     );
     
     if (!tableExists.rows[0].exists) {
-      console.log('Creating cloth table...');
-      await query(`
-        CREATE TABLE cloth (
-          id SERIAL PRIMARY KEY,
-          name VARCHAR(100) NOT NULL,
-          description TEXT,
-          price DECIMAL(10,2) NOT NULL,
-          size VARCHAR(10)[],
-          colors VARCHAR(20)[],
-          material VARCHAR(50),
-          created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
-          updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
-        )
-      `);
-      console.log('Cloth table created successfully');
-    } else {
-      console.log('Cloth table already exists');
+      console.log('🆕 创建 design_usage 表...');
+      
+      // 从文件读取 SQL 脚本
+      const sqlPath = path.join(__dirname, 'init.sql');
+      const sqlScript = fs.readFileSync(sqlPath, 'utf8');
+      
+      // 执行初始化脚本
+      await query(sqlScript);
+      console.log('🎉 Design_usage 表创建并初始化成功');
     }
     
     // 测试数据库连接
     const dbStatus = await testDbConnection();
-    console.log('Database connection successful:', dbStatus);
+    console.log('📡 数据库连接成功:', dbStatus);
     
+    return true;
   } catch (error) {
     const err = error as Error;
-    console.error('Database initialization failed:', err.message);
+    console.error('🔥 数据库初始化失败:', err.message);
     throw err;
   }
+};
+
+// 测试数据库连接
+export const testDbConnection = async () => {
+  try {
+    const result = await query('SELECT NOW()');
+    return { time: result.rows[0].now };
+  } catch (error) {
+    const err = error as Error;
+    throw new Error(`Database connection failed: ${err.message}`);
+  }
+};
+
+// 获取所有设计使用情况
+export const getAllDesignUsage = async () => {
+  try {
+    const result = await query(`
+      SELECT part_id, color_code, usage_count
+      FROM design_usage
+      ORDER BY part_id, usage_count DESC
+    `);
+    
+    return result.rows.map(row => ({
+      partId: row.part_id,
+      colorCode: row.color_code,
+      usageCount: row.usage_count
+    }));
+  } catch (error) {
+    const err = error as Error;
+    throw new Error(`获取设计使用数据失败: ${err.message}`);
+  }
+};
+
+// 记录设计使用情况
+export const recordDesignUsage = async (design: {
+  part1: string;
+  part2: string;
+  part3: string;
+  part4: string;
+}) => {
+  try {
+    const client = await pool.connect();
+    
+    try {
+      await client.query('BEGIN');
+      
+      const colors = [
+        design.part1, design.part2, 
+        design.part3, design.part4
+      ];
+      
+      for (let partId = 1; partId <= 4; partId++) {
+        const colorCode = colors[partId - 1];
+        await client.query(
+          `INSERT INTO design_usage (part_id, color_code, usage_count)
+           VALUES ($1, $2, 1)
+           ON CONFLICT (part_id, color_code)
+           DO UPDATE SET usage_count = design_usage.usage_count + 1`,
+          [partId, colorCode]
+        );
+      }
+      
+      await client.query('COMMIT');
+    } catch (error) {
+      await client.query('ROLLBACK');
+      throw error;
+    } finally {
+      client.release();
+    }
+  } catch (error) {
+    const err = error as Error;
+    throw new Error(`记录设计使用失败: ${err.message}`);
+  }
 };

+ 18 - 0
back-end/src/database/init.sql

@@ -0,0 +1,18 @@
+-- 创建设计使用表
+CREATE TABLE IF NOT EXISTS design_usage (
+  id SERIAL PRIMARY KEY,
+  part_id INTEGER NOT NULL CHECK (part_id BETWEEN 1 AND 4),
+  color_code CHAR(2) NOT NULL CHECK (color_code ~ '^[0-9A-F]{2}$'),
+  usage_count INTEGER NOT NULL DEFAULT 0,
+  UNIQUE (part_id, color_code)
+);
+
+-- 插入初始数据
+INSERT INTO design_usage (part_id, color_code, usage_count)
+VALUES
+  (1, '00', 150), (1, '01', 120), (1, '02', 95), (1, '03', 80),
+  (2, '04', 65), (2, '05', 140), (2, '06', 60), (2, '07', 85),
+  (3, '08', 110), (3, '09', 130), (3, '0A', 45), (3, '0B', 100),
+  (4, '0C', 55), (4, '0D', 75), (4, '0E', 125), (4, '0F', 90)
+ON CONFLICT (part_id, color_code) DO UPDATE
+SET usage_count = EXCLUDED.usage_count;

+ 0 - 44
back-end/src/database/users.repository.ts

@@ -1,44 +0,0 @@
-import { query } from '.';
-import { User } from '../types/user.type';
-
-// 创建用户表
-export const createUsersTable = async () => {
-  try {
-    await query(`
-      CREATE TABLE IF NOT EXISTS users (
-        id SERIAL PRIMARY KEY,
-        name VARCHAR(50) NOT NULL,
-        email VARCHAR(100) UNIQUE NOT NULL
-      )
-    `);
-    return { message: 'Users table created' };
-  } catch (error) {
-    const err = error as Error;
-    throw new Error(`Failed to create table: ${err.message}`);
-  }
-};
-
-// 获取所有用户
-export const getAllUsers = async (): Promise<User[]> => {
-  try {
-    const result = await query('SELECT * FROM users');
-    return result.rows;
-  } catch (error) {
-    const err = error as Error;
-    throw new Error(`Failed to get users: ${err.message}`);
-  }
-};
-
-// 创建用户
-export const createUser = async (user: Omit<User, 'id'>): Promise<User> => {
-  try {
-    const result = await query(
-      'INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *',
-      [user.name, user.email]
-    );
-    return result.rows[0];
-  } catch (error) {
-    const err = error as Error;
-    throw new Error(`Failed to create user: ${err.message}`);
-  }
-};

+ 8 - 24
back-end/src/main.ts

@@ -1,28 +1,12 @@
-import { createServer } from 'http';
 import app from './app';
-import { config, validateEnv } from './config';
-import { initializeDatabase } from './database';
+import { config } from './config';
 
 const port = config.port || 3000;
-const server = createServer(app);
 
-async function startServer() {
-  try {
-    // 验证环境变量
-    validateEnv();
-    
-    // 初始化数据库
-    await initializeDatabase();
-    
-    // 启动服务器
-    server.listen(port, () => {
-      console.log(`Server running on http://localhost:${port}`);
-    });
-    
-  } catch (error) {
-    console.error('Failed to start server:', error);
-    process.exit(1);
-  }
-}
-
-startServer();
+// 启动服务器
+app.listen(port, () => {
+  console.log(`🚀 服务器运行在 http://localhost:${port}`);
+  console.log(`📡 API 端点: http://localhost:${port}/api`);
+  console.log(`🩺 健康检查: http://localhost:${port}/health`);
+  console.log(`🎨 颜色统计: http://localhost:${port}/api/designs/color-statistics`);
+});

+ 23 - 0
back-end/src/routes/color-stats.route.ts

@@ -0,0 +1,23 @@
+import { Router } from 'express';
+import { designService } from '../services/design.service';
+
+const router = Router();
+
+// 直接在这里实现端点逻辑
+router.get('/color-statistics', async (req, res) => {
+  try {
+    const stats = await designService.getAllColorsStatistics();
+    res.json({
+      success: true,
+      data: stats
+    });
+  } catch (error) {
+    console.error('获取颜色统计失败:', error);
+    res.status(500).json({
+      success: false,
+      error: '获取颜色统计数据失败'
+    });
+  }
+});
+
+export default router;

+ 12 - 0
back-end/src/routes/debug.route.ts

@@ -0,0 +1,12 @@
+import { Router } from 'express';
+import { debugController } from '../controllers/debug.controller';
+
+const router = Router();
+
+// 最简单的路由定义
+router.get('/init-db', debugController.initDb);
+router.get('/check-db', debugController.checkDb);
+router.post('/generate-test-data', debugController.generateTestData);
+router.post('/reset-statistics', debugController.resetStatistics);
+
+export default router;

+ 12 - 0
back-end/src/routes/design.route.ts

@@ -0,0 +1,12 @@
+import { Router } from 'express';
+import { designController } from '../controllers/design.controller';
+
+const router = Router();
+
+// 颜色统计端点
+router.get('/color-statistics', designController.getColorStatistics);
+
+// 记录设计使用端点
+router.post('/record', designController.recordDesignUsage);
+
+export default router;

+ 6 - 3
back-end/src/routes/index.ts

@@ -1,10 +1,13 @@
 import { Router } from 'express';
 import healthRouter from './health.route';
-import clothRouter from './cloth.route'; 
+import clothRouter from './cloth.route';
+import designRouter from './design.route'; // 设计路由
 
 const router = Router();
 
 router.use('/health', healthRouter);
-router.use('/clothes', clothRouter); 
-
+router.use('/clothes', clothRouter);
+router.use('/designs', designRouter); // 添加设计路由端点
+import colorStatsRouter from './color-stats.route'; 
+router.use('/designs', colorStatsRouter);
 export default router;

+ 107 - 0
back-end/src/services/design.service.ts

@@ -0,0 +1,107 @@
+import {
+  getAllDesignUsage,
+  recordDesignUsage
+} from '../database';
+
+// 颜色映射配置
+const COLOR_MAPPING = [
+  { code: '00', hex: '#3498db', name: '天空蓝' },
+  { code: '01', hex: '#e74c3c', name: '热情红' },
+  { code: '02', hex: '#2ecc71', name: '森林绿' },
+  { code: '03', hex: '#f1c40f', name: '阳光黄' },
+  { code: '04', hex: '#9b59b6', name: '紫罗兰' },
+  { code: '05', hex: '#1abc9c', name: '碧波绿' },
+  { code: '06', hex: '#e67e22', name: '落日橙' },
+  { code: '07', hex: '#2c3e50', name: '午夜蓝' },
+  { code: '08', hex: '#ecf0f1', name: '云朵白' },
+  { code: '09', hex: '#e84393', name: '玫瑰粉' },
+  { code: '0A', hex: '#ffeaa7', name: '奶油黄' },
+  { code: '0B', hex: '#ffb6c1', name: '樱花粉' },
+  { code: '0C', hex: '#98ff98', name: '薄荷绿' },
+  { code: '0D', hex: '#b399d4', name: '薰衣草' },
+  { code: '0E', hex: '#ff7f50', name: '珊瑚橙' },
+  { code: '0F', hex: '#89cff0', name: '海洋蓝' },
+];
+
+class DesignService {
+  // 保存设计选择
+  async saveDesign(design: {
+    part1: string;
+    part2: string;
+    part3: string;
+    part4: string;
+  }) {
+    // 验证颜色代码
+    const isValid = Object.values(design).every(
+      color => /^[0-9A-Fa-f]{2}$/.test(color)
+    );
+    
+    if (!isValid) {
+      throw new Error('无效的颜色代码。必须是两位十六进制值 (00-FF)');
+    }
+    
+    // 转换为大写确保一致性
+    const normalizedDesign = {
+      part1: design.part1.toUpperCase(),
+      part2: design.part2.toUpperCase(),
+      part3: design.part3.toUpperCase(),
+      part4: design.part4.toUpperCase(),
+    };
+    
+    await recordDesignUsage(normalizedDesign);
+  }
+
+  // 获取所有颜色统计数据
+  async getAllColorsStatistics() {
+    try {
+      const allUsage = await getAllDesignUsage();
+      
+      // 按部件分组
+      const byPart: Record<number, Array<{
+        code: string;
+        hex: string;
+        name: string;
+        usageCount: number;
+      }>> = {};
+      
+      for (const item of allUsage) {
+        if (!byPart[item.partId]) {
+          byPart[item.partId] = [];
+        }
+        
+        const colorInfo = this.getColorInfo(item.colorCode);
+        byPart[item.partId].push({
+          code: item.colorCode,
+          hex: colorInfo.hex,
+          name: colorInfo.name,
+          usageCount: item.usageCount
+        });
+      }
+      
+      // 对每个部件的颜色按使用次数排序
+      for (const partId in byPart) {
+        byPart[partId].sort((a, b) => b.usageCount - a.usageCount);
+      }
+      
+      return {
+        byPart,
+        timestamp: new Date().toISOString()
+      };
+    } catch (error) {
+      const err = error as Error;
+      throw new Error(`获取颜色统计数据失败: ${err.message}`);
+    }
+  }
+  
+  // 根据颜色代码获取颜色信息
+  getColorInfo(code: string) {
+    const foundColor = COLOR_MAPPING.find(c => c.code === code);
+    return foundColor || {
+      code,
+      hex: '#CCCCCC',
+      name: '未知色'
+    };
+  }
+}
+
+export const designService = new DesignService();

+ 4 - 3
back-end/tsconfig.json

@@ -4,11 +4,12 @@
     "module": "commonjs",
     "outDir": "./dist",
     "rootDir": "./src",
-    "strict": true,
+    "strict": false,
     "esModuleInterop": true,
     "skipLibCheck": true,
-    "forceConsistentCasingInFileNames": true
+    "noImplicitAny": false,
+    "forceConsistentCasingInFileNames": true,  
   },
-  "include": ["src/**/*.ts"],
+  "include": ["src/**/*.ts", "src/app.ts"],
   "exclude": ["node_modules"]
 }

+ 4 - 0
cloth-design/angular.json

@@ -18,6 +18,9 @@
         "build": {
           "builder": "@angular/build:application",
           "options": {
+            "scripts": [
+              "node_modules/chart.js/dist/chart.umd.js"
+            ],
             "browser": "src/main.ts",
             "polyfills": [
               "zone.js"
@@ -95,6 +98,7 @@
               "@angular/material/prebuilt-themes/azure-blue.css",
               "src/styles.scss"
             ]
+            
           }
         }
       }

+ 10 - 0
cloth-design/package-lock.json

@@ -17,6 +17,7 @@
         "@angular/material": "^20.0.4",
         "@angular/platform-browser": "^20.0.5",
         "@angular/router": "^20.0.0",
+        "@fortawesome/fontawesome-free": "^6.7.2",
         "chart.js": "^4.5.0",
         "echarts": "^5.6.0",
         "rxjs": "~7.8.0",
@@ -1265,6 +1266,15 @@
         "node": ">=18"
       }
     },
+    "node_modules/@fortawesome/fontawesome-free": {
+      "version": "6.7.2",
+      "resolved": "https://registry.npmmirror.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.7.2.tgz",
+      "integrity": "sha512-JUOtgFW6k9u4Y+xeIaEiLr3+cjoUPiAuLXoyKOJSia6Duzb7pq+A76P9ZdPDoAoxHdHzq6gE9/jKBGXlZT8FbA==",
+      "license": "(CC-BY-4.0 AND OFL-1.1 AND MIT)",
+      "engines": {
+        "node": ">=6"
+      }
+    },
     "node_modules/@inquirer/checkbox": {
       "version": "4.1.8",
       "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-4.1.8.tgz",

+ 1 - 0
cloth-design/package.json

@@ -29,6 +29,7 @@
     "@angular/material": "^20.0.4",
     "@angular/platform-browser": "^20.0.5",
     "@angular/router": "^20.0.0",
+    "@fortawesome/fontawesome-free": "^6.7.2",
     "chart.js": "^4.5.0",
     "echarts": "^5.6.0",
     "rxjs": "~7.8.0",

+ 17 - 19
cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.html

@@ -2,28 +2,26 @@
   <h2><i class="fas fa-chart-line"></i> 颜色流行趋势</h2>
   <p class="section-desc">查看最受欢迎的颜色搭配和当前流行趋势</p>
   
-  <h3>本周最受欢迎颜色</h3>
-  <div class="chart-container">
-    <canvas #colorChart></canvas>
+  <div *ngIf="isLoading" class="loading-container">
+    <div class="spinner"></div>
+    <p>正在加载数据...</p>
   </div>
-  
-  <h3>热门搭配方案</h3>
-  <div class="color-stats">
-    
-    <div class="color-stat">
-      <div class="color-box" style="background: linear-gradient(135deg, #3498db, #2c3e50);">
-        <i class="fas fa-water"></i>
-      </div>
-      <div class="stat-name">深海蓝黑</div>
-      <div class="stat-count">5,678 次使用</div>
-    </div>
 
-    <div class="color-stat">
-      <div class="color-box" style="background: linear-gradient(135deg, #e74c3c, #f1c40f);">
-        <i class="fas fa-sun"></i>
+  <div *ngIf="!isLoading">
+    <h3>本周最受欢迎颜色</h3>
+    <div class="chart-container">
+      <canvas #colorChart></canvas>
+    </div>
+    
+    <h3>热门搭配方案</h3>
+    <div class="color-stats">
+      <div *ngFor="let combo of popularCombinations" class="color-stat">
+        <div class="color-box" [style]="getGradientStyle(combo.colors)">
+          <i [class]="combo.icon"></i>
+        </div>
+        <div class="stat-name">{{ combo.name }}</div>
+        <div class="stat-count">{{ combo.count }}</div>
       </div>
-      <div class="stat-name">日落橙黄</div>
-      <div class="stat-count">4,987 次使用</div>
     </div>
   </div>
 </div>

+ 69 - 56
cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.scss

@@ -2,9 +2,8 @@
   background: white;
   border-radius: 25px;
   padding: 30px;
-  margin-bottom: 25px;
+  margin: 20px;
   box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
-  animation: fadeIn 0.6s ease;
 }
 
 h2 {
@@ -14,21 +13,11 @@ h2 {
   display: flex;
   align-items: center;
   gap: 12px;
-  padding-bottom: 15px;
-  border-bottom: 2px solid #ecf0f1;
-}
-
-h2 i {
-  background: linear-gradient(135deg, #3498db, #9b59b6);
-  -webkit-background-clip: text;
-  -webkit-text-fill-color: transparent;
-  width: 36px;
-  height: 36px;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  border-radius: 50%;
-  background-color: rgba(52, 152, 219, 0.1);
+  
+  i {
+    color: #3498db;
+    font-size: 1.8rem;
+  }
 }
 
 .section-desc {
@@ -38,80 +27,104 @@ h2 i {
 }
 
 .chart-container {
-  background: white;
-  border-radius: 20px;
-  padding: 20px;
-  margin-top: 25px;
-  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
+  position: relative;
+  height: 400px;
+  width: 100%;
+  margin: 20px 0;
+  
+  canvas {
+    display: block;
+    width: 100%;
+    height: 100%;
+  }
+}
+
+.loading-container {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
   height: 300px;
+  
+  .spinner {
+    width: 50px;
+    height: 50px;
+    border: 5px solid rgba(52, 152, 219, 0.2);
+    border-top: 5px solid #3498db;
+    border-radius: 50%;
+    animation: spin 1s linear infinite;
+    margin-bottom: 20px;
+  }
+  
+  p {
+    color: #95a5a6;
+    font-size: 1.1rem;
+  }
+  
+  @keyframes spin {
+    0% { transform: rotate(0deg); }
+    100% { transform: rotate(360deg); }
+  }
 }
 
 .color-stats {
   display: flex;
   flex-wrap: wrap;
-  gap: 15px;
+  gap: 20px;
   margin-top: 20px;
 }
 
 .color-stat {
   flex: 1;
-  min-width: 140px;
+  min-width: 200px;
   background: white;
-  border-radius: 18px;
-  padding: 20px 15px;
+  border-radius: 15px;
+  padding: 20px;
+  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
   text-align: center;
-  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
-  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
-}
-
-.color-stat:hover {
-  transform: translateY(-8px);
-  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
+  transition: all 0.3s ease;
+  
+  &:hover {
+    transform: translateY(-5px);
+    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
+  }
 }
 
-.color-stat .color-box {
-  width: 70px;
-  height: 70px;
+.color-box {
+  width: 80px;
+  height: 80px;
   border-radius: 50%;
   margin: 0 auto 15px;
-  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 1.8rem;
   color: white;
+  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
+  
+  i {
+    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
+  }
 }
 
-.color-stat .stat-name {
+.stat-name {
   font-weight: 700;
   margin-bottom: 8px;
   font-size: 1.1rem;
+  color: #2c3e50;
 }
 
-.color-stat .stat-count {
-  color: #95a5a6;
+.stat-count {
+  color: #7f8c8d;
   font-size: 0.95rem;
 }
 
-@keyframes fadeIn {
-  from { opacity: 0; transform: translateY(20px); }
-  to { opacity: 1; transform: translateY(0); }
-}
-
-@media (max-width: 480px) {
-  .panel {
-    padding: 25px 20px;
-  }
-  
-  .color-stats {
-    flex-direction: column;
+@media (max-width: 768px) {
+  .chart-container {
+    height: 300px;
   }
   
   .color-stat {
     min-width: 100%;
   }
-  
-  .chart-container {
-    height: 250px;
-  }
 }

+ 123 - 152
cloth-design/src/app/modules/cloth/mobile/page-trends/page-trends.component.ts

@@ -1,166 +1,137 @@
-import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
-import { Chart } from 'chart.js/auto';
-import { ColorUsage } from '../../../../../lib/ncloud';
-import { PageDesignComponent } from '../page-design/page-design.component';
-
-// 定义JSON数据结构
-interface ColorData {
-  labels: string[];
-  datasets: {
-    label: string;
-    data: number[];
-    backgroundColor: string[];
-    borderColor: string[];
-    borderWidth: number;
-    borderRadius: number;
-  }[];
-}
-
-interface ColorCombination {
-  colors: string[];
-  icon: string;
-  name: string;
-  count: string;
-}
+import { Component, ViewChild, ElementRef, AfterViewInit, OnInit } from '@angular/core';
+import Chart from 'chart.js/auto';
+import { CommonModule } from '@angular/common';
 
 @Component({
   selector: 'app-page-trends',
   standalone: true,
+  imports: [CommonModule], // 添加 CommonModule 解决 ngIf 问题
   templateUrl: './page-trends.component.html',
   styleUrls: ['./page-trends.component.scss']
 })
-export class PageTrendsComponent implements AfterViewInit {
+export class PageTrendsComponent implements OnInit, AfterViewInit {
   @ViewChild('colorChart') colorChartRef!: ElementRef;
   private colorChart: any;
-
-  //constructor(private pageDesignComponent: PageDesignComponent) {}
-  colorUsage: ColorUsage = new ColorUsage();
-
-
-
-  /*colorData: ColorData = {
-    labels: ['海洋蓝', '活力红', '森林绿', '阳光黄', '梦幻紫', '珊瑚橙'],
-    datasets: [{
-      label: '使用次数',
-      data: [1850, 1620, 1540, 1420, 1360, 1280],
-      backgroundColor: [
-        '#3498db',
-        '#e74c3c',
-        '#2ecc71',
-        '#f1c40f',
-        '#9b59b6',
-        '#ff7f50'
-      ],
-      borderColor: [
-        '#2980b9',
-        '#c0392b',
-        '#27ae60',
-        '#f39c12',
-        '#8e44ad',
-        '#ff6347'
-      ],
-      borderWidth: 1,
-      borderRadius: 10
-    }]
-  };*/
-
-// 增加一个方法来获取颜色使用统计结果并生成图表数据
-private getColorData(): any {
-    const colorUsage = this.colorUsage.getAll();
-    const sortedColors = Object.entries(colorUsage).sort((a, b) => b[1] - a[1]);
-    const topColors = sortedColors.slice(0, 6);
-
-    return {
-      labels: topColors.map(([color]) => color),
-      datasets: [{
-        label: '使用次数',
-        data: topColors.map(([, count]) => count),
-        backgroundColor: topColors.map(([color]) => color),
-        borderColor: topColors.map(([color]) => this.darkenColor(color, 20)),
-        borderWidth: 1,
-        borderRadius: 10
-      }]
-    };
+  isLoading = true;
+  
+  // 使用模拟数据确保图表始终显示
+  chartData: any = {
+    labels: ['天空蓝', '热情红', '森林绿', '阳光黄', '紫罗兰', '碧波绿'],
+    datasets: [{
+      label: '使用次数',
+      data: [1850, 1620, 1540, 1420, 1360, 1280],
+      backgroundColor: [
+        '#3498db',
+        '#e74c3c',
+        '#2ecc71',
+        '#f1c40f',
+        '#9b59b6',
+        '#1abc9c'
+      ],
+      borderColor: [
+        '#2980b9',
+        '#c0392b',
+        '#27ae60',
+        '#f39c12',
+        '#8e44ad',
+        '#16a085'
+      ],
+      borderWidth: 1,
+      borderRadius: 10
+    }]
+  };
+
+  // 模拟热门搭配数据
+  popularCombinations: any[] = [
+    {
+      colors: ['#3498db', '#2c3e50'],
+      name: '深海蓝黑',
+      count: '5,678 次使用',
+      icon: 'fas fa-water'
+    },
+    {
+      colors: ['#e74c3c', '#f1c40f'],
+      name: '日落橙黄',
+      count: '4,987 次使用',
+      icon: 'fas fa-sun'
+    }
+  ];
+
+  ngOnInit() {
+    // 模拟数据加载
+    setTimeout(() => {
+      this.isLoading = false;
+      this.initChart();
+    }, 1000);
   }
 
-  // JSON格式的热门搭配数据
-  popularCombinations: ColorCombination[] = [
-    {
-      colors: ['#3498db', '#2c3e50'],
-      icon: 'fas fa-water',
-      name: '深海蓝黑',
-      count: '5,678 次使用'
-    },
-    {
-      colors: ['#e74c3c', '#f1c40f'],
-      icon: 'fas fa-sun',
-      name: '日落橙黄',
-      count: '4,987 次使用'
-    }
-  ];
-
-  ngAfterViewInit() {
-    this.initChart();
-  }
-
-  private initChart() {
-    const ctx = this.colorChartRef.nativeElement.getContext('2d');
-    this.colorChart = new Chart(ctx, {
-      type: 'bar',
-      //data: this.colorData,
-      data: this.getColorData(),
-      options: {
-        responsive: true,
-        maintainAspectRatio: false,
-        plugins: {
-          legend: {
-            display: false
-          },
-          title: {
-            display: true,
-            text: '颜色使用频率统计',
-            font: {
-              size: 16
-            }
-          }
-        },
-        scales: {
-          y: {
-            beginAtZero: true,
-            grid: {
-              color: 'rgba(0, 0, 0, 0.05)'
-            }
-          },
-          x: {
-            grid: {
-              display: false
-            }
-          }
-        }
-      }
-    });
-  }
-
-
-  // 生成渐变背景样式
-  getGradientStyle(colors: string[]): string {
-    return `background: linear-gradient(135deg, ${colors[0]}, ${colors[1]});`;
-  }
+  ngAfterViewInit() {
+    // 确保视图初始化后尝试创建图表
+    setTimeout(() => this.initChart(), 500);
+  }
 
-// 增加一个方法来生成颜色的边框颜色
-private darkenColor(color: string, percent: number): string {
-  const num = parseInt(color.replace('#', ''), 16);
-  const amt = Math.round(2.55 * percent);
-  const R = (num >> 16) - amt;
-  const G = (num >> 8 & 0x00FF) - amt;
-  const B = (num & 0x0000FF) - amt;
-  
-  return '#' + (
-    0x1000000 +
-    (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
-    (G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
-    (B < 255 ? B < 1 ? 0 : B : 255)
-  ).toString(16).slice(1);
-}
+  private initChart() {
+    if (!this.colorChartRef?.nativeElement) {
+      console.warn('Canvas元素不可用,延迟重试');
+      setTimeout(() => this.initChart(), 500);
+      return;
+    }
+    
+    const ctx = this.colorChartRef.nativeElement.getContext('2d');
+    
+    // 销毁现有图表实例
+    if (this.colorChart) {
+      this.colorChart.destroy();
+    }
+    
+    this.colorChart = new Chart(ctx, {
+      type: 'bar',
+      data: this.chartData,
+      options: {
+        responsive: true,
+        maintainAspectRatio: false,
+        plugins: {
+          legend: {
+            display: false
+          },
+          title: {
+            display: true,
+            text: '颜色使用频率统计',
+            font: {
+              size: 16
+            }
+          },
+          tooltip: {
+            callbacks: {
+              label: function(context) {
+                return `使用次数: ${context.parsed.y.toLocaleString()}`;
+              }
+            }
+          }
+        },
+        scales: {
+          y: {
+            beginAtZero: true,
+            grid: {
+              color: 'rgba(0, 0, 0, 0.05)'
+            },
+            ticks: {
+              callback: function(value) {
+                return value.toLocaleString();
+              }
+            }
+          },
+          x: {
+            grid: {
+              display: false
+            }
+          }
+        }
+      }
+    });
+  }
 
+  getGradientStyle(colors: string[]): string {
+    return `background: linear-gradient(135deg, ${colors[0]}, ${colors[1]});`;
+  }
 }

+ 55 - 0
cloth-design/src/app/services/color-mapping.service.ts

@@ -0,0 +1,55 @@
+import { Injectable } from '@angular/core';
+
+@Injectable({
+  providedIn: 'root'
+})
+export class ColorMappingService {
+  private COLOR_MAPPING = [
+    { code: '00', hex: '#3498db', name: '天空蓝' },
+    { code: '01', hex: '#e74c3c', name: '热情红' },
+    { code: '02', hex: '#2ecc71', name: '森林绿' },
+    { code: '03', hex: '#f1c40f', name: '阳光黄' },
+    { code: '04', hex: '#9b59b6', name: '紫罗兰' },
+    { code: '05', hex: '#1abc9c', name: '碧波绿' },
+    { code: '06', hex: '#e67e22', name: '落日橙' },
+    { code: '07', hex: '#2c3e50', name: '午夜蓝' },
+    { code: '08', hex: '#ecf0f1', name: '云朵白' },
+    { code: '09', hex: '#e84393', name: '玫瑰粉' },
+    { code: '0A', hex: '#ffeaa7', name: '奶油黄' },
+    { code: '0B', hex: '#ffb6c1', name: '樱花粉' },
+    { code: '0C', hex: '#98ff98', name: '薄荷绿' },
+    { code: '0D', hex: '#b399d4', name: '薰衣草' },
+    { code: '0E', hex: '#ff7f50', name: '珊瑚橙' },
+    { code: '0F', hex: '#89cff0', name: '海洋蓝' },
+    { code: '10', hex: '#ff9aa2', name: '西瓜红' },
+    { code: '11', hex: '#40e0d0', name: '蓝绿色' },
+    { code: '12', hex: '#f0e68c', name: '卡其黄' },
+    { code: '13', hex: '#c8a2c8', name: '丁香紫' },
+  ];
+
+  constructor() {}
+
+  getAllColors() {
+    return this.COLOR_MAPPING;
+  }
+
+  getColorInfo(code: string) {
+    const foundColor = this.COLOR_MAPPING.find(c => c.code === code);
+    return foundColor || { code, hex: '#CCCCCC', name: '未知色' };
+  }
+
+  darkenColor(color: string, percent: number): string {
+    const num = parseInt(color.replace('#', ''), 16);
+    const amt = Math.round(2.55 * percent);
+    const R = Math.max(0, (num >> 16) - amt);
+    const G = Math.max(0, (num >> 8 & 0x00FF) - amt);
+    const B = Math.max(0, (num & 0x0000FF) - amt);
+    
+    return '#' + (
+      0x1000000 +
+      (R < 255 ? R : 255) * 0x10000 +
+      (G < 255 ? G : 255) * 0x100 +
+      (B < 255 ? B : 255)
+    ).toString(16).slice(1);
+  }
+}

+ 38 - 0
cloth-design/src/app/services/design-api.service.ts

@@ -0,0 +1,38 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { Observable } from 'rxjs';
+import { environment } from '../../environments/environment';
+
+@Injectable({
+  providedIn: 'root'
+})
+export class DesignApiService {
+  private apiUrl = `${environment.apiUrl}/designs`;
+
+  constructor(private http: HttpClient) {}
+
+  // 获取颜色统计数据
+  getAllColorsStatistics(): Observable<any> {
+    return this.http.get(`${this.apiUrl}/color-statistics`);
+  }
+
+  // 记录设计使用
+  saveDesign(design: {
+    part1: string;
+    part2: string;
+    part3: string;
+    part4: string;
+  }): Observable<any> {
+    return this.http.post(`${this.apiUrl}/record`, design);
+  }
+
+  // 生成测试数据
+  generateTestData(count: number): Observable<any> {
+    return this.http.post(`${this.apiUrl}/generate-test-data?count=${count}`, {});
+  }
+
+  // 重置统计数据
+  resetStatistics(): Observable<any> {
+    return this.http.post(`${this.apiUrl}/reset-statistics`, {});
+  }
+}

+ 5 - 0
cloth-design/src/environments/environment.prod.ts

@@ -0,0 +1,5 @@
+// src/environments/environment.prod.ts
+export const environment = {
+  production: true,
+  apiUrl: 'https://your-production-domain.com/api' // 生产环境 API 地址
+};

+ 5 - 0
cloth-design/src/environments/environment.ts

@@ -0,0 +1,5 @@
+// src/environments/environment.ts
+export const environment = {
+  production: false,
+  apiUrl: 'http://localhost:3000/api' // 您的后端 API 地址
+};

+ 6 - 0
end-b/.env

@@ -0,0 +1,6 @@
+DB_USER=user_HZJ7TG
+DB_PASSWORD=password_kJJM8P
+DB_HOST=110.42.109.119
+DB_PORT=5455
+DB_NAME=design_usage
+PORT=3000

+ 42 - 0
end-b/.gitignore

@@ -0,0 +1,42 @@
+# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
+
+# Compiled output
+/dist
+/tmp
+/out-tsc
+/bazel-out
+
+# Node
+/node_modules
+npm-debug.log
+yarn-error.log
+
+# IDEs and editors
+.idea/
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# Visual Studio Code
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+.history/*
+
+# Miscellaneous
+/.angular/cache
+.sass-cache/
+/connect.lock
+/coverage
+/libpeerconnection.log
+testem.log
+/typings
+
+# System files
+.DS_Store
+Thumbs.db

+ 1392 - 0
end-b/package-lock.json

@@ -0,0 +1,1392 @@
+{
+  "name": "back-end",
+  "version": "1.0.0",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "name": "back-end",
+      "version": "1.0.0",
+      "dependencies": {
+        "body-parser": "^1.20.2",
+        "cors": "^2.8.5",
+        "dotenv": "^16.4.5",
+        "express": "^4.19.2",
+        "pg": "^8.11.3"
+      },
+      "devDependencies": {
+        "nodemon": "^3.1.0"
+      }
+    },
+    "node_modules/accepts": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmmirror.com/accepts/-/accepts-1.3.8.tgz",
+      "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+      "license": "MIT",
+      "dependencies": {
+        "mime-types": "~2.1.34",
+        "negotiator": "0.6.3"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/anymatch": {
+      "version": "3.1.3",
+      "resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz",
+      "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
+      "dev": true,
+      "license": "ISC",
+      "dependencies": {
+        "normalize-path": "^3.0.0",
+        "picomatch": "^2.0.4"
+      },
+      "engines": {
+        "node": ">= 8"
+      }
+    },
+    "node_modules/array-flatten": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmmirror.com/array-flatten/-/array-flatten-1.1.1.tgz",
+      "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
+      "license": "MIT"
+    },
+    "node_modules/balanced-match": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
+      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
+      "dev": true,
+      "license": "MIT"
+    },
+    "node_modules/binary-extensions": {
+      "version": "2.3.0",
+      "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz",
+      "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=8"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/body-parser": {
+      "version": "1.20.3",
+      "resolved": "https://registry.npmmirror.com/body-parser/-/body-parser-1.20.3.tgz",
+      "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
+      "license": "MIT",
+      "dependencies": {
+        "bytes": "3.1.2",
+        "content-type": "~1.0.5",
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "destroy": "1.2.0",
+        "http-errors": "2.0.0",
+        "iconv-lite": "0.4.24",
+        "on-finished": "2.4.1",
+        "qs": "6.13.0",
+        "raw-body": "2.5.2",
+        "type-is": "~1.6.18",
+        "unpipe": "1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8",
+        "npm": "1.2.8000 || >= 1.4.16"
+      }
+    },
+    "node_modules/brace-expansion": {
+      "version": "1.1.12",
+      "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.12.tgz",
+      "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "balanced-match": "^1.0.0",
+        "concat-map": "0.0.1"
+      }
+    },
+    "node_modules/braces": {
+      "version": "3.0.3",
+      "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz",
+      "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "fill-range": "^7.1.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/bytes": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz",
+      "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/call-bind-apply-helpers": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
+      "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+      "license": "MIT",
+      "dependencies": {
+        "es-errors": "^1.3.0",
+        "function-bind": "^1.1.2"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/call-bound": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmmirror.com/call-bound/-/call-bound-1.0.4.tgz",
+      "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
+      "license": "MIT",
+      "dependencies": {
+        "call-bind-apply-helpers": "^1.0.2",
+        "get-intrinsic": "^1.3.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/chokidar": {
+      "version": "3.6.0",
+      "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz",
+      "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "anymatch": "~3.1.2",
+        "braces": "~3.0.2",
+        "glob-parent": "~5.1.2",
+        "is-binary-path": "~2.1.0",
+        "is-glob": "~4.0.1",
+        "normalize-path": "~3.0.0",
+        "readdirp": "~3.6.0"
+      },
+      "engines": {
+        "node": ">= 8.10.0"
+      },
+      "funding": {
+        "url": "https://paulmillr.com/funding/"
+      },
+      "optionalDependencies": {
+        "fsevents": "~2.3.2"
+      }
+    },
+    "node_modules/concat-map": {
+      "version": "0.0.1",
+      "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz",
+      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+      "dev": true,
+      "license": "MIT"
+    },
+    "node_modules/content-disposition": {
+      "version": "0.5.4",
+      "resolved": "https://registry.npmmirror.com/content-disposition/-/content-disposition-0.5.4.tgz",
+      "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+      "license": "MIT",
+      "dependencies": {
+        "safe-buffer": "5.2.1"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/content-type": {
+      "version": "1.0.5",
+      "resolved": "https://registry.npmmirror.com/content-type/-/content-type-1.0.5.tgz",
+      "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/cookie": {
+      "version": "0.7.1",
+      "resolved": "https://registry.npmmirror.com/cookie/-/cookie-0.7.1.tgz",
+      "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/cookie-signature": {
+      "version": "1.0.6",
+      "resolved": "https://registry.npmmirror.com/cookie-signature/-/cookie-signature-1.0.6.tgz",
+      "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
+      "license": "MIT"
+    },
+    "node_modules/cors": {
+      "version": "2.8.5",
+      "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz",
+      "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
+      "license": "MIT",
+      "dependencies": {
+        "object-assign": "^4",
+        "vary": "^1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/debug": {
+      "version": "2.6.9",
+      "resolved": "https://registry.npmmirror.com/debug/-/debug-2.6.9.tgz",
+      "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+      "license": "MIT",
+      "dependencies": {
+        "ms": "2.0.0"
+      }
+    },
+    "node_modules/depd": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
+      "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/destroy": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmmirror.com/destroy/-/destroy-1.2.0.tgz",
+      "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8",
+        "npm": "1.2.8000 || >= 1.4.16"
+      }
+    },
+    "node_modules/dotenv": {
+      "version": "16.6.1",
+      "resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.6.1.tgz",
+      "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
+      "license": "BSD-2-Clause",
+      "engines": {
+        "node": ">=12"
+      },
+      "funding": {
+        "url": "https://dotenvx.com"
+      }
+    },
+    "node_modules/dunder-proto": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz",
+      "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+      "license": "MIT",
+      "dependencies": {
+        "call-bind-apply-helpers": "^1.0.1",
+        "es-errors": "^1.3.0",
+        "gopd": "^1.2.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/ee-first": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz",
+      "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
+      "license": "MIT"
+    },
+    "node_modules/encodeurl": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/encodeurl/-/encodeurl-2.0.0.tgz",
+      "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/es-define-property": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz",
+      "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/es-errors": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz",
+      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/es-object-atoms": {
+      "version": "1.1.1",
+      "resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
+      "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
+      "license": "MIT",
+      "dependencies": {
+        "es-errors": "^1.3.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/escape-html": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz",
+      "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
+      "license": "MIT"
+    },
+    "node_modules/etag": {
+      "version": "1.8.1",
+      "resolved": "https://registry.npmmirror.com/etag/-/etag-1.8.1.tgz",
+      "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/express": {
+      "version": "4.21.2",
+      "resolved": "https://registry.npmmirror.com/express/-/express-4.21.2.tgz",
+      "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
+      "license": "MIT",
+      "dependencies": {
+        "accepts": "~1.3.8",
+        "array-flatten": "1.1.1",
+        "body-parser": "1.20.3",
+        "content-disposition": "0.5.4",
+        "content-type": "~1.0.4",
+        "cookie": "0.7.1",
+        "cookie-signature": "1.0.6",
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "encodeurl": "~2.0.0",
+        "escape-html": "~1.0.3",
+        "etag": "~1.8.1",
+        "finalhandler": "1.3.1",
+        "fresh": "0.5.2",
+        "http-errors": "2.0.0",
+        "merge-descriptors": "1.0.3",
+        "methods": "~1.1.2",
+        "on-finished": "2.4.1",
+        "parseurl": "~1.3.3",
+        "path-to-regexp": "0.1.12",
+        "proxy-addr": "~2.0.7",
+        "qs": "6.13.0",
+        "range-parser": "~1.2.1",
+        "safe-buffer": "5.2.1",
+        "send": "0.19.0",
+        "serve-static": "1.16.2",
+        "setprototypeof": "1.2.0",
+        "statuses": "2.0.1",
+        "type-is": "~1.6.18",
+        "utils-merge": "1.0.1",
+        "vary": "~1.1.2"
+      },
+      "engines": {
+        "node": ">= 0.10.0"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/express"
+      }
+    },
+    "node_modules/fill-range": {
+      "version": "7.1.1",
+      "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz",
+      "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "to-regex-range": "^5.0.1"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/finalhandler": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmmirror.com/finalhandler/-/finalhandler-1.3.1.tgz",
+      "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
+      "license": "MIT",
+      "dependencies": {
+        "debug": "2.6.9",
+        "encodeurl": "~2.0.0",
+        "escape-html": "~1.0.3",
+        "on-finished": "2.4.1",
+        "parseurl": "~1.3.3",
+        "statuses": "2.0.1",
+        "unpipe": "~1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/forwarded": {
+      "version": "0.2.0",
+      "resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz",
+      "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/fresh": {
+      "version": "0.5.2",
+      "resolved": "https://registry.npmmirror.com/fresh/-/fresh-0.5.2.tgz",
+      "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/fsevents": {
+      "version": "2.3.3",
+      "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz",
+      "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+      "dev": true,
+      "hasInstallScript": true,
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "engines": {
+        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+      }
+    },
+    "node_modules/function-bind": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz",
+      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+      "license": "MIT",
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/get-intrinsic": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
+      "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+      "license": "MIT",
+      "dependencies": {
+        "call-bind-apply-helpers": "^1.0.2",
+        "es-define-property": "^1.0.1",
+        "es-errors": "^1.3.0",
+        "es-object-atoms": "^1.1.1",
+        "function-bind": "^1.1.2",
+        "get-proto": "^1.0.1",
+        "gopd": "^1.2.0",
+        "has-symbols": "^1.1.0",
+        "hasown": "^2.0.2",
+        "math-intrinsics": "^1.1.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/get-proto": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz",
+      "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+      "license": "MIT",
+      "dependencies": {
+        "dunder-proto": "^1.0.1",
+        "es-object-atoms": "^1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/glob-parent": {
+      "version": "5.1.2",
+      "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz",
+      "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
+      "dev": true,
+      "license": "ISC",
+      "dependencies": {
+        "is-glob": "^4.0.1"
+      },
+      "engines": {
+        "node": ">= 6"
+      }
+    },
+    "node_modules/gopd": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz",
+      "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/has-flag": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-3.0.0.tgz",
+      "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/has-symbols": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz",
+      "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/hasown": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.2.tgz",
+      "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
+      "license": "MIT",
+      "dependencies": {
+        "function-bind": "^1.1.2"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/http-errors": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz",
+      "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
+      "license": "MIT",
+      "dependencies": {
+        "depd": "2.0.0",
+        "inherits": "2.0.4",
+        "setprototypeof": "1.2.0",
+        "statuses": "2.0.1",
+        "toidentifier": "1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/iconv-lite": {
+      "version": "0.4.24",
+      "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz",
+      "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+      "license": "MIT",
+      "dependencies": {
+        "safer-buffer": ">= 2.1.2 < 3"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/ignore-by-default": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
+      "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
+      "dev": true,
+      "license": "ISC"
+    },
+    "node_modules/inherits": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz",
+      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+      "license": "ISC"
+    },
+    "node_modules/ipaddr.js": {
+      "version": "1.9.1",
+      "resolved": "https://registry.npmmirror.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+      "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/is-binary-path": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz",
+      "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "binary-extensions": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=8"
+      }
+    },
+    "node_modules/is-extglob": {
+      "version": "2.1.1",
+      "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz",
+      "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-glob": {
+      "version": "4.0.3",
+      "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz",
+      "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "is-extglob": "^2.1.1"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/is-number": {
+      "version": "7.0.0",
+      "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz",
+      "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.12.0"
+      }
+    },
+    "node_modules/math-intrinsics": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
+      "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      }
+    },
+    "node_modules/media-typer": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmmirror.com/media-typer/-/media-typer-0.3.0.tgz",
+      "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/merge-descriptors": {
+      "version": "1.0.3",
+      "resolved": "https://registry.npmmirror.com/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
+      "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
+      "license": "MIT",
+      "funding": {
+        "url": "https://github.com/sponsors/sindresorhus"
+      }
+    },
+    "node_modules/methods": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/methods/-/methods-1.1.2.tgz",
+      "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/mime": {
+      "version": "1.6.0",
+      "resolved": "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz",
+      "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+      "license": "MIT",
+      "bin": {
+        "mime": "cli.js"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/mime-db": {
+      "version": "1.52.0",
+      "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
+      "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/mime-types": {
+      "version": "2.1.35",
+      "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
+      "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+      "license": "MIT",
+      "dependencies": {
+        "mime-db": "1.52.0"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/minimatch": {
+      "version": "3.1.2",
+      "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz",
+      "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+      "dev": true,
+      "license": "ISC",
+      "dependencies": {
+        "brace-expansion": "^1.1.7"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/ms": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/ms/-/ms-2.0.0.tgz",
+      "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+      "license": "MIT"
+    },
+    "node_modules/negotiator": {
+      "version": "0.6.3",
+      "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz",
+      "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/nodemon": {
+      "version": "3.1.10",
+      "resolved": "https://registry.npmmirror.com/nodemon/-/nodemon-3.1.10.tgz",
+      "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "chokidar": "^3.5.2",
+        "debug": "^4",
+        "ignore-by-default": "^1.0.1",
+        "minimatch": "^3.1.2",
+        "pstree.remy": "^1.1.8",
+        "semver": "^7.5.3",
+        "simple-update-notifier": "^2.0.0",
+        "supports-color": "^5.5.0",
+        "touch": "^3.1.0",
+        "undefsafe": "^2.0.5"
+      },
+      "bin": {
+        "nodemon": "bin/nodemon.js"
+      },
+      "engines": {
+        "node": ">=10"
+      },
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/nodemon"
+      }
+    },
+    "node_modules/nodemon/node_modules/debug": {
+      "version": "4.4.1",
+      "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.1.tgz",
+      "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "ms": "^2.1.3"
+      },
+      "engines": {
+        "node": ">=6.0"
+      },
+      "peerDependenciesMeta": {
+        "supports-color": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/nodemon/node_modules/ms": {
+      "version": "2.1.3",
+      "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz",
+      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+      "dev": true,
+      "license": "MIT"
+    },
+    "node_modules/normalize-path": {
+      "version": "3.0.0",
+      "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz",
+      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-assign": {
+      "version": "4.1.1",
+      "resolved": "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz",
+      "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/object-inspect": {
+      "version": "1.13.4",
+      "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.4.tgz",
+      "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/on-finished": {
+      "version": "2.4.1",
+      "resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz",
+      "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+      "license": "MIT",
+      "dependencies": {
+        "ee-first": "1.1.1"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/parseurl": {
+      "version": "1.3.3",
+      "resolved": "https://registry.npmmirror.com/parseurl/-/parseurl-1.3.3.tgz",
+      "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/path-to-regexp": {
+      "version": "0.1.12",
+      "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
+      "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
+      "license": "MIT"
+    },
+    "node_modules/pg": {
+      "version": "8.16.3",
+      "resolved": "https://registry.npmmirror.com/pg/-/pg-8.16.3.tgz",
+      "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==",
+      "license": "MIT",
+      "dependencies": {
+        "pg-connection-string": "^2.9.1",
+        "pg-pool": "^3.10.1",
+        "pg-protocol": "^1.10.3",
+        "pg-types": "2.2.0",
+        "pgpass": "1.0.5"
+      },
+      "engines": {
+        "node": ">= 16.0.0"
+      },
+      "optionalDependencies": {
+        "pg-cloudflare": "^1.2.7"
+      },
+      "peerDependencies": {
+        "pg-native": ">=3.0.1"
+      },
+      "peerDependenciesMeta": {
+        "pg-native": {
+          "optional": true
+        }
+      }
+    },
+    "node_modules/pg-cloudflare": {
+      "version": "1.2.7",
+      "resolved": "https://registry.npmmirror.com/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz",
+      "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==",
+      "license": "MIT",
+      "optional": true
+    },
+    "node_modules/pg-connection-string": {
+      "version": "2.9.1",
+      "resolved": "https://registry.npmmirror.com/pg-connection-string/-/pg-connection-string-2.9.1.tgz",
+      "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==",
+      "license": "MIT"
+    },
+    "node_modules/pg-int8": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/pg-int8/-/pg-int8-1.0.1.tgz",
+      "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
+      "license": "ISC",
+      "engines": {
+        "node": ">=4.0.0"
+      }
+    },
+    "node_modules/pg-pool": {
+      "version": "3.10.1",
+      "resolved": "https://registry.npmmirror.com/pg-pool/-/pg-pool-3.10.1.tgz",
+      "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==",
+      "license": "MIT",
+      "peerDependencies": {
+        "pg": ">=8.0"
+      }
+    },
+    "node_modules/pg-protocol": {
+      "version": "1.10.3",
+      "resolved": "https://registry.npmmirror.com/pg-protocol/-/pg-protocol-1.10.3.tgz",
+      "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==",
+      "license": "MIT"
+    },
+    "node_modules/pg-types": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmmirror.com/pg-types/-/pg-types-2.2.0.tgz",
+      "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
+      "license": "MIT",
+      "dependencies": {
+        "pg-int8": "1.0.1",
+        "postgres-array": "~2.0.0",
+        "postgres-bytea": "~1.0.0",
+        "postgres-date": "~1.0.4",
+        "postgres-interval": "^1.1.0"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/pgpass": {
+      "version": "1.0.5",
+      "resolved": "https://registry.npmmirror.com/pgpass/-/pgpass-1.0.5.tgz",
+      "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
+      "license": "MIT",
+      "dependencies": {
+        "split2": "^4.1.0"
+      }
+    },
+    "node_modules/picomatch": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz",
+      "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
+      "dev": true,
+      "license": "MIT",
+      "engines": {
+        "node": ">=8.6"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/jonschlinkert"
+      }
+    },
+    "node_modules/postgres-array": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/postgres-array/-/postgres-array-2.0.0.tgz",
+      "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/postgres-bytea": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
+      "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/postgres-date": {
+      "version": "1.0.7",
+      "resolved": "https://registry.npmmirror.com/postgres-date/-/postgres-date-1.0.7.tgz",
+      "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/postgres-interval": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmmirror.com/postgres-interval/-/postgres-interval-1.2.0.tgz",
+      "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
+      "license": "MIT",
+      "dependencies": {
+        "xtend": "^4.0.0"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/proxy-addr": {
+      "version": "2.0.7",
+      "resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.7.tgz",
+      "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+      "license": "MIT",
+      "dependencies": {
+        "forwarded": "0.2.0",
+        "ipaddr.js": "1.9.1"
+      },
+      "engines": {
+        "node": ">= 0.10"
+      }
+    },
+    "node_modules/pstree.remy": {
+      "version": "1.1.8",
+      "resolved": "https://registry.npmmirror.com/pstree.remy/-/pstree.remy-1.1.8.tgz",
+      "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
+      "dev": true,
+      "license": "MIT"
+    },
+    "node_modules/qs": {
+      "version": "6.13.0",
+      "resolved": "https://registry.npmmirror.com/qs/-/qs-6.13.0.tgz",
+      "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
+      "license": "BSD-3-Clause",
+      "dependencies": {
+        "side-channel": "^1.0.6"
+      },
+      "engines": {
+        "node": ">=0.6"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/range-parser": {
+      "version": "1.2.1",
+      "resolved": "https://registry.npmmirror.com/range-parser/-/range-parser-1.2.1.tgz",
+      "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/raw-body": {
+      "version": "2.5.2",
+      "resolved": "https://registry.npmmirror.com/raw-body/-/raw-body-2.5.2.tgz",
+      "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
+      "license": "MIT",
+      "dependencies": {
+        "bytes": "3.1.2",
+        "http-errors": "2.0.0",
+        "iconv-lite": "0.4.24",
+        "unpipe": "1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/readdirp": {
+      "version": "3.6.0",
+      "resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz",
+      "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "picomatch": "^2.2.1"
+      },
+      "engines": {
+        "node": ">=8.10.0"
+      }
+    },
+    "node_modules/safe-buffer": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz",
+      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+      "funding": [
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/feross"
+        },
+        {
+          "type": "patreon",
+          "url": "https://www.patreon.com/feross"
+        },
+        {
+          "type": "consulting",
+          "url": "https://feross.org/support"
+        }
+      ],
+      "license": "MIT"
+    },
+    "node_modules/safer-buffer": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz",
+      "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
+      "license": "MIT"
+    },
+    "node_modules/semver": {
+      "version": "7.7.2",
+      "resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.2.tgz",
+      "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
+      "dev": true,
+      "license": "ISC",
+      "bin": {
+        "semver": "bin/semver.js"
+      },
+      "engines": {
+        "node": ">=10"
+      }
+    },
+    "node_modules/send": {
+      "version": "0.19.0",
+      "resolved": "https://registry.npmmirror.com/send/-/send-0.19.0.tgz",
+      "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
+      "license": "MIT",
+      "dependencies": {
+        "debug": "2.6.9",
+        "depd": "2.0.0",
+        "destroy": "1.2.0",
+        "encodeurl": "~1.0.2",
+        "escape-html": "~1.0.3",
+        "etag": "~1.8.1",
+        "fresh": "0.5.2",
+        "http-errors": "2.0.0",
+        "mime": "1.6.0",
+        "ms": "2.1.3",
+        "on-finished": "2.4.1",
+        "range-parser": "~1.2.1",
+        "statuses": "2.0.1"
+      },
+      "engines": {
+        "node": ">= 0.8.0"
+      }
+    },
+    "node_modules/send/node_modules/encodeurl": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/encodeurl/-/encodeurl-1.0.2.tgz",
+      "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/send/node_modules/ms": {
+      "version": "2.1.3",
+      "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz",
+      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+      "license": "MIT"
+    },
+    "node_modules/serve-static": {
+      "version": "1.16.2",
+      "resolved": "https://registry.npmmirror.com/serve-static/-/serve-static-1.16.2.tgz",
+      "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
+      "license": "MIT",
+      "dependencies": {
+        "encodeurl": "~2.0.0",
+        "escape-html": "~1.0.3",
+        "parseurl": "~1.3.3",
+        "send": "0.19.0"
+      },
+      "engines": {
+        "node": ">= 0.8.0"
+      }
+    },
+    "node_modules/setprototypeof": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz",
+      "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
+      "license": "ISC"
+    },
+    "node_modules/side-channel": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.1.0.tgz",
+      "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
+      "license": "MIT",
+      "dependencies": {
+        "es-errors": "^1.3.0",
+        "object-inspect": "^1.13.3",
+        "side-channel-list": "^1.0.0",
+        "side-channel-map": "^1.0.1",
+        "side-channel-weakmap": "^1.0.2"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/side-channel-list": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/side-channel-list/-/side-channel-list-1.0.0.tgz",
+      "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
+      "license": "MIT",
+      "dependencies": {
+        "es-errors": "^1.3.0",
+        "object-inspect": "^1.13.3"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/side-channel-map": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/side-channel-map/-/side-channel-map-1.0.1.tgz",
+      "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
+      "license": "MIT",
+      "dependencies": {
+        "call-bound": "^1.0.2",
+        "es-errors": "^1.3.0",
+        "get-intrinsic": "^1.2.5",
+        "object-inspect": "^1.13.3"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/side-channel-weakmap": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
+      "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
+      "license": "MIT",
+      "dependencies": {
+        "call-bound": "^1.0.2",
+        "es-errors": "^1.3.0",
+        "get-intrinsic": "^1.2.5",
+        "object-inspect": "^1.13.3",
+        "side-channel-map": "^1.0.1"
+      },
+      "engines": {
+        "node": ">= 0.4"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/ljharb"
+      }
+    },
+    "node_modules/simple-update-notifier": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmmirror.com/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
+      "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "semver": "^7.5.3"
+      },
+      "engines": {
+        "node": ">=10"
+      }
+    },
+    "node_modules/split2": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/split2/-/split2-4.2.0.tgz",
+      "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
+      "license": "ISC",
+      "engines": {
+        "node": ">= 10.x"
+      }
+    },
+    "node_modules/statuses": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz",
+      "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/supports-color": {
+      "version": "5.5.0",
+      "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-5.5.0.tgz",
+      "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "has-flag": "^3.0.0"
+      },
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/to-regex-range": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz",
+      "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "is-number": "^7.0.0"
+      },
+      "engines": {
+        "node": ">=8.0"
+      }
+    },
+    "node_modules/toidentifier": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz",
+      "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.6"
+      }
+    },
+    "node_modules/touch": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmmirror.com/touch/-/touch-3.1.1.tgz",
+      "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
+      "dev": true,
+      "license": "ISC",
+      "bin": {
+        "nodetouch": "bin/nodetouch.js"
+      }
+    },
+    "node_modules/type-is": {
+      "version": "1.6.18",
+      "resolved": "https://registry.npmmirror.com/type-is/-/type-is-1.6.18.tgz",
+      "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+      "license": "MIT",
+      "dependencies": {
+        "media-typer": "0.3.0",
+        "mime-types": "~2.1.24"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/undefsafe": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmmirror.com/undefsafe/-/undefsafe-2.0.5.tgz",
+      "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
+      "dev": true,
+      "license": "MIT"
+    },
+    "node_modules/unpipe": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz",
+      "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/utils-merge": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npmmirror.com/utils-merge/-/utils-merge-1.0.1.tgz",
+      "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.4.0"
+      }
+    },
+    "node_modules/vary": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz",
+      "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+      "license": "MIT",
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/xtend": {
+      "version": "4.0.2",
+      "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz",
+      "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
+      "license": "MIT",
+      "engines": {
+        "node": ">=0.4"
+      }
+    }
+  }
+}

+ 18 - 0
end-b/package.json

@@ -0,0 +1,18 @@
+{
+  "name": "back-end",
+  "version": "1.0.0",
+  "scripts": {
+    "start": "node src/index.js",
+    "dev": "nodemon src/index.js"
+  },
+  "dependencies": {
+    "body-parser": "^1.20.2",
+    "cors": "^2.8.5",
+    "dotenv": "^16.4.5",
+    "express": "^4.19.2",
+    "pg": "^8.11.3"
+  },
+  "devDependencies": {
+    "nodemon": "^3.1.0"
+  }
+}

+ 44 - 0
end-b/src/app.js

@@ -0,0 +1,44 @@
+const express = require('express');
+const bodyParser = require('body-parser');
+const cors = require('cors');
+const router = require('./routes/index');
+const { initializeDatabase } = require('./database');
+const config = require('./config');
+
+const app = express();
+
+// 中间件
+app.use(cors());
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: true }));
+
+// 数据库初始化中间件
+app.use(async (req, res, next) => {
+  try {
+    await initializeDatabase();
+    next();
+  } catch (error) {
+    console.error('❌ 数据库初始化失败:', error);
+    res.status(500).json({ error: '数据库初始化失败' });
+  }
+});
+
+// 在数据库初始化后添加
+app.use('/api', router);
+
+// 打印所有注册的端点
+app._router.stack.forEach(middleware => {
+  if (middleware.route) {
+    // 应用程序级别的路由
+    console.log(`${Object.keys(middleware.route.methods).join(', ')} ${middleware.route.path}`);
+  } else if (middleware.name === 'router') {
+    // 路由级别的中间件
+    middleware.handle.stack.forEach(handler => {
+      if (handler.route) {
+        console.log(`${Object.keys(handler.route.methods).join(', ')} ${handler.route.path}`);
+      }
+    });
+  }
+});
+
+module.exports = app;

+ 12 - 0
end-b/src/config.js

@@ -0,0 +1,12 @@
+require('dotenv').config();
+
+module.exports = {
+  port: process.env.PORT || 3000,
+  db: {
+    user: process.env.DB_USER || 'postgres',
+    host: process.env.DB_HOST || 'localhost',
+    database: process.env.DB_NAME || 'cloth_design',
+    password: process.env.DB_PASSWORD || 'yourpassword',
+    port: parseInt(process.env.DB_PORT || '5432'),
+  }
+};

+ 44 - 0
end-b/src/controllers/design.controller.js

@@ -0,0 +1,44 @@
+const designService = require('../services/design.service');
+
+const designController = {
+  // 获取颜色统计数据
+  getColorStatistics: async (req, res) => {
+    try {
+      const stats = await designService.getAllColorsStatistics();
+      res.json({
+        success: true,
+        data: stats
+      });
+    } catch (error) {
+      console.error('获取颜色统计失败:', error);
+      res.status(500).json({ 
+        success: false,
+        error: '获取颜色统计数据失败'
+      });
+    }
+  },
+  
+  // 记录设计使用
+  recordDesignUsage: async (req, res) => {
+    try {
+      const design = {
+        part1: req.body.part1,
+        part2: req.body.part2,
+        part3: req.body.part3,
+        part4: req.body.part4,
+      };
+      
+      await designService.saveDesign(design);
+      res.json({ success: true });
+    } catch (error) {
+      console.error('记录设计使用失败:', error);
+      res.status(400).json({ 
+        success: false,
+        error: error.message
+      });
+    }
+  }
+};
+
+// 确保正确导出控制器对象
+module.exports = designController;

+ 177 - 0
end-b/src/database.js

@@ -0,0 +1,177 @@
+const { Pool } = require('pg');
+const fs = require('fs');
+const path = require('path');
+const { db } = require('./config');
+
+// 全局连接池
+let pool;
+
+// 创建连接池
+function createPool() {
+  if (!pool) {
+    pool = new Pool(db);
+    
+    // 错误处理
+    pool.on('error', (err) => {
+      console.error('Unexpected database error', err);
+    });
+  }
+  return pool;
+}
+
+// 查询函数
+exports.query = async (text, params) => {
+  const pool = createPool();
+  try {
+    return await pool.query(text, params);
+  } catch (error) {
+    console.error('Database query failed:', error);
+    throw error;
+  }
+};
+
+// 事务执行函数
+exports.executeInTransaction = async (callback) => {
+  const pool = createPool();
+  const client = await pool.connect();
+  try {
+    await client.query('BEGIN');
+    await callback(client);
+    await client.query('COMMIT');
+  } catch (error) {
+    await client.query('ROLLBACK');
+    throw error;
+  } finally {
+    client.release();
+  }
+};
+
+// 测试数据库连接
+exports.testDbConnection = async () => {
+  try {
+    const result = await exports.query('SELECT NOW()');
+    return { time: result.rows[0].now };
+  } catch (error) {
+    throw new Error(`Database connection failed: ${error.message}`);
+  }
+};
+
+// 完整的数据库初始化
+exports.initializeDatabase = async () => {
+  try {
+    // 第一步:检查数据库是否存在
+    try {
+      // 尝试连接到目标数据库
+      await exports.testDbConnection();
+      console.log('✅ 数据库连接成功');
+    } catch (dbError) {
+      // 如果数据库不存在,创建它
+      if (dbError.code === '3D000') {
+        console.log('🆕 数据库不存在,尝试创建...');
+        
+        // 连接到默认的postgres数据库
+        const adminPool = new Pool({
+          ...db,
+          database: 'postgres'
+        });
+        
+        // 创建新数据库
+        await adminPool.query(`CREATE DATABASE ${db.database}`);
+        console.log(`🎉 数据库 ${db.database} 创建成功`);
+        
+        // 关闭管理员连接
+        await adminPool.end();
+      } else {
+        throw dbError;
+      }
+    }
+    
+    // 第二步:检查表是否存在
+    const tableExists = await exports.query(
+      `SELECT EXISTS (
+        SELECT FROM information_schema.tables 
+        WHERE table_schema = 'public' 
+        AND table_name = 'design_usage'
+      )`
+    );
+    
+    // 如果表不存在则创建
+    if (!tableExists.rows[0].exists) {
+      console.log('🆕 创建 design_usage 表...');
+      
+      // 创建表结构
+      await exports.query(`
+        CREATE TABLE design_usage (
+          id SERIAL PRIMARY KEY,
+          part_id INTEGER NOT NULL CHECK (part_id BETWEEN 1 AND 4),
+          color_code CHAR(2) NOT NULL CHECK (color_code ~ '^[0-9A-F]{2}$'),
+          usage_count INTEGER NOT NULL DEFAULT 0,
+          UNIQUE (part_id, color_code)
+        )
+      `);
+      
+      console.log('🎉 design_usage 表创建成功');
+      
+      // 插入初始数据
+      console.log('📥 插入初始数据...');
+      await exports.query(`
+        INSERT INTO design_usage (part_id, color_code, usage_count) VALUES
+        (1, '00', 1850), (1, '01', 1620), (1, '02', 1540), (1, '03', 1420),
+        (2, '04', 1360), (2, '05', 1280), (2, '06', 1200), (2, '07', 1150),
+        (3, '08', 1100), (3, '09', 1050), (3, '0A', 1000), (3, '0B', 950),
+        (4, '0C', 900), (4, '0D', 850), (4, '0E', 800), (4, '0F', 750)
+      `);
+      console.log('🎉 初始数据插入完成');
+    }
+    
+    // 第三步:测试数据库连接
+    const dbStatus = await exports.testDbConnection();
+    console.log('📡 数据库连接成功:', dbStatus);
+    
+    return true;
+  } catch (error) {
+    console.error('🔥 数据库初始化失败:');
+    console.error(error);
+    throw error;
+  }
+};
+
+// 获取所有设计使用情况
+exports.getAllDesignUsage = async () => {
+  try {
+    const result = await exports.query(`
+      SELECT part_id, color_code, usage_count
+      FROM design_usage
+      ORDER BY part_id, usage_count DESC
+    `);
+    
+    return result.rows.map(row => ({
+      partId: row.part_id,
+      colorCode: row.color_code,
+      usageCount: row.usage_count
+    }));
+  } catch (error) {
+    throw new Error(`获取设计使用数据失败: ${error.message}`);
+  }
+};
+
+// 记录设计使用情况
+exports.recordDesignUsage = async (design) => {
+  await exports.executeInTransaction(async (client) => {
+    const colors = [
+      design.part1, design.part2, 
+      design.part3, design.part4
+    ];
+    
+    for (let partId = 1; partId <= 4; partId++) {
+      const colorCode = colors[partId - 1];
+      await client.query(
+        `INSERT INTO design_usage (part_id, color_code, usage_count)
+         VALUES ($1, $2, 1)
+         ON CONFLICT (part_id, color_code)
+         DO UPDATE SET usage_count = design_usage.usage_count + 1`,
+        [partId, colorCode]
+      );
+    }
+  });
+};

+ 10 - 0
end-b/src/index.js

@@ -0,0 +1,10 @@
+const app = require('./app');
+const config = require('./config');
+
+const port = config.port || 3000;
+
+app.listen(port, () => {
+  console.log(`🚀 服务器运行在 http://localhost:${port}`);
+  console.log(`📡 API 端点: http://localhost:${port}/api`);
+  console.log(`🩺 健康检查: http://localhost:${port}/health`);
+});

+ 18 - 0
end-b/src/routes/design.route.js

@@ -0,0 +1,18 @@
+const express = require('express');
+const router = express.Router();
+
+// 正确导入控制器
+const designController = require('../controllers/design.controller');
+
+// 验证控制器函数是否存在
+if (!designController.getColorStatistics) {
+  throw new Error('designController.getColorStatistics is undefined');
+}
+
+// 确保传递完整的函数引用
+router.get('/color-statistics', designController.getColorStatistics);
+
+// 添加其他端点
+router.post('/record', designController.recordDesignUsage);
+
+module.exports = router;

+ 26 - 0
end-b/src/routes/index.js

@@ -0,0 +1,26 @@
+const express = require('express');
+const router = express.Router();
+
+// 导入前打印调试信息
+console.log('导入设计路由前');
+
+// 导入设计路由
+const designRouter = require('./design.route');
+
+// 导入后验证路由
+console.log('导入的设计路由:', designRouter);
+
+// 使用设计路由
+router.use('/designs', designRouter);
+
+// 打印路由栈以验证
+console.log('已注册的主路由:');
+router.stack.forEach((layer) => {
+  if (layer.route) {
+    console.log(`路径: ${layer.route.path}`);
+  } else if (layer.name === 'router') {
+    console.log(`子路由器: ${layer.handle.stack.length} 个路由`);
+  }
+});
+
+module.exports = router;

+ 75 - 0
end-b/src/services/design.service.js

@@ -0,0 +1,75 @@
+const { getAllDesignUsage } = require('../database');
+
+// 颜色映射配置
+const COLOR_MAPPING = [
+  { code: '00', hex: '#3498db', name: '天空蓝' },
+  { code: '01', hex: '#e74c3c', name: '热情红' },
+  { code: '02', hex: '#2ecc71', name: '森林绿' },
+  { code: '03', hex: '#f1c40f', name: '阳光黄' },
+  { code: '04', hex: '#9b59b6', name: '紫罗兰' },
+  { code: '05', hex: '#1abc9c', name: '碧波绿' },
+  { code: '06', hex: '#e67e22', name: '落日橙' },
+  { code: '07', hex: '#2c3e50', name: '午夜蓝' },
+  { code: '08', hex: '#ecf0f1', name: '云朵白' },
+  { code: '09', hex: '#e84393', name: '玫瑰粉' },
+  { code: '0A', hex: '#ffeaa7', name: '奶油黄' },
+  { code: '0B', hex: '#ffb6c1', name: '樱花粉' },
+  { code: '0C', hex: '#98ff98', name: '薄荷绿' },
+  { code: '0D', hex: '#b399d4', name: '薰衣草' },
+  { code: '0E', hex: '#ff7f50', name: '珊瑚橙' },
+  { code: '0F', hex: '#89cff0', name: '海洋蓝' },
+  { code: '10', hex: '#ff9aa2', name: '西瓜红' },
+  { code: '11', hex: '#40e0d0', name: '蓝绿色' },
+  { code: '12', hex: '#f0e68c', name: '卡其黄' },
+  { code: '13', hex: '#c8a2c8', name: '丁香紫' },
+];
+
+// 根据颜色代码获取颜色信息
+function getColorInfo(code) {
+  return COLOR_MAPPING.find(c => c.code === code) || {
+    code,
+    hex: '#CCCCCC',
+    name: '未知色'
+  };
+}
+
+class DesignService {
+  // 获取所有颜色统计数据
+  async getAllColorsStatistics() {
+    try {
+      const allUsage = await getAllDesignUsage();
+      
+      // 按部件分组
+      const byPart = {};
+      
+      for (const item of allUsage) {
+        if (!byPart[item.partId]) {
+          byPart[item.partId] = [];
+        }
+        
+        const colorInfo = getColorInfo(item.colorCode);
+        byPart[item.partId].push({
+          code: item.colorCode,
+          hex: colorInfo.hex,
+          name: colorInfo.name,
+          usageCount: item.usageCount
+        });
+      }
+      
+      // 对每个部件的颜色按使用次数排序
+      for (const partId in byPart) {
+        byPart[partId].sort((a, b) => b.usageCount - a.usageCount);
+      }
+      
+      return {
+        byPart,
+        timestamp: new Date().toISOString()
+      };
+    } catch (error) {
+      console.error('获取颜色统计数据失败:', error);
+      throw error;
+    }
+  }
+}
+
+module.exports = new DesignService();