Files
Web_BLS_SQL_Temp/temporary_project_management
XuJiacheng a4763b5e30 feat: 初始化临时项目管理项目结构及核心功能
- 新增项目根目录及配置文件,包括 .gitignore、.env.example 和 package.json
- 实现数据库连接池、配置加载、日志记录和 HTTP 客户端工具
- 添加数据服务层,支持酒店、房间、房型和回路数据的批量事务处理
- 创建主脚本,实现分阶段数据获取、处理和存储流程
- 提供数据库初始化脚本和测试用例
- 添加项目文档,包括 README.md 和项目需求说明
2026-02-02 09:10:53 +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.