文件
jw-beauty/server
Guoguo 92416261ee feat: production readiness — feature gaps + config hardening
Miniprogram:
- Add BLE reconnect button on home page when disconnected
- Add loading states to index, profile, subscribe-plans pages
- Add profile editing (avatar + nickname) with COS upload
- Enable pull-to-refresh on history page
- Fix auto-scan self.options → self.data inconsistency
- Add console.error to silent catch blocks
- Gate 'Simple Peripheral' BLE scan behind __DEV__ flag
- Add production config comment to env.js

Admin console:
- Add empty state '暂无数据' to all 5 list views
- Replace plain text plan input with select dropdown
- Add type="date" to record date filters
- Add production config comment

Server:
- CORS origin restricted in production (env CORS_ORIGIN)
- DB pool size configurable via DB_POOL_SIZE env var
- .env.example updated with WeChat Pay + production fields
2026-05-15 09:07:41 -07:00
..

Hox 腾讯云函数后端

本目录是 Hox 项目的腾讯云后端骨架,目标架构为:腾讯云函数 SCF Node.js + 腾讯云数据库 MySQL + 腾讯云 COS。

配置

本地配置文件为 .env,不会提交到 Git。提交用模板为 .env.example

当前已按项目默认值预置:

配置
COS Bucket jw-bucket-1426323813
地域 ap-guangzhou
数据库 jw_beauty
数据库用户 root
临时后台账号 admin
临时后台密码 admin

你需要补充 .env 中的真实值:

  • TENCENT_SECRET_ID
  • TENCENT_SECRET_KEY
  • DB_HOST
  • DB_PASSWORD
  • WECHAT_APPID
  • WECHAT_SECRET
  • JWT_SECRET
  • ADMIN_JWT_SECRET

本地运行

cd server
npm install
npm run db:init
npm start

健康检查:

curl http://localhost:3000/health

SCF 入口

腾讯云函数入口:

index.main_handler

HTTP 触发器或函数 URL 需要透传:

  • HTTP method
  • path
  • headers
  • queryStringParameters
  • body

已实现接口

小程序接口:

  • POST /api/v1/auth/login
  • POST /api/v1/auth/refresh
  • GET /api/v1/user/profile
  • PUT /api/v1/user/profile
  • POST /api/v1/user/phone
  • POST /api/v1/device/bind
  • POST /api/v1/device/unbind
  • GET /api/v1/device/list
  • GET /api/v1/device/:device_id
  • GET /api/v1/device/command/pending
  • POST /api/v1/device/event
  • GET /api/v1/subscription
  • POST /api/v1/subscription/purchase
  • POST /api/v1/subscription/verify
  • GET /api/v1/treatment/history
  • POST /api/v1/treatment/sync
  • GET /api/v1/firmware/latest

管理后台接口:

  • POST /api/v1/admin/login
  • GET /api/v1/admin/dashboard
  • GET /api/v1/admin/devices
  • GET /api/v1/admin/devices/:device_id
  • POST /api/v1/admin/devices/:device_id/command
  • POST /api/v1/admin/devices/:device_id/unbind
  • GET /api/v1/admin/users
  • GET /api/v1/admin/users/:user_id
  • GET /api/v1/admin/subscriptions
  • POST /api/v1/admin/subscriptions
  • GET /api/v1/admin/records
  • GET /api/v1/admin/logs
  • GET /api/v1/admin/settings
  • POST /api/v1/admin/settings
  • GET /api/v1/admin/devices/:device_id/commands
  • GET /api/v1/admin/firmware
  • POST /api/v1/admin/firmware
  • POST /api/v1/admin/firmware/:firmware_id/status

数据库

表结构在:

sql/schema.sql

初始化脚本会创建表并插入临时管理员账号。

重要说明

  • 当前微信支付只保留接口骨架,未接入真实微信支付回调。
  • /api/v1/device/command/pending 已接入 device_commands,小程序拉取后执行 BLE 指令并回传结果。
  • /api/v1/firmware/latest 会读取 firmware_files 并生成 COS 签名 URL,后台可通过固件接口登记 COS 对象 key。
  • 生产环境必须替换 admin/admin 和所有默认 secret。