@ttkit/daily-hot-api 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/.env.example +77 -0
  2. package/LICENSE +21 -0
  3. package/README.md +317 -2
  4. package/bin/daily-hot-api.js +25 -0
  5. package/dist/app.controller.d.ts +41 -0
  6. package/dist/app.controller.js +91 -0
  7. package/dist/app.controller.js.map +1 -0
  8. package/dist/app.module.d.ts +4 -0
  9. package/dist/app.module.js +44 -0
  10. package/dist/app.module.js.map +1 -0
  11. package/dist/app.service.d.ts +19 -0
  12. package/dist/app.service.js +57 -0
  13. package/dist/app.service.js.map +1 -0
  14. package/dist/cache/cache.module.d.ts +2 -0
  15. package/dist/cache/cache.module.js +52 -0
  16. package/dist/cache/cache.module.js.map +1 -0
  17. package/dist/cache/cache.service.d.ts +26 -0
  18. package/dist/cache/cache.service.js +163 -0
  19. package/dist/cache/cache.service.js.map +1 -0
  20. package/dist/cli/args.d.ts +24 -0
  21. package/dist/cli/args.js +261 -0
  22. package/dist/cli/args.js.map +1 -0
  23. package/dist/cli/commands/logs.d.ts +3 -0
  24. package/dist/cli/commands/logs.js +55 -0
  25. package/dist/cli/commands/logs.js.map +1 -0
  26. package/dist/cli/commands/restart.d.ts +3 -0
  27. package/dist/cli/commands/restart.js +62 -0
  28. package/dist/cli/commands/restart.js.map +1 -0
  29. package/dist/cli/commands/start.d.ts +3 -0
  30. package/dist/cli/commands/start.js +280 -0
  31. package/dist/cli/commands/start.js.map +1 -0
  32. package/dist/cli/commands/status.d.ts +3 -0
  33. package/dist/cli/commands/status.js +78 -0
  34. package/dist/cli/commands/status.js.map +1 -0
  35. package/dist/cli/commands/stop.d.ts +12 -0
  36. package/dist/cli/commands/stop.js +135 -0
  37. package/dist/cli/commands/stop.js.map +1 -0
  38. package/dist/cli/context.d.ts +4 -0
  39. package/dist/cli/context.js +3 -0
  40. package/dist/cli/context.js.map +1 -0
  41. package/dist/cli/env.d.ts +2 -0
  42. package/dist/cli/env.js +80 -0
  43. package/dist/cli/env.js.map +1 -0
  44. package/dist/cli/errors.d.ts +14 -0
  45. package/dist/cli/errors.js +25 -0
  46. package/dist/cli/errors.js.map +1 -0
  47. package/dist/cli/health.d.ts +2 -0
  48. package/dist/cli/health.js +44 -0
  49. package/dist/cli/health.js.map +1 -0
  50. package/dist/cli/help.d.ts +3 -0
  51. package/dist/cli/help.js +158 -0
  52. package/dist/cli/help.js.map +1 -0
  53. package/dist/cli/index.d.ts +2 -0
  54. package/dist/cli/index.js +94 -0
  55. package/dist/cli/index.js.map +1 -0
  56. package/dist/cli/log-file.d.ts +8 -0
  57. package/dist/cli/log-file.js +58 -0
  58. package/dist/cli/log-file.js.map +1 -0
  59. package/dist/cli/output.d.ts +7 -0
  60. package/dist/cli/output.js +46 -0
  61. package/dist/cli/output.js.map +1 -0
  62. package/dist/cli/paths.d.ts +33 -0
  63. package/dist/cli/paths.js +76 -0
  64. package/dist/cli/paths.js.map +1 -0
  65. package/dist/cli/run-state.d.ts +25 -0
  66. package/dist/cli/run-state.js +159 -0
  67. package/dist/cli/run-state.js.map +1 -0
  68. package/dist/common/middlewares/logger.middleware.d.ts +7 -0
  69. package/dist/common/middlewares/logger.middleware.js +29 -0
  70. package/dist/common/middlewares/logger.middleware.js.map +1 -0
  71. package/dist/config/config.module.d.ts +2 -0
  72. package/dist/config/config.module.js +47 -0
  73. package/dist/config/config.module.js.map +1 -0
  74. package/dist/config/configuration.d.ts +3 -0
  75. package/dist/config/configuration.js +5 -0
  76. package/dist/config/configuration.js.map +1 -0
  77. package/dist/config/validation.schema.d.ts +114 -0
  78. package/dist/config/validation.schema.js +69 -0
  79. package/dist/config/validation.schema.js.map +1 -0
  80. package/dist/daily-brief/clients/ai-analysis.client.d.ts +20 -0
  81. package/dist/daily-brief/clients/ai-analysis.client.js +217 -0
  82. package/dist/daily-brief/clients/ai-analysis.client.js.map +1 -0
  83. package/dist/daily-brief/clients/brief-search.service.d.ts +11 -0
  84. package/dist/daily-brief/clients/brief-search.service.js +52 -0
  85. package/dist/daily-brief/clients/brief-search.service.js.map +1 -0
  86. package/dist/daily-brief/clients/deepseek-search.client.d.ts +11 -0
  87. package/dist/daily-brief/clients/deepseek-search.client.js +70 -0
  88. package/dist/daily-brief/clients/deepseek-search.client.js.map +1 -0
  89. package/dist/daily-brief/clients/tavily-search.client.d.ts +11 -0
  90. package/dist/daily-brief/clients/tavily-search.client.js +72 -0
  91. package/dist/daily-brief/clients/tavily-search.client.js.map +1 -0
  92. package/dist/daily-brief/daily-brief.config.d.ts +31 -0
  93. package/dist/daily-brief/daily-brief.config.js +108 -0
  94. package/dist/daily-brief/daily-brief.config.js.map +1 -0
  95. package/dist/daily-brief/daily-brief.controller.d.ts +72 -0
  96. package/dist/daily-brief/daily-brief.controller.js +169 -0
  97. package/dist/daily-brief/daily-brief.controller.js.map +1 -0
  98. package/dist/daily-brief/daily-brief.module.d.ts +2 -0
  99. package/dist/daily-brief/daily-brief.module.js +49 -0
  100. package/dist/daily-brief/daily-brief.module.js.map +1 -0
  101. package/dist/daily-brief/daily-brief.scheduler.d.ts +30 -0
  102. package/dist/daily-brief/daily-brief.scheduler.js +113 -0
  103. package/dist/daily-brief/daily-brief.scheduler.js.map +1 -0
  104. package/dist/daily-brief/daily-brief.service.d.ts +101 -0
  105. package/dist/daily-brief/daily-brief.service.js +412 -0
  106. package/dist/daily-brief/daily-brief.service.js.map +1 -0
  107. package/dist/daily-brief/dto/brief-date-param.dto.d.ts +3 -0
  108. package/dist/daily-brief/dto/brief-date-param.dto.js +23 -0
  109. package/dist/daily-brief/dto/brief-date-param.dto.js.map +1 -0
  110. package/dist/daily-brief/dto/generate-brief.dto.d.ts +6 -0
  111. package/dist/daily-brief/dto/generate-brief.dto.js +39 -0
  112. package/dist/daily-brief/dto/generate-brief.dto.js.map +1 -0
  113. package/dist/daily-brief/dto/list-briefs-query.dto.d.ts +6 -0
  114. package/dist/daily-brief/dto/list-briefs-query.dto.js +42 -0
  115. package/dist/daily-brief/dto/list-briefs-query.dto.js.map +1 -0
  116. package/dist/daily-brief/dto/stock-ranking-query.dto.d.ts +6 -0
  117. package/dist/daily-brief/dto/stock-ranking-query.dto.js +46 -0
  118. package/dist/daily-brief/dto/stock-ranking-query.dto.js.map +1 -0
  119. package/dist/daily-brief/interfaces/daily-brief.interface.d.ts +59 -0
  120. package/dist/daily-brief/interfaces/daily-brief.interface.js +3 -0
  121. package/dist/daily-brief/interfaces/daily-brief.interface.js.map +1 -0
  122. package/dist/daily-brief/interfaces/search-provider.interface.d.ts +11 -0
  123. package/dist/daily-brief/interfaces/search-provider.interface.js +3 -0
  124. package/dist/daily-brief/interfaces/search-provider.interface.js.map +1 -0
  125. package/dist/daily-brief/utils/brief-date.d.ts +2 -0
  126. package/dist/daily-brief/utils/brief-date.js +16 -0
  127. package/dist/daily-brief/utils/brief-date.js.map +1 -0
  128. package/dist/daily-brief/utils/concurrency.d.ts +1 -0
  129. package/dist/daily-brief/utils/concurrency.js +20 -0
  130. package/dist/daily-brief/utils/concurrency.js.map +1 -0
  131. package/dist/database/database.module.d.ts +2 -0
  132. package/dist/database/database.module.js +57 -0
  133. package/dist/database/database.module.js.map +1 -0
  134. package/dist/database/repositories/daily-brief.repository.d.ts +96 -0
  135. package/dist/database/repositories/daily-brief.repository.js +457 -0
  136. package/dist/database/repositories/daily-brief.repository.js.map +1 -0
  137. package/dist/database/repositories/hot-item.repository.d.ts +52 -0
  138. package/dist/database/repositories/hot-item.repository.js +255 -0
  139. package/dist/database/repositories/hot-item.repository.js.map +1 -0
  140. package/dist/database/repositories/source-config.repository.d.ts +15 -0
  141. package/dist/database/repositories/source-config.repository.js +77 -0
  142. package/dist/database/repositories/source-config.repository.js.map +1 -0
  143. package/dist/database/schemas/daily-brief.schema.d.ts +30 -0
  144. package/dist/database/schemas/daily-brief.schema.js +103 -0
  145. package/dist/database/schemas/daily-brief.schema.js.map +1 -0
  146. package/dist/database/schemas/hot-item.schema.d.ts +20 -0
  147. package/dist/database/schemas/hot-item.schema.js +72 -0
  148. package/dist/database/schemas/hot-item.schema.js.map +1 -0
  149. package/dist/database/schemas/source-config.schema.d.ts +15 -0
  150. package/dist/database/schemas/source-config.schema.js +47 -0
  151. package/dist/database/schemas/source-config.schema.js.map +1 -0
  152. package/dist/history/dto/history-response.dto.d.ts +17 -0
  153. package/dist/history/dto/history-response.dto.js +13 -0
  154. package/dist/history/dto/history-response.dto.js.map +1 -0
  155. package/dist/history/dto/search-history.dto.d.ts +10 -0
  156. package/dist/history/dto/search-history.dto.js +72 -0
  157. package/dist/history/dto/search-history.dto.js.map +1 -0
  158. package/dist/history/history.controller.d.ts +13 -0
  159. package/dist/history/history.controller.js +92 -0
  160. package/dist/history/history.controller.js.map +1 -0
  161. package/dist/history/history.module.d.ts +2 -0
  162. package/dist/history/history.module.js +25 -0
  163. package/dist/history/history.module.js.map +1 -0
  164. package/dist/history/history.service.d.ts +15 -0
  165. package/dist/history/history.service.js +68 -0
  166. package/dist/history/history.service.js.map +1 -0
  167. package/dist/host-lists/decorators/hot-source.decorator.d.ts +9 -0
  168. package/dist/host-lists/decorators/hot-source.decorator.js +11 -0
  169. package/dist/host-lists/decorators/hot-source.decorator.js.map +1 -0
  170. package/dist/host-lists/dto/hot-list.dto.d.ts +14 -0
  171. package/dist/host-lists/dto/hot-list.dto.js +94 -0
  172. package/dist/host-lists/dto/hot-list.dto.js.map +1 -0
  173. package/dist/host-lists/hot-lists.controller.d.ts +39 -0
  174. package/dist/host-lists/hot-lists.controller.js +87 -0
  175. package/dist/host-lists/hot-lists.controller.js.map +1 -0
  176. package/dist/host-lists/hot-lists.module.d.ts +2 -0
  177. package/dist/host-lists/hot-lists.module.js +36 -0
  178. package/dist/host-lists/hot-lists.module.js.map +1 -0
  179. package/dist/host-lists/hot-lists.service.d.ts +21 -0
  180. package/dist/host-lists/hot-lists.service.js +115 -0
  181. package/dist/host-lists/hot-lists.service.js.map +1 -0
  182. package/dist/host-lists/interfaces/hot-list-source.interface.d.ts +5 -0
  183. package/dist/host-lists/interfaces/hot-list-source.interface.js +3 -0
  184. package/dist/host-lists/interfaces/hot-list-source.interface.js.map +1 -0
  185. package/dist/host-lists/interfaces/hot-list.interface.d.ts +31 -0
  186. package/dist/host-lists/interfaces/hot-list.interface.js +3 -0
  187. package/dist/host-lists/interfaces/hot-list.interface.js.map +1 -0
  188. package/dist/host-lists/interfaces/router-data.interface.d.ts +19 -0
  189. package/dist/host-lists/interfaces/router-data.interface.js +3 -0
  190. package/dist/host-lists/interfaces/router-data.interface.js.map +1 -0
  191. package/dist/host-lists/sources/36kr.source.d.ts +9 -0
  192. package/dist/host-lists/sources/36kr.source.js +89 -0
  193. package/dist/host-lists/sources/36kr.source.js.map +1 -0
  194. package/dist/host-lists/sources/51cto.source.d.ts +11 -0
  195. package/dist/host-lists/sources/51cto.source.js +71 -0
  196. package/dist/host-lists/sources/51cto.source.js.map +1 -0
  197. package/dist/host-lists/sources/52pojie.source.d.ts +9 -0
  198. package/dist/host-lists/sources/52pojie.source.js +109 -0
  199. package/dist/host-lists/sources/52pojie.source.js.map +1 -0
  200. package/dist/host-lists/sources/acfun.source.d.ts +9 -0
  201. package/dist/host-lists/sources/acfun.source.js +90 -0
  202. package/dist/host-lists/sources/acfun.source.js.map +1 -0
  203. package/dist/host-lists/sources/baidu.source.d.ts +9 -0
  204. package/dist/host-lists/sources/baidu.source.js +85 -0
  205. package/dist/host-lists/sources/baidu.source.js.map +1 -0
  206. package/dist/host-lists/sources/bilibili.source.d.ts +14 -0
  207. package/dist/host-lists/sources/bilibili.source.js +188 -0
  208. package/dist/host-lists/sources/bilibili.source.js.map +1 -0
  209. package/dist/host-lists/sources/caixin.source.d.ts +9 -0
  210. package/dist/host-lists/sources/caixin.source.js +102 -0
  211. package/dist/host-lists/sources/caixin.source.js.map +1 -0
  212. package/dist/host-lists/sources/cls.source.d.ts +9 -0
  213. package/dist/host-lists/sources/cls.source.js +62 -0
  214. package/dist/host-lists/sources/cls.source.js.map +1 -0
  215. package/dist/host-lists/sources/coolapk.source.d.ts +9 -0
  216. package/dist/host-lists/sources/coolapk.source.js +57 -0
  217. package/dist/host-lists/sources/coolapk.source.js.map +1 -0
  218. package/dist/host-lists/sources/csdn.source.d.ts +9 -0
  219. package/dist/host-lists/sources/csdn.source.js +59 -0
  220. package/dist/host-lists/sources/csdn.source.js.map +1 -0
  221. package/dist/host-lists/sources/dgtle.source.d.ts +9 -0
  222. package/dist/host-lists/sources/dgtle.source.js +57 -0
  223. package/dist/host-lists/sources/dgtle.source.js.map +1 -0
  224. package/dist/host-lists/sources/douban-group.source.d.ts +11 -0
  225. package/dist/host-lists/sources/douban-group.source.js +100 -0
  226. package/dist/host-lists/sources/douban-group.source.js.map +1 -0
  227. package/dist/host-lists/sources/douban-movie.source.d.ts +10 -0
  228. package/dist/host-lists/sources/douban-movie.source.js +103 -0
  229. package/dist/host-lists/sources/douban-movie.source.js.map +1 -0
  230. package/dist/host-lists/sources/douyin.d.ts +16 -0
  231. package/dist/host-lists/sources/douyin.js +215 -0
  232. package/dist/host-lists/sources/douyin.js.map +1 -0
  233. package/dist/host-lists/sources/eastmoney-stock.source.d.ts +11 -0
  234. package/dist/host-lists/sources/eastmoney-stock.source.js +151 -0
  235. package/dist/host-lists/sources/eastmoney-stock.source.js.map +1 -0
  236. package/dist/host-lists/sources/eastmoney.source.d.ts +9 -0
  237. package/dist/host-lists/sources/eastmoney.source.js +86 -0
  238. package/dist/host-lists/sources/eastmoney.source.js.map +1 -0
  239. package/dist/host-lists/sources/geekpark.source.d.ts +9 -0
  240. package/dist/host-lists/sources/geekpark.source.js +60 -0
  241. package/dist/host-lists/sources/geekpark.source.js.map +1 -0
  242. package/dist/host-lists/sources/gelonghui.source.d.ts +9 -0
  243. package/dist/host-lists/sources/gelonghui.source.js +139 -0
  244. package/dist/host-lists/sources/gelonghui.source.js.map +1 -0
  245. package/dist/host-lists/sources/github.source.d.ts +12 -0
  246. package/dist/host-lists/sources/github.source.js +171 -0
  247. package/dist/host-lists/sources/github.source.js.map +1 -0
  248. package/dist/host-lists/sources/guokr.source.d.ts +11 -0
  249. package/dist/host-lists/sources/guokr.source.js +98 -0
  250. package/dist/host-lists/sources/guokr.source.js.map +1 -0
  251. package/dist/host-lists/sources/hackernews.source.d.ts +11 -0
  252. package/dist/host-lists/sources/hackernews.source.js +121 -0
  253. package/dist/host-lists/sources/hackernews.source.js.map +1 -0
  254. package/dist/host-lists/sources/hellogithub.source.d.ts +11 -0
  255. package/dist/host-lists/sources/hellogithub.source.js +98 -0
  256. package/dist/host-lists/sources/hellogithub.source.js.map +1 -0
  257. package/dist/host-lists/sources/history.source.d.ts +11 -0
  258. package/dist/host-lists/sources/history.source.js +92 -0
  259. package/dist/host-lists/sources/history.source.js.map +1 -0
  260. package/dist/host-lists/sources/honkai.source.d.ts +9 -0
  261. package/dist/host-lists/sources/honkai.source.js +72 -0
  262. package/dist/host-lists/sources/honkai.source.js.map +1 -0
  263. package/dist/host-lists/sources/hostloc.source.d.ts +9 -0
  264. package/dist/host-lists/sources/hostloc.source.js +75 -0
  265. package/dist/host-lists/sources/hostloc.source.js.map +1 -0
  266. package/dist/host-lists/sources/hupu.source.d.ts +9 -0
  267. package/dist/host-lists/sources/hupu.source.js +73 -0
  268. package/dist/host-lists/sources/hupu.source.js.map +1 -0
  269. package/dist/host-lists/sources/huxiu.source.d.ts +9 -0
  270. package/dist/host-lists/sources/huxiu.source.js +153 -0
  271. package/dist/host-lists/sources/huxiu.source.js.map +1 -0
  272. package/dist/host-lists/sources/ifanr.source.d.ts +9 -0
  273. package/dist/host-lists/sources/ifanr.source.js +57 -0
  274. package/dist/host-lists/sources/ifanr.source.js.map +1 -0
  275. package/dist/host-lists/sources/index.d.ts +2 -0
  276. package/dist/host-lists/sources/index.js +134 -0
  277. package/dist/host-lists/sources/index.js.map +1 -0
  278. package/dist/host-lists/sources/ithome-xijiayi.source.d.ts +9 -0
  279. package/dist/host-lists/sources/ithome-xijiayi.source.js +75 -0
  280. package/dist/host-lists/sources/ithome-xijiayi.source.js.map +1 -0
  281. package/dist/host-lists/sources/ithome.source.d.ts +9 -0
  282. package/dist/host-lists/sources/ithome.source.js +71 -0
  283. package/dist/host-lists/sources/ithome.source.js.map +1 -0
  284. package/dist/host-lists/sources/jd.source.d.ts +9 -0
  285. package/dist/host-lists/sources/jd.source.js +82 -0
  286. package/dist/host-lists/sources/jd.source.js.map +1 -0
  287. package/dist/host-lists/sources/jianshu.source.d.ts +9 -0
  288. package/dist/host-lists/sources/jianshu.source.js +72 -0
  289. package/dist/host-lists/sources/jianshu.source.js.map +1 -0
  290. package/dist/host-lists/sources/jin10.source.d.ts +9 -0
  291. package/dist/host-lists/sources/jin10.source.js +63 -0
  292. package/dist/host-lists/sources/jin10.source.js.map +1 -0
  293. package/dist/host-lists/sources/juejin.source.d.ts +10 -0
  294. package/dist/host-lists/sources/juejin.source.js +81 -0
  295. package/dist/host-lists/sources/juejin.source.js.map +1 -0
  296. package/dist/host-lists/sources/kuaishou.source.d.ts +13 -0
  297. package/dist/host-lists/sources/kuaishou.source.js +179 -0
  298. package/dist/host-lists/sources/kuaishou.source.js.map +1 -0
  299. package/dist/host-lists/sources/linuxdo.source.d.ts +9 -0
  300. package/dist/host-lists/sources/linuxdo.source.js +62 -0
  301. package/dist/host-lists/sources/linuxdo.source.js.map +1 -0
  302. package/dist/host-lists/sources/lol.source.d.ts +9 -0
  303. package/dist/host-lists/sources/lol.source.js +58 -0
  304. package/dist/host-lists/sources/lol.source.js.map +1 -0
  305. package/dist/host-lists/sources/miyoushe.source.d.ts +9 -0
  306. package/dist/host-lists/sources/miyoushe.source.js +88 -0
  307. package/dist/host-lists/sources/miyoushe.source.js.map +1 -0
  308. package/dist/host-lists/sources/netease-news.source.d.ts +9 -0
  309. package/dist/host-lists/sources/netease-news.source.js +56 -0
  310. package/dist/host-lists/sources/netease-news.source.js.map +1 -0
  311. package/dist/host-lists/sources/ngabbs.source.d.ts +9 -0
  312. package/dist/host-lists/sources/ngabbs.source.js +70 -0
  313. package/dist/host-lists/sources/ngabbs.source.js.map +1 -0
  314. package/dist/host-lists/sources/nodeseek.source.d.ts +9 -0
  315. package/dist/host-lists/sources/nodeseek.source.js +62 -0
  316. package/dist/host-lists/sources/nodeseek.source.js.map +1 -0
  317. package/dist/host-lists/sources/nytimes.source.d.ts +9 -0
  318. package/dist/host-lists/sources/nytimes.source.js +77 -0
  319. package/dist/host-lists/sources/nytimes.source.js.map +1 -0
  320. package/dist/host-lists/sources/producthunt.source.d.ts +9 -0
  321. package/dist/host-lists/sources/producthunt.source.js +75 -0
  322. package/dist/host-lists/sources/producthunt.source.js.map +1 -0
  323. package/dist/host-lists/sources/qq-news.source.d.ts +9 -0
  324. package/dist/host-lists/sources/qq-news.source.js +53 -0
  325. package/dist/host-lists/sources/qq-news.source.js.map +1 -0
  326. package/dist/host-lists/sources/sina-news.source.d.ts +9 -0
  327. package/dist/host-lists/sources/sina-news.source.js +98 -0
  328. package/dist/host-lists/sources/sina-news.source.js.map +1 -0
  329. package/dist/host-lists/sources/sina.source.d.ts +9 -0
  330. package/dist/host-lists/sources/sina.source.js +78 -0
  331. package/dist/host-lists/sources/sina.source.js.map +1 -0
  332. package/dist/host-lists/sources/smzdm.source.d.ts +9 -0
  333. package/dist/host-lists/sources/smzdm.source.js +71 -0
  334. package/dist/host-lists/sources/smzdm.source.js.map +1 -0
  335. package/dist/host-lists/sources/sspai.source.d.ts +9 -0
  336. package/dist/host-lists/sources/sspai.source.js +69 -0
  337. package/dist/host-lists/sources/sspai.source.js.map +1 -0
  338. package/dist/host-lists/sources/starrail.source.d.ts +9 -0
  339. package/dist/host-lists/sources/starrail.source.js +72 -0
  340. package/dist/host-lists/sources/starrail.source.js.map +1 -0
  341. package/dist/host-lists/sources/taobao.source.d.ts +10 -0
  342. package/dist/host-lists/sources/taobao.source.js +169 -0
  343. package/dist/host-lists/sources/taobao.source.js.map +1 -0
  344. package/dist/host-lists/sources/thepaper.source.d.ts +9 -0
  345. package/dist/host-lists/sources/thepaper.source.js +56 -0
  346. package/dist/host-lists/sources/thepaper.source.js.map +1 -0
  347. package/dist/host-lists/sources/tieba.source.d.ts +9 -0
  348. package/dist/host-lists/sources/tieba.source.js +58 -0
  349. package/dist/host-lists/sources/tieba.source.js.map +1 -0
  350. package/dist/host-lists/sources/tonghuashun.source.d.ts +9 -0
  351. package/dist/host-lists/sources/tonghuashun.source.js +112 -0
  352. package/dist/host-lists/sources/tonghuashun.source.js.map +1 -0
  353. package/dist/host-lists/sources/toutiao.source.d.ts +9 -0
  354. package/dist/host-lists/sources/toutiao.source.js +56 -0
  355. package/dist/host-lists/sources/toutiao.source.js.map +1 -0
  356. package/dist/host-lists/sources/v2ex.source.d.ts +9 -0
  357. package/dist/host-lists/sources/v2ex.source.js +67 -0
  358. package/dist/host-lists/sources/v2ex.source.js.map +1 -0
  359. package/dist/host-lists/sources/wallstreet.source.d.ts +9 -0
  360. package/dist/host-lists/sources/wallstreet.source.js +59 -0
  361. package/dist/host-lists/sources/wallstreet.source.js.map +1 -0
  362. package/dist/host-lists/sources/weatheralarm.source.d.ts +9 -0
  363. package/dist/host-lists/sources/weatheralarm.source.js +68 -0
  364. package/dist/host-lists/sources/weatheralarm.source.js.map +1 -0
  365. package/dist/host-lists/sources/weibo.source.d.ts +15 -0
  366. package/dist/host-lists/sources/weibo.source.js +180 -0
  367. package/dist/host-lists/sources/weibo.source.js.map +1 -0
  368. package/dist/host-lists/sources/weread.source.d.ts +9 -0
  369. package/dist/host-lists/sources/weread.source.js +82 -0
  370. package/dist/host-lists/sources/weread.source.js.map +1 -0
  371. package/dist/host-lists/sources/xinyu.source.d.ts +9 -0
  372. package/dist/host-lists/sources/xinyu.source.js +151 -0
  373. package/dist/host-lists/sources/xinyu.source.js.map +1 -0
  374. package/dist/host-lists/sources/yicai.source.d.ts +9 -0
  375. package/dist/host-lists/sources/yicai.source.js +113 -0
  376. package/dist/host-lists/sources/yicai.source.js.map +1 -0
  377. package/dist/host-lists/sources/yystv.source.d.ts +9 -0
  378. package/dist/host-lists/sources/yystv.source.js +57 -0
  379. package/dist/host-lists/sources/yystv.source.js.map +1 -0
  380. package/dist/host-lists/sources/zhihu-daily.source.d.ts +9 -0
  381. package/dist/host-lists/sources/zhihu-daily.source.js +60 -0
  382. package/dist/host-lists/sources/zhihu-daily.source.js.map +1 -0
  383. package/dist/host-lists/sources/zhihu.source.d.ts +12 -0
  384. package/dist/host-lists/sources/zhihu.source.js +195 -0
  385. package/dist/host-lists/sources/zhihu.source.js.map +1 -0
  386. package/dist/http/http.module.d.ts +2 -0
  387. package/dist/http/http.module.js +30 -0
  388. package/dist/http/http.module.js.map +1 -0
  389. package/dist/http/http.service.d.ts +53 -0
  390. package/dist/http/http.service.js +277 -0
  391. package/dist/http/http.service.js.map +1 -0
  392. package/dist/main.d.ts +3 -0
  393. package/dist/main.js +70 -0
  394. package/dist/main.js.map +1 -0
  395. package/dist/rss/rss.module.d.ts +2 -0
  396. package/dist/rss/rss.module.js +21 -0
  397. package/dist/rss/rss.module.js.map +1 -0
  398. package/dist/rss/rss.service.d.ts +5 -0
  399. package/dist/rss/rss.service.js +55 -0
  400. package/dist/rss/rss.service.js.map +1 -0
  401. package/dist/scheduler/dto/trigger-fetch.dto.d.ts +3 -0
  402. package/dist/scheduler/dto/trigger-fetch.dto.js +22 -0
  403. package/dist/scheduler/dto/trigger-fetch.dto.js.map +1 -0
  404. package/dist/scheduler/dto/update-source-config.dto.d.ts +4 -0
  405. package/dist/scheduler/dto/update-source-config.dto.js +29 -0
  406. package/dist/scheduler/dto/update-source-config.dto.js.map +1 -0
  407. package/dist/scheduler/scheduler.controller.d.ts +52 -0
  408. package/dist/scheduler/scheduler.controller.js +132 -0
  409. package/dist/scheduler/scheduler.controller.js.map +1 -0
  410. package/dist/scheduler/scheduler.module.d.ts +2 -0
  411. package/dist/scheduler/scheduler.module.js +34 -0
  412. package/dist/scheduler/scheduler.module.js.map +1 -0
  413. package/dist/scheduler/scheduler.service.d.ts +54 -0
  414. package/dist/scheduler/scheduler.service.js +238 -0
  415. package/dist/scheduler/scheduler.service.js.map +1 -0
  416. package/dist/scheduler/tasks/fetch-hot-data.task.d.ts +34 -0
  417. package/dist/scheduler/tasks/fetch-hot-data.task.js +175 -0
  418. package/dist/scheduler/tasks/fetch-hot-data.task.js.map +1 -0
  419. package/dist/token/coolapk.d.ts +11 -0
  420. package/dist/token/coolapk.js +40 -0
  421. package/dist/token/coolapk.js.map +1 -0
  422. package/dist/token/token.module.d.ts +2 -0
  423. package/dist/token/token.module.js +23 -0
  424. package/dist/token/token.module.js.map +1 -0
  425. package/dist/token/token.service.d.ts +19 -0
  426. package/dist/token/token.service.js +115 -0
  427. package/dist/token/token.service.js.map +1 -0
  428. package/dist/token/tools.d.ts +1 -0
  429. package/dist/token/tools.js +15 -0
  430. package/dist/token/tools.js.map +1 -0
  431. package/dist/token/weread.d.ts +2 -0
  432. package/dist/token/weread.js +55 -0
  433. package/dist/token/weread.js.map +1 -0
  434. package/dist/utils/getNum.d.ts +1 -0
  435. package/dist/utils/getNum.js +20 -0
  436. package/dist/utils/getNum.js.map +1 -0
  437. package/dist/utils/getTime.d.ts +11 -0
  438. package/dist/utils/getTime.js +134 -0
  439. package/dist/utils/getTime.js.map +1 -0
  440. package/dist/utils/headers.d.ts +16 -0
  441. package/dist/utils/headers.js +20 -0
  442. package/dist/utils/headers.js.map +1 -0
  443. package/dist/utils/index.d.ts +1 -0
  444. package/dist/utils/index.js +12 -0
  445. package/dist/utils/index.js.map +1 -0
  446. package/dist/utils/parseRSS.d.ts +11 -0
  447. package/dist/utils/parseRSS.js +47 -0
  448. package/dist/utils/parseRSS.js.map +1 -0
  449. package/package.json +148 -4
  450. package/views/home.hbs +65 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logsCommand = logsCommand;
4
+ const fs_1 = require("fs");
5
+ const promises_1 = require("fs/promises");
6
+ const errors_1 = require("../errors");
7
+ const log_file_1 = require("../log-file");
8
+ const output_1 = require("../output");
9
+ const paths_1 = require("../paths");
10
+ const FOLLOW_INTERVAL_MS = 500;
11
+ async function logsCommand(options, context = {}) {
12
+ const cwd = context.cwd ?? process.cwd();
13
+ const env = context.env ?? process.env;
14
+ const homeDir = (0, paths_1.resolveHomeDir)({ home: options.home, cwd, env });
15
+ const paths = (0, paths_1.buildCliPaths)(homeDir);
16
+ if (!(0, fs_1.existsSync)(paths.logFile)) {
17
+ (0, output_1.fail)(`日志文件不存在: ${paths.logFile}`);
18
+ (0, output_1.fail)('前台模式的标准输出直接打印在启动终端,不会写入日志文件;请使用 daily-hot-api start -d 后台启动');
19
+ return errors_1.EXIT_CODES.error;
20
+ }
21
+ const content = (0, log_file_1.tailFile)(paths.logFile, options.lines);
22
+ if (content) {
23
+ process.stdout.write(content.endsWith('\n') ? content : `${content}\n`);
24
+ }
25
+ if (!options.follow) {
26
+ return errors_1.EXIT_CODES.ok;
27
+ }
28
+ (0, output_1.progress)(`正在跟踪日志: ${paths.logFile}(按 Ctrl+C 退出)`);
29
+ let position = (await (0, promises_1.stat)(paths.logFile)).size;
30
+ const timer = setInterval(() => {
31
+ try {
32
+ const chunk = (0, log_file_1.readLogChunk)(paths.logFile, position);
33
+ position = chunk.nextPosition;
34
+ if (chunk.text) {
35
+ process.stdout.write(chunk.text);
36
+ }
37
+ }
38
+ catch {
39
+ }
40
+ }, FOLLOW_INTERVAL_MS);
41
+ const stopFollowing = () => {
42
+ clearInterval(timer);
43
+ };
44
+ process.once('SIGINT', () => {
45
+ stopFollowing();
46
+ process.stdout.write('\n');
47
+ process.exit(0);
48
+ });
49
+ process.once('SIGTERM', () => {
50
+ stopFollowing();
51
+ process.exit(0);
52
+ });
53
+ return errors_1.EXIT_CODES.ok;
54
+ }
55
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/cli/commands/logs.ts"],"names":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C;IAClD,IAAI,QAAQ,GAAG,CAAC,MAAM,IAAA,eAAI,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAA,uBAAY,EAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACpD,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC;YAC9B,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;IACH,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAEvB,MAAM,aAAa,GAAG,GAAS,EAAE;QAC/B,aAAa,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC1B,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;QAC3B,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,mBAAU,CAAC,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type CliOptions } from '../args';
2
+ import type { CommandContext } from '../context';
3
+ export declare function restartCommand(options: CliOptions, context?: Partial<CommandContext>): Promise<number>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restartCommand = restartCommand;
4
+ const args_1 = require("../args");
5
+ const errors_1 = require("../errors");
6
+ const output_1 = require("../output");
7
+ const paths_1 = require("../paths");
8
+ const run_state_1 = require("../run-state");
9
+ const start_1 = require("./start");
10
+ const stop_1 = require("./stop");
11
+ async function restartCommand(options, context = {}) {
12
+ const cwd = context.cwd ?? process.cwd();
13
+ const env = context.env ?? process.env;
14
+ const homeDir = (0, paths_1.resolveHomeDir)({ home: options.home, cwd, env });
15
+ const paths = (0, paths_1.buildCliPaths)(homeDir);
16
+ const existing = (0, run_state_1.readRunState)(paths.stateFile);
17
+ if (existing.state &&
18
+ (0, run_state_1.isProcessAlive)(existing.state.pid) &&
19
+ !(0, run_state_1.processLooksLikeService)(existing.state.pid, (0, paths_1.getPackageRoot)())) {
20
+ throw new errors_1.CliError(`运行状态文件记录的 PID ${existing.state.pid} 仍存活,但无法确认是 ${paths_1.APP_NAME} 进程。` +
21
+ `请先执行 ${paths_1.APP_NAME} stop --force 终止并清理状态文件,或手动删除 ${paths.stateFile}`);
22
+ }
23
+ const runningState = existing.state &&
24
+ (0, run_state_1.isProcessAlive)(existing.state.pid) &&
25
+ (0, run_state_1.processLooksLikeService)(existing.state.pid, (0, paths_1.getPackageRoot)())
26
+ ? existing.state
27
+ : null;
28
+ const mode = options.daemon
29
+ ? 'daemon'
30
+ : options.foreground
31
+ ? 'foreground'
32
+ : (runningState?.mode ?? 'foreground');
33
+ const port = options.port ?? runningState?.port;
34
+ const envFile = options.envFile ?? runningState?.envFile ?? undefined;
35
+ if (runningState) {
36
+ (0, output_1.info)(`正在重启热点服务(当前 PID ${runningState.pid},端口 ${runningState.port})...`);
37
+ await (0, stop_1.stopCommand)({ ...options, command: 'stop', json: false }, context);
38
+ }
39
+ else {
40
+ if (existing.state || existing.corrupt) {
41
+ (0, output_1.warn)('清理了过期运行状态');
42
+ }
43
+ (0, output_1.info)('热点服务未在运行,将直接启动');
44
+ }
45
+ const startOptions = {
46
+ ...options,
47
+ command: 'start',
48
+ commandExplicit: true,
49
+ help: false,
50
+ version: false,
51
+ json: false,
52
+ follow: false,
53
+ lines: args_1.DEFAULT_LOG_LINES,
54
+ daemon: mode === 'daemon',
55
+ foreground: false,
56
+ port,
57
+ envFile,
58
+ helpTarget: undefined,
59
+ };
60
+ return (0, start_1.startCommand)(startOptions, context);
61
+ }
62
+ //# sourceMappingURL=restart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restart.js","sourceRoot":"","sources":["../../../src/cli/commands/restart.ts"],"names":[],"mappings":";;AAmBA,wCAiEC;AApFD,kCAA6D;AAE7D,sCAAqC;AACrC,sCAAuC;AACvC,oCAKkB;AAClB,4CAKsB;AACtB,mCAAuC;AACvC,iCAAqC;AAE9B,KAAK,UAAU,cAAc,CAClC,OAAmB,EACnB,UAAmC,EAAE;IAErC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,IAAA,sBAAc,EAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,wBAAY,EAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE/C,IACE,QAAQ,CAAC,KAAK;QACd,IAAA,0BAAc,EAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC;QAClC,CAAC,IAAA,mCAAuB,EAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,IAAA,sBAAc,GAAE,CAAC,EAC9D,CAAC;QACD,MAAM,IAAI,iBAAQ,CAChB,iBAAiB,QAAQ,CAAC,KAAK,CAAC,GAAG,eAAe,gBAAQ,MAAM;YAC9D,QAAQ,gBAAQ,iCAAiC,KAAK,CAAC,SAAS,EAAE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,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,wBAAiB;QACxB,MAAM,EAAE,IAAI,KAAK,QAAQ;QACzB,UAAU,EAAE,KAAK;QACjB,IAAI;QACJ,OAAO;QACP,UAAU,EAAE,SAAS;KACtB,CAAC;IACF,OAAO,IAAA,oBAAY,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CliOptions } from '../args';
2
+ import type { CommandContext } from '../context';
3
+ export declare function startCommand(options: CliOptions, context?: Partial<CommandContext>): Promise<number>;
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.startCommand = startCommand;
37
+ const config_1 = require("@nestjs/config");
38
+ const child_process_1 = require("child_process");
39
+ const fs_1 = require("fs");
40
+ const path_1 = require("path");
41
+ const env_1 = require("../env");
42
+ const errors_1 = require("../errors");
43
+ const health_1 = require("../health");
44
+ const log_file_1 = require("../log-file");
45
+ const output_1 = require("../output");
46
+ const paths_1 = require("../paths");
47
+ const run_state_1 = require("../run-state");
48
+ async function startCommand(options, context = {}) {
49
+ const cwd = context.cwd ?? process.cwd();
50
+ const env = context.env ?? process.env;
51
+ const homeDir = (0, paths_1.resolveHomeDir)({ home: options.home, cwd, env });
52
+ const paths = (0, paths_1.buildCliPaths)(homeDir);
53
+ const envResolution = (0, paths_1.resolveEnvFile)({
54
+ cwd,
55
+ homeDir,
56
+ envFile: options.envFile,
57
+ env,
58
+ });
59
+ if (envResolution) {
60
+ (0, env_1.applyEnvFile)(envResolution.path, env);
61
+ }
62
+ const port = (0, env_1.resolvePort)(options.port, env);
63
+ env.PORT = String(port);
64
+ assertNoRunningInstance(paths);
65
+ if (await (0, run_state_1.isPortInUse)(port)) {
66
+ throw new errors_1.CliError(`端口 ${port} 已被其他进程占用,请使用 --port 指定其他端口,或先停止占用进程`);
67
+ }
68
+ const target = {
69
+ cwd,
70
+ env,
71
+ paths,
72
+ port,
73
+ envFile: envResolution?.path ?? null,
74
+ };
75
+ if (options.daemon) {
76
+ return startDaemon(target);
77
+ }
78
+ const daemonChild = env[paths_1.DAEMON_CHILD_ENV] === '1';
79
+ delete env[paths_1.DAEMON_CHILD_ENV];
80
+ return startForeground(target, daemonChild ? 'daemon' : 'foreground');
81
+ }
82
+ function ensureStateDir(homeDir) {
83
+ try {
84
+ (0, fs_1.mkdirSync)((0, path_1.join)(homeDir, 'logs'), { recursive: true });
85
+ }
86
+ catch (error) {
87
+ const reason = error instanceof Error ? error.message : String(error);
88
+ throw new errors_1.CliError(`无法创建状态目录 ${homeDir}: ${reason}。请检查 --home / DAILY_HOT_API_HOME 是否指向可写的目录`);
89
+ }
90
+ }
91
+ function assertNoRunningInstance(paths) {
92
+ const existing = (0, run_state_1.readRunState)(paths.stateFile);
93
+ if (existing.corrupt) {
94
+ (0, output_1.warn)(`运行状态文件损坏,已清理: ${paths.stateFile}`);
95
+ (0, run_state_1.clearRunState)(paths.stateFile);
96
+ return;
97
+ }
98
+ const state = existing.state;
99
+ if (!state) {
100
+ return;
101
+ }
102
+ if ((0, run_state_1.isProcessAlive)(state.pid)) {
103
+ if ((0, run_state_1.processLooksLikeService)(state.pid)) {
104
+ throw new errors_1.CliError(`热点服务已在运行(PID ${state.pid},端口 ${state.port})。如需重启请运行: ${paths_1.APP_NAME} restart`);
105
+ }
106
+ throw new errors_1.CliError(`运行状态文件记录的 PID ${state.pid} 仍存活,但无法确认是 ${paths_1.APP_NAME} 进程。` +
107
+ `请先执行 ${paths_1.APP_NAME} stop --force 终止并清理状态文件,或手动删除 ${paths.stateFile}`);
108
+ }
109
+ (0, output_1.warn)(`清理过期运行状态(PID ${state.pid} 已退出)`);
110
+ (0, run_state_1.clearRunState)(paths.stateFile, state.pid);
111
+ }
112
+ async function startForeground(target, mode) {
113
+ (0, output_1.info)(`正在启动 ${paths_1.APP_NAME}(${mode === 'daemon' ? '后台' : '前台'}模式)...`);
114
+ (0, output_1.info)(`端口: ${target.port}`);
115
+ if (target.envFile) {
116
+ (0, output_1.info)(`配置文件: ${target.envFile}`);
117
+ }
118
+ (0, output_1.info)(`状态目录: ${target.paths.homeDir}`);
119
+ const state = {
120
+ pid: process.pid,
121
+ port: target.port,
122
+ mode,
123
+ startedAt: new Date().toISOString(),
124
+ cwd: target.cwd,
125
+ envFile: target.envFile,
126
+ logFile: mode === 'daemon' ? target.paths.logFile : null,
127
+ version: (0, paths_1.getPackageVersion)(),
128
+ entry: (0, paths_1.getBinPath)(),
129
+ };
130
+ try {
131
+ (0, run_state_1.writeRunState)(target.paths.stateFile, state);
132
+ }
133
+ catch (error) {
134
+ const reason = error instanceof Error ? error.message : String(error);
135
+ throw new errors_1.CliError(`无法写入运行状态文件(状态目录不可用): ${reason}。请检查 --home / DAILY_HOT_API_HOME 是否指向可写的目录`);
136
+ }
137
+ const clearStateFile = () => {
138
+ try {
139
+ (0, run_state_1.clearRunState)(target.paths.stateFile, process.pid);
140
+ }
141
+ catch {
142
+ }
143
+ };
144
+ process.once('exit', clearStateFile);
145
+ process.once('SIGINT', clearStateFile);
146
+ process.once('SIGTERM', clearStateFile);
147
+ process.once('SIGHUP', clearStateFile);
148
+ const { bootstrap } = await Promise.resolve().then(() => __importStar(require('../../main')));
149
+ let app;
150
+ try {
151
+ app = await bootstrap();
152
+ }
153
+ catch (error) {
154
+ clearStateFile();
155
+ const reason = error instanceof Error ? error.message : String(error);
156
+ throw new errors_1.CliError(`服务启动失败: ${reason}`);
157
+ }
158
+ const config = app.get(config_1.ConfigService);
159
+ const actualPort = config.getOrThrow('PORT');
160
+ if (actualPort !== state.port) {
161
+ state.port = actualPort;
162
+ try {
163
+ (0, run_state_1.writeRunState)(target.paths.stateFile, state);
164
+ }
165
+ catch {
166
+ }
167
+ }
168
+ (0, output_1.info)(`热点服务已启动: http://localhost:${actualPort}`);
169
+ if (mode === 'daemon') {
170
+ (0, output_1.info)(`PID: ${process.pid}`);
171
+ (0, output_1.info)(`日志: ${target.paths.logFile}`);
172
+ }
173
+ else {
174
+ (0, output_1.info)(`PID: ${process.pid},按 Ctrl+C 停止服务`);
175
+ }
176
+ return errors_1.EXIT_CODES.ok;
177
+ }
178
+ async function startDaemon(target) {
179
+ ensureStateDir(target.paths.homeDir);
180
+ let logFd;
181
+ try {
182
+ logFd = (0, fs_1.openSync)(target.paths.logFile, 'a');
183
+ }
184
+ catch (error) {
185
+ const reason = error instanceof Error ? error.message : String(error);
186
+ throw new errors_1.CliError(`无法写入日志文件 ${target.paths.logFile}: ${reason}。请检查状态目录是否可写`);
187
+ }
188
+ const startedAt = new Date().toISOString();
189
+ (0, fs_1.writeSync)(logFd, `\n[${startedAt}] ${paths_1.APP_NAME} background start (port=${target.port}${target.envFile ? `, env_file=${target.envFile}` : ''})\n`);
190
+ const childArgs = [(0, paths_1.getBinPath)(), 'start', '--home', target.paths.homeDir];
191
+ if (target.envFile) {
192
+ childArgs.push('--config', target.envFile);
193
+ }
194
+ const childEnv = {
195
+ ...target.env,
196
+ PORT: String(target.port),
197
+ [paths_1.DAEMON_CHILD_ENV]: '1',
198
+ };
199
+ let child;
200
+ try {
201
+ child = (0, child_process_1.spawn)(process.execPath, childArgs, {
202
+ cwd: target.cwd,
203
+ detached: true,
204
+ stdio: ['ignore', logFd, logFd],
205
+ env: childEnv,
206
+ windowsHide: true,
207
+ });
208
+ }
209
+ catch (error) {
210
+ (0, fs_1.closeSync)(logFd);
211
+ const reason = error instanceof Error ? error.message : String(error);
212
+ throw new errors_1.CliError(`后台进程创建失败: ${reason}`);
213
+ }
214
+ (0, fs_1.closeSync)(logFd);
215
+ child.unref();
216
+ const childPid = child.pid;
217
+ if (!childPid) {
218
+ throw new errors_1.CliError('后台进程创建失败: 未返回进程 PID');
219
+ }
220
+ (0, output_1.info)(`正在后台启动 ${paths_1.APP_NAME}(PID ${childPid})...`);
221
+ const ready = await waitForDaemonReady(childPid, child, target.port, target.paths.stateFile);
222
+ if (!ready.ok) {
223
+ await terminateFailedChild(childPid, target.paths.stateFile);
224
+ const reason = ready.reason === 'timeout'
225
+ ? `等待服务就绪超时(${Math.round(paths_1.START_TIMEOUT_MS / 1000)} 秒)`
226
+ : `后台进程提前退出(退出码 ${ready.exitCode ?? 'unknown'})`;
227
+ const logTail = safeTailLog(target.paths.logFile, 30);
228
+ throw new errors_1.CliError([
229
+ `后台启动失败: ${reason}`,
230
+ `日志: ${target.paths.logFile}`,
231
+ logTail ? `最近日志:\n${logTail}` : '',
232
+ ]
233
+ .filter(Boolean)
234
+ .join('\n'));
235
+ }
236
+ (0, output_1.info)(`热点服务已在后台启动: http://localhost:${target.port}`);
237
+ (0, output_1.field)('PID', childPid);
238
+ (0, output_1.field)('日志', target.paths.logFile);
239
+ (0, output_1.info)(`停止: ${paths_1.APP_NAME} stop 状态: ${paths_1.APP_NAME} status 日志: ${paths_1.APP_NAME} logs -f`);
240
+ return errors_1.EXIT_CODES.ok;
241
+ }
242
+ async function waitForDaemonReady(pid, child, port, stateFile) {
243
+ const deadline = Date.now() + paths_1.START_TIMEOUT_MS;
244
+ while (Date.now() < deadline) {
245
+ if (!(0, run_state_1.isProcessAlive)(pid) || child.exitCode !== null) {
246
+ return { ok: false, reason: 'exited', exitCode: child.exitCode };
247
+ }
248
+ const { state } = (0, run_state_1.readRunState)(stateFile);
249
+ if (state?.pid === pid && (await (0, health_1.checkHealth)(port))) {
250
+ return { ok: true };
251
+ }
252
+ await (0, run_state_1.sleep)(paths_1.START_POLL_INTERVAL_MS);
253
+ }
254
+ return { ok: false, reason: 'timeout' };
255
+ }
256
+ async function terminateFailedChild(pid, stateFile) {
257
+ try {
258
+ process.kill(pid, 'SIGTERM');
259
+ }
260
+ catch {
261
+ }
262
+ if (!(await (0, run_state_1.waitForProcessExit)(pid, 3000))) {
263
+ try {
264
+ process.kill(pid, 'SIGKILL');
265
+ }
266
+ catch {
267
+ }
268
+ await (0, run_state_1.waitForProcessExit)(pid, 2000);
269
+ }
270
+ (0, run_state_1.clearRunState)(stateFile, pid);
271
+ }
272
+ function safeTailLog(logFile, lines) {
273
+ try {
274
+ return (0, log_file_1.tailFile)(logFile, lines);
275
+ }
276
+ catch {
277
+ return '';
278
+ }
279
+ }
280
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/cli/commands/start.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,oCA8CC;AAhGD,2CAA+C;AAC/C,iDAAyD;AACzD,2BAA+D;AAC/D,+BAA4B;AAG5B,gCAAmD;AACnD,sCAAiD;AACjD,sCAAwC;AACxC,0CAA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IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,IAAA,8BAAkB,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;QACD,MAAM,IAAA,8BAAkB,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,IAAA,yBAAa,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,OAAe,EAAE,KAAa;IACjD,IAAI,CAAC;QACH,OAAO,IAAA,mBAAQ,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CliOptions } from '../args';
2
+ import type { CommandContext } from '../context';
3
+ export declare function statusCommand(options: CliOptions, context?: Partial<CommandContext>): Promise<number>;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.statusCommand = statusCommand;
4
+ const errors_1 = require("../errors");
5
+ const health_1 = require("../health");
6
+ const output_1 = require("../output");
7
+ const paths_1 = require("../paths");
8
+ const run_state_1 = require("../run-state");
9
+ async function statusCommand(options, context = {}) {
10
+ const cwd = context.cwd ?? process.cwd();
11
+ const env = context.env ?? process.env;
12
+ const homeDir = (0, paths_1.resolveHomeDir)({ home: options.home, cwd, env });
13
+ const paths = (0, paths_1.buildCliPaths)(homeDir);
14
+ const existing = (0, run_state_1.readRunState)(paths.stateFile);
15
+ if (existing.corrupt) {
16
+ (0, run_state_1.clearRunState)(paths.stateFile);
17
+ return reportNotRunning(options.json, '运行状态文件损坏,已清理', paths);
18
+ }
19
+ const state = existing.state;
20
+ if (!state) {
21
+ return reportNotRunning(options.json, '未找到运行状态', paths);
22
+ }
23
+ if (!(0, run_state_1.isProcessAlive)(state.pid)) {
24
+ (0, run_state_1.clearRunState)(paths.stateFile, state.pid);
25
+ return reportNotRunning(options.json, `PID ${state.pid} 已退出,已清理过期状态文件`, paths);
26
+ }
27
+ if (!(0, run_state_1.processLooksLikeService)(state.pid, (0, paths_1.getPackageRoot)())) {
28
+ return reportNotRunning(options.json, `PID ${state.pid} 仍存活但无法确认是 daily-hot-api 进程,状态文件可能已过期;可执行 daily-hot-api stop --force 清理`, paths);
29
+ }
30
+ const health = await (0, health_1.checkHealth)(state.port);
31
+ const startedAtMs = Date.parse(state.startedAt);
32
+ const uptimeSeconds = Number.isFinite(startedAtMs)
33
+ ? Math.max(0, Math.floor((Date.now() - startedAtMs) / 1000))
34
+ : 0;
35
+ const url = `http://localhost:${state.port}`;
36
+ if (options.json) {
37
+ console.log(JSON.stringify({
38
+ running: true,
39
+ pid: state.pid,
40
+ port: state.port,
41
+ url,
42
+ mode: state.mode,
43
+ startedAt: state.startedAt,
44
+ uptimeSeconds,
45
+ health,
46
+ cwd: state.cwd,
47
+ envFile: state.envFile,
48
+ logFile: state.logFile,
49
+ version: state.version,
50
+ }, null, 2));
51
+ return errors_1.EXIT_CODES.ok;
52
+ }
53
+ (0, output_1.info)('热点服务运行中');
54
+ (0, output_1.field)('PID', state.pid);
55
+ (0, output_1.field)('端口', state.port);
56
+ (0, output_1.field)('地址', url);
57
+ (0, output_1.field)('模式', state.mode === 'daemon' ? '后台 (daemon)' : '前台 (foreground)');
58
+ (0, output_1.field)('启动时间', `${state.startedAt}(已运行 ${(0, output_1.formatDuration)(uptimeSeconds)})`);
59
+ (0, output_1.field)('健康检查', health ? 'ok' : '无响应(进程存在但 /health 不可达)');
60
+ if (state.envFile) {
61
+ (0, output_1.field)('配置文件', state.envFile);
62
+ }
63
+ (0, output_1.field)('运行目录', state.cwd || 'unknown');
64
+ if (state.logFile) {
65
+ (0, output_1.field)('日志文件', state.logFile);
66
+ }
67
+ return errors_1.EXIT_CODES.ok;
68
+ }
69
+ function reportNotRunning(json, reason, paths) {
70
+ if (json) {
71
+ console.log(JSON.stringify({ running: false, reason, stateFile: paths.stateFile }));
72
+ }
73
+ else {
74
+ (0, output_1.info)(`热点服务未在运行(${reason})`);
75
+ }
76
+ return errors_1.EXIT_CODES.notRunning;
77
+ }
78
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/cli/commands/status.ts"],"names":[],"mappings":";;AAkBA,sCA0FC;AA1GD,sCAAuC;AACvC,sCAAwC;AACxC,sCAAwD;AACxD,oCAKkB;AAClB,4CAKsB;AAEf,KAAK,UAAU,aAAa,CACjC,OAAmB,EACnB,UAAmC,EAAE;IAErC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,IAAA,sBAAc,EAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,wBAAY,EAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE/C,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,IAAA,yBAAa,EAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC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K,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,mBAAU,CAAC,EAAE,CAAC;AACvB,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAa,EACb,MAAc,EACd,KAAe;IAEf,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CACvE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,IAAA,aAAI,EAAC,YAAY,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,mBAAU,CAAC,UAAU,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { CliOptions } from '../args';
2
+ import type { CommandContext } from '../context';
3
+ export interface StopOutcome {
4
+ stopped: boolean;
5
+ stale: boolean;
6
+ forced: boolean;
7
+ pid?: number;
8
+ port?: number;
9
+ message: string;
10
+ }
11
+ export declare function stopCommand(options: CliOptions, context?: Partial<CommandContext>): Promise<number>;
12
+ export declare function stopService(options: CliOptions, context?: Partial<CommandContext>): Promise<StopOutcome>;