Files
XuJiacheng daea483199 feat: 更新项目配置、数据库架构和文档路径
- 将项目文档路径从 project1.md 改为 project_management/project.md
- 启用酒店列表、房间列表和房型列表接口,并扩展启用的酒店ID范围
- 更新项目文档中的字段定义,将多个空调和能耗表字段改为数组类型以支持多设备
- 用新的 room_status_moment.sql 替换 init_db.sql,新增 bright_g 和 agreement_ver 字段,并为空调和能耗表字段使用数组类型,同时添加唯一索引支持 UPSERT
2026-02-10 09:03:18 +08:00
..

Temporary Project Management

This is a local Node.js project for fetching hotel data and loop addresses, managing them in a local SQLite database.

Prerequisites

  • Node.js (v14+ recommended)
  • npm

Installation

  1. Clone or navigate to the project directory.
  2. Install dependencies:
    npm install
    
  3. Copy .env.example to .env and configure:
    cp .env.example .env
    
    (On Windows: copy .env.example .env)

Configuration (.env)

  • PORT: App port (default 3000)
  • DB_FILE: Path to SQLite database file (default ./local.db)
  • ENABLED_HOTEL_IDS: Comma-separated list of Hotel IDs to fetch loops for (e.g., 1085,2144)
  • API_BASE_URL: Base URL for external APIs

Usage

  • Development Mode (with hot reload):
    npm run dev
    
  • Start Production:
    npm start
    
  • Run Tests:
    npm test
    

Project Structure

  • src/config: Configuration loading
  • src/db: Database connection and schema initialization
  • src/services: Business logic for fetching and saving data
  • src/utils: Helpers (Logger, HTTP client with retry/delay)
  • src/scripts: Main entry point

Troubleshooting

  • Database Locks: If you encounter SQLITE_BUSY, ensure no other process (like a DB viewer) has the file open. The app handles some concurrency but file locks can block it.
  • API Timeouts: If the API is slow, the app is configured with a 100s timeout and 2 retries. Check your network connection.
  • Logs: Check logs/ directory for daily application logs and error snapshots.