@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,238 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SchedulerService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SchedulerService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const schedule_1 = require("@nestjs/schedule");
16
+ const config_1 = require("@nestjs/config");
17
+ const hot_lists_service_1 = require("../host-lists/hot-lists.service");
18
+ const source_config_repository_1 = require("../database/repositories/source-config.repository");
19
+ const fetch_hot_data_task_1 = require("./tasks/fetch-hot-data.task");
20
+ const cron_1 = require("cron");
21
+ const crypto_1 = require("crypto");
22
+ let SchedulerService = SchedulerService_1 = class SchedulerService {
23
+ constructor(schedulerRegistry, configService, hotListsService, sourceConfigRepository, fetchHotDataTask) {
24
+ this.schedulerRegistry = schedulerRegistry;
25
+ this.configService = configService;
26
+ this.hotListsService = hotListsService;
27
+ this.sourceConfigRepository = sourceConfigRepository;
28
+ this.fetchHotDataTask = fetchHotDataTask;
29
+ this.logger = new common_1.Logger(SchedulerService_1.name);
30
+ this.isRunning = false;
31
+ this.schedulerEnabled = false;
32
+ this.cronJobName = 'hot-data-fetch';
33
+ this.ignoreSources = [];
34
+ this.runs = new Map();
35
+ this.loadIgnoreSources();
36
+ this.loadSchedulerConfig();
37
+ }
38
+ async onModuleInit() {
39
+ await this.initializeSourceConfigs();
40
+ this.setupDynamicCronJob();
41
+ }
42
+ onModuleDestroy() {
43
+ this.stopDynamicCronJob();
44
+ }
45
+ loadIgnoreSources() {
46
+ const ignoreSaveConfig = this.configService.get('IGNORE_SAVE_SOURCES');
47
+ if (ignoreSaveConfig) {
48
+ this.ignoreSources.push(...ignoreSaveConfig.split(',').map((s) => s.trim()));
49
+ this.logger.log(`Ignoring sources for saving: ${this.ignoreSources.join(', ')}`);
50
+ }
51
+ }
52
+ loadSchedulerConfig() {
53
+ const autoStart = this.configService.get('SCHEDULER_AUTO_START', true);
54
+ this.schedulerEnabled = autoStart;
55
+ this.logger.log(`Scheduler auto-start: ${autoStart ? 'enabled' : 'disabled'}`);
56
+ }
57
+ setupDynamicCronJob() {
58
+ try {
59
+ this.stopDynamicCronJob();
60
+ const cronExpression = this.configService.get('SCHEDULER_CRON_EXPRESSION', '0 */12 * * *');
61
+ this.logger.log(`cronExpression: ${cronExpression}`);
62
+ if (this.schedulerEnabled) {
63
+ const job = new cron_1.CronJob(cronExpression, () => {
64
+ void this.handleCron();
65
+ });
66
+ this.schedulerRegistry.addCronJob(this.cronJobName, job);
67
+ job.start();
68
+ this.logger.log(`Dynamic cron job setup with expression: ${cronExpression}`);
69
+ }
70
+ else {
71
+ this.logger.log('Scheduler is disabled, not starting cron job');
72
+ }
73
+ }
74
+ catch (error) {
75
+ this.logger.error('Failed to setup dynamic cron job:', error);
76
+ }
77
+ }
78
+ stopDynamicCronJob() {
79
+ try {
80
+ if (this.schedulerRegistry.doesExist('cron', this.cronJobName)) {
81
+ this.schedulerRegistry.deleteCronJob(this.cronJobName);
82
+ this.logger.log(`Stopped cron job: ${this.cronJobName}`);
83
+ }
84
+ }
85
+ catch (error) {
86
+ this.logger.error('Failed to stop cron job:', error);
87
+ }
88
+ }
89
+ shouldIgnoreSource(source) {
90
+ return this.ignoreSources.includes(source);
91
+ }
92
+ async initializeSourceConfigs() {
93
+ try {
94
+ const sources = this.hotListsService.getAllSources();
95
+ await this.sourceConfigRepository.initializeConfigs(sources);
96
+ this.logger.log(`Initialized ${sources.length} source configurations`);
97
+ }
98
+ catch (error) {
99
+ this.logger.error('Failed to initialize source configs:', error);
100
+ }
101
+ }
102
+ async handleCron() {
103
+ this.logger.log('handleCron');
104
+ if (!this.schedulerEnabled) {
105
+ return;
106
+ }
107
+ if (this.isRunning) {
108
+ this.logger.debug('Previous task still running, skipping...');
109
+ return;
110
+ }
111
+ this.isRunning = true;
112
+ try {
113
+ await this.processScheduledTasks();
114
+ }
115
+ catch (error) {
116
+ this.logger.error('Error in scheduled task:', error);
117
+ }
118
+ finally {
119
+ this.isRunning = false;
120
+ }
121
+ }
122
+ async processScheduledTasks() {
123
+ await this.initializeSourceConfigs();
124
+ const enabledConfigs = await this.sourceConfigRepository.findEnabled();
125
+ const now = Date.now();
126
+ const sources = enabledConfigs
127
+ .filter((config) => {
128
+ if (this.shouldIgnoreSource(config.source))
129
+ return false;
130
+ const interval = Number.isFinite(config.interval) && config.interval > 0
131
+ ? config.interval
132
+ : 30;
133
+ return (!config.lastFetchAt ||
134
+ config.lastFetchAt.getTime() + interval * 60_000 <= now);
135
+ })
136
+ .map((config) => config.source);
137
+ await this.fetchHotDataTask.executeBatch(sources);
138
+ }
139
+ async triggerFetch(source) {
140
+ let sources;
141
+ if (source) {
142
+ if (this.shouldIgnoreSource(source)) {
143
+ throw new common_1.BadRequestException(`Source '${source}' is ignored`);
144
+ }
145
+ if (!this.hotListsService.getAllSources().includes(source)) {
146
+ throw new common_1.NotFoundException(`Source '${source}' not found`);
147
+ }
148
+ sources = [source];
149
+ }
150
+ else {
151
+ await this.initializeSourceConfigs();
152
+ const enabledConfigs = await this.sourceConfigRepository.findEnabled();
153
+ sources = enabledConfigs
154
+ .map((config) => config.source)
155
+ .filter((name) => !this.shouldIgnoreSource(name));
156
+ }
157
+ this.pruneRuns(true);
158
+ const run = {
159
+ runId: (0, crypto_1.randomUUID)(),
160
+ status: 'running',
161
+ sourceCount: sources.length,
162
+ startedAt: new Date().toISOString(),
163
+ };
164
+ this.runs.set(run.runId, run);
165
+ void this.fetchHotDataTask.executeBatch(sources).then((results) => {
166
+ run.status = 'completed';
167
+ run.completedAt = new Date().toISOString();
168
+ run.results = results.map(({ items, ...summary }) => {
169
+ void items;
170
+ return {
171
+ ...summary,
172
+ error: summary.success ? undefined : 'Source refresh failed',
173
+ };
174
+ });
175
+ }, () => {
176
+ run.status = 'failed';
177
+ run.completedAt = new Date().toISOString();
178
+ run.error = 'Batch fetch failed';
179
+ });
180
+ return run;
181
+ }
182
+ getRun(runId) {
183
+ this.pruneRuns();
184
+ const run = this.runs.get(runId);
185
+ if (!run)
186
+ throw new common_1.NotFoundException(`Fetch run '${runId}' not found`);
187
+ return run;
188
+ }
189
+ pruneRuns(ensureCapacity = false) {
190
+ const cutoff = Date.now() - 60 * 60_000;
191
+ for (const [id, run] of this.runs) {
192
+ if (run.status !== 'running' && Date.parse(run.startedAt) < cutoff) {
193
+ this.runs.delete(id);
194
+ }
195
+ }
196
+ while (ensureCapacity && this.runs.size >= 100) {
197
+ const oldest = [...this.runs].find(([, run]) => run.status !== 'running')?.[0];
198
+ if (!oldest) {
199
+ throw new common_1.ServiceUnavailableException('Too many active fetch runs');
200
+ }
201
+ this.runs.delete(oldest);
202
+ }
203
+ }
204
+ getStatus() {
205
+ return {
206
+ isRunning: this.isRunning,
207
+ schedulerEnabled: this.schedulerEnabled,
208
+ cronJobs: this.schedulerRegistry.getCronJobs().size,
209
+ ignoreSources: this.ignoreSources,
210
+ cronExpression: this.configService.get('SCHEDULER_CRON_EXPRESSION'),
211
+ cronJobExists: this.schedulerRegistry.doesExist('cron', this.cronJobName),
212
+ };
213
+ }
214
+ start() {
215
+ this.schedulerEnabled = true;
216
+ this.setupDynamicCronJob();
217
+ this.logger.log('Scheduler enabled');
218
+ }
219
+ stop() {
220
+ this.schedulerEnabled = false;
221
+ this.stopDynamicCronJob();
222
+ this.logger.log('Scheduler disabled');
223
+ }
224
+ reconfigureCron() {
225
+ this.setupDynamicCronJob();
226
+ this.logger.log('Cron job reconfigured');
227
+ }
228
+ };
229
+ exports.SchedulerService = SchedulerService;
230
+ exports.SchedulerService = SchedulerService = SchedulerService_1 = __decorate([
231
+ (0, common_1.Injectable)(),
232
+ __metadata("design:paramtypes", [schedule_1.SchedulerRegistry,
233
+ config_1.ConfigService,
234
+ hot_lists_service_1.HotListsService,
235
+ source_config_repository_1.SourceConfigRepository,
236
+ fetch_hot_data_task_1.FetchHotDataTask])
237
+ ], SchedulerService);
238
+ //# sourceMappingURL=scheduler.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.service.js","sourceRoot":"","sources":["../../src/scheduler/scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAQwB;AACxB,+CAAqD;AACrD,2CAA+C;AAC/C,uEAAkE;AAClE,gGAA2F;AAC3F,qEAA4E;AAC5E,+BAA+B;AAC/B,mCAAoC;AAa7B,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAS3B,YACmB,iBAAoC,EACpC,aAA4B,EAC5B,eAAgC,EAChC,sBAA8C,EAC9C,gBAAkC;QAJlC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,kBAAa,GAAb,aAAa,CAAe;QAC5B,oBAAe,GAAf,eAAe,CAAiB;QAChC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,qBAAgB,GAAhB,gBAAgB,CAAkB;QAbpC,WAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;QACpD,cAAS,GAAG,KAAK,CAAC;QAClB,qBAAgB,GAAG,KAAK,CAAC;QAChB,gBAAW,GAAG,gBAAgB,CAAC;QAE/B,kBAAa,GAAa,EAAE,CAAC;QAC7B,SAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;QASlD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACrC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED,eAAe;QACb,IAAI,CAAC,kBAAkB,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ACJ,CAAC;IAGD,KAAK;QACH,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAGD,IAAI;QACF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAGD,eAAe;QACb,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AA7QY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAW2B,4BAAiB;QACrB,sBAAa;QACX,mCAAe;QACR,iDAAsB;QAC5B,sCAAgB;GAd1C,gBAAgB,CA6Q5B"}
@@ -0,0 +1,34 @@
1
+ import { BeforeApplicationShutdown } from '@nestjs/common';
2
+ import { HotListsService } from '../../host-lists/hot-lists.service';
3
+ import { HotItemRepository } from '../../database/repositories/hot-item.repository';
4
+ import { SourceConfigRepository } from '../../database/repositories/source-config.repository';
5
+ import { ConfigService } from '@nestjs/config';
6
+ import { HotListItem } from '../../host-lists/interfaces/hot-list.interface';
7
+ export interface FetchResult {
8
+ sourceName: string;
9
+ success: boolean;
10
+ duration: number;
11
+ savedCount: number;
12
+ totalCount: number;
13
+ items?: HotListItem[];
14
+ error?: string;
15
+ }
16
+ export declare class FetchHotDataTask implements BeforeApplicationShutdown {
17
+ private readonly hotListsService;
18
+ private readonly hotItemRepository;
19
+ private readonly sourceConfigRepository;
20
+ private readonly logger;
21
+ private readonly maxConcurrency;
22
+ private active;
23
+ private readonly waiters;
24
+ private readonly inFlight;
25
+ private shuttingDown;
26
+ private readonly ignoredSaveSources;
27
+ constructor(hotListsService: HotListsService, hotItemRepository: HotItemRepository, sourceConfigRepository: SourceConfigRepository, configService: ConfigService);
28
+ execute(sourceName: string): Promise<FetchResult>;
29
+ beforeApplicationShutdown(): Promise<void>;
30
+ private withSlot;
31
+ private executeSource;
32
+ executeBatch(sourceNames: string[]): Promise<FetchResult[]>;
33
+ private validateSource;
34
+ }
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var FetchHotDataTask_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.FetchHotDataTask = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const hot_lists_service_1 = require("../../host-lists/hot-lists.service");
16
+ const hot_item_repository_1 = require("../../database/repositories/hot-item.repository");
17
+ const source_config_repository_1 = require("../../database/repositories/source-config.repository");
18
+ const config_1 = require("@nestjs/config");
19
+ let FetchHotDataTask = FetchHotDataTask_1 = class FetchHotDataTask {
20
+ constructor(hotListsService, hotItemRepository, sourceConfigRepository, configService) {
21
+ this.hotListsService = hotListsService;
22
+ this.hotItemRepository = hotItemRepository;
23
+ this.sourceConfigRepository = sourceConfigRepository;
24
+ this.logger = new common_1.Logger(FetchHotDataTask_1.name);
25
+ this.maxConcurrency = 5;
26
+ this.active = 0;
27
+ this.waiters = [];
28
+ this.inFlight = new Map();
29
+ this.shuttingDown = false;
30
+ this.ignoredSaveSources = new Set((configService.get('IGNORE_SAVE_SOURCES') ?? '')
31
+ .split(',')
32
+ .map((name) => name.trim())
33
+ .filter(Boolean));
34
+ }
35
+ execute(sourceName) {
36
+ const current = this.inFlight.get(sourceName);
37
+ if (current !== undefined)
38
+ return current;
39
+ if (this.shuttingDown) {
40
+ return Promise.resolve({
41
+ sourceName,
42
+ success: false,
43
+ duration: 0,
44
+ savedCount: 0,
45
+ totalCount: 0,
46
+ error: 'Application is shutting down',
47
+ });
48
+ }
49
+ const pending = this.withSlot(() => this.executeSource(sourceName));
50
+ this.inFlight.set(sourceName, pending);
51
+ void pending.then(() => this.inFlight.delete(sourceName), () => this.inFlight.delete(sourceName));
52
+ return pending;
53
+ }
54
+ async beforeApplicationShutdown() {
55
+ this.shuttingDown = true;
56
+ if (this.inFlight.size === 0)
57
+ return;
58
+ this.logger.log(`Waiting for ${this.inFlight.size} active fetches to finish`);
59
+ let timer;
60
+ try {
61
+ await Promise.race([
62
+ Promise.allSettled([...this.inFlight.values()]),
63
+ new Promise((resolve) => {
64
+ timer = setTimeout(resolve, 30_000);
65
+ }),
66
+ ]);
67
+ }
68
+ finally {
69
+ if (timer)
70
+ clearTimeout(timer);
71
+ }
72
+ }
73
+ async withSlot(operation) {
74
+ if (this.active < this.maxConcurrency) {
75
+ this.active++;
76
+ }
77
+ else {
78
+ await new Promise((resolve) => this.waiters.push(resolve));
79
+ }
80
+ try {
81
+ return await operation();
82
+ }
83
+ finally {
84
+ const next = this.waiters.shift();
85
+ if (next)
86
+ next();
87
+ else
88
+ this.active--;
89
+ }
90
+ }
91
+ async executeSource(sourceName) {
92
+ const startTime = Date.now();
93
+ const result = {
94
+ sourceName,
95
+ success: false,
96
+ duration: 0,
97
+ savedCount: 0,
98
+ totalCount: 0,
99
+ };
100
+ try {
101
+ this.logger.log(`🚀 Starting to fetch data for source: ${sourceName}`);
102
+ if (!this.validateSource(sourceName)) {
103
+ result.error = `Source '${sourceName}' not found`;
104
+ this.logger.error(result.error);
105
+ return result;
106
+ }
107
+ const sourceConfig = await this.sourceConfigRepository.findBySource(sourceName);
108
+ if (sourceConfig && !sourceConfig.enabled) {
109
+ result.error = `Source '${sourceName}' is disabled`;
110
+ this.logger.warn(result.error);
111
+ return result;
112
+ }
113
+ const hotListData = await this.hotListsService.fetchSource(sourceName, {}, true);
114
+ if (!hotListData || !hotListData.data || hotListData.data.length === 0) {
115
+ result.error = `No data received for source: ${sourceName}`;
116
+ this.logger.warn(result.error);
117
+ return result;
118
+ }
119
+ result.totalCount = hotListData.data.length;
120
+ result.items = hotListData.data;
121
+ const savedCount = this.ignoredSaveSources.has(sourceName)
122
+ ? 0
123
+ : await this.hotItemRepository.saveHotItems(hotListData.data, sourceName);
124
+ result.savedCount = savedCount;
125
+ result.success = true;
126
+ await this.sourceConfigRepository.updateLastFetchTime(sourceName);
127
+ const duration = Date.now() - startTime;
128
+ result.duration = duration;
129
+ const saveSummary = this.ignoredSaveSources.has(sourceName)
130
+ ? 'not saved (IGNORE_SAVE_SOURCES)'
131
+ : `${savedCount} new`;
132
+ this.logger.log(`✅ Source ${sourceName}: ${hotListData.data.length} fetched, ${saveSummary} in ${duration}ms`);
133
+ return result;
134
+ }
135
+ catch (error) {
136
+ const duration = Date.now() - startTime;
137
+ result.duration = duration;
138
+ result.error = error instanceof Error ? error.message : String(error);
139
+ this.logger.error(`❌ Failed to fetch data for ${sourceName} after ${duration}ms:`, error);
140
+ return result;
141
+ }
142
+ }
143
+ async executeBatch(sourceNames) {
144
+ const startTime = Date.now();
145
+ this.logger.log(`🚀 Starting batch fetch for ${sourceNames.length} sources with max concurrency: ${this.maxConcurrency}`);
146
+ const results = await Promise.all(sourceNames.map((source) => this.execute(source)));
147
+ const totalDuration = Date.now() - startTime;
148
+ const succeeded = results.filter((r) => r.success).length;
149
+ const failed = results.filter((r) => !r.success).length;
150
+ const totalSaved = results.reduce((sum, r) => sum + r.savedCount, 0);
151
+ const totalItems = results.reduce((sum, r) => sum + r.totalCount, 0);
152
+ this.logger.log(`📊 Batch fetch completed in ${totalDuration}ms: ${succeeded} succeeded, ${failed} failed, ${totalItems} fetched, ${totalSaved} new`);
153
+ if (failed > 0) {
154
+ const failedSources = results
155
+ .filter((r) => !r.success)
156
+ .map((r) => `${r.sourceName}(${r.error})`)
157
+ .join(', ');
158
+ this.logger.warn(`Failed sources: ${failedSources}`);
159
+ }
160
+ return results;
161
+ }
162
+ validateSource(sourceName) {
163
+ const sources = this.hotListsService.getAllSources();
164
+ return sources.includes(sourceName);
165
+ }
166
+ };
167
+ exports.FetchHotDataTask = FetchHotDataTask;
168
+ exports.FetchHotDataTask = FetchHotDataTask = FetchHotDataTask_1 = __decorate([
169
+ (0, common_1.Injectable)(),
170
+ __metadata("design:paramtypes", [hot_lists_service_1.HotListsService,
171
+ hot_item_repository_1.HotItemRepository,
172
+ source_config_repository_1.SourceConfigRepository,
173
+ config_1.ConfigService])
174
+ ], FetchHotDataTask);
175
+ //# sourceMappingURL=fetch-hot-data.task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-hot-data.task.js","sourceRoot":"","sources":["../../../src/scheduler/tasks/fetch-hot-data.task.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA+E;AAC/E,0EAAqE;AACrE,yFAAoF;AACpF,mGAA8F;AAC9F,2CAA+C;AAcxC,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAS3B,YACmB,eAAgC,EAChC,iBAAoC,EACpC,sBAA8C,EAC/D,aAA4B;QAHX,oBAAe,GAAf,eAAe,CAAiB;QAChC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAXhD,WAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,mBAAc,GAAG,CAAC,CAAC;QAC5B,WAAM,GAAG,CAAC,CAAC;QACF,YAAO,GAAsB,EAAE,CAAC;QAChC,aAAQ,G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AE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;iBACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC;iBACzC,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,aAAa,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAKO,cAAc,CAAC,UAAkB;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC;QACrD,OAAO,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AAjNY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAWyB,mCAAe;QACb,uCAAiB;QACZ,iDAAsB;QAChD,sBAAa;GAbnB,gBAAgB,CAiN5B"}
@@ -0,0 +1,11 @@
1
+ export declare const genCoolapkHeaders: () => {
2
+ 'X-Requested-With': string;
3
+ 'X-App-Id': string;
4
+ 'X-App-Token': string;
5
+ 'X-Sdk-Int': string;
6
+ 'X-Sdk-Locale': string;
7
+ 'X-App-Version': string;
8
+ 'X-Api-Version': string;
9
+ 'X-App-Code': string;
10
+ 'User-Agent': string;
11
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.genCoolapkHeaders = void 0;
7
+ const md5_1 = __importDefault(require("md5"));
8
+ const getRandomDEVICE_ID = () => {
9
+ const id = [10, 6, 6, 6, 14];
10
+ return id.map((i) => Math.random().toString(36).substring(2, i)).join('-');
11
+ };
12
+ const get_app_token = () => {
13
+ const DEVICE_ID = getRandomDEVICE_ID();
14
+ const now = Math.round(Date.now() / 1000);
15
+ const hex_now = '0x' + now.toString(16);
16
+ const md5_now = (0, md5_1.default)(now.toString());
17
+ const s = 'token://com.coolapk.market/c67ef5943784d09750dcfbb31020f0ab?' +
18
+ md5_now +
19
+ '$' +
20
+ DEVICE_ID +
21
+ '&com.coolapk.market';
22
+ const md5_s = (0, md5_1.default)(Buffer.from(s).toString('base64'));
23
+ const token = md5_s + DEVICE_ID + hex_now;
24
+ return token;
25
+ };
26
+ const genCoolapkHeaders = () => {
27
+ return {
28
+ 'X-Requested-With': 'XMLHttpRequest',
29
+ 'X-App-Id': 'com.coolapk.market',
30
+ 'X-App-Token': get_app_token(),
31
+ 'X-Sdk-Int': '29',
32
+ 'X-Sdk-Locale': 'zh-CN',
33
+ 'X-App-Version': '11.0',
34
+ 'X-Api-Version': '11',
35
+ 'X-App-Code': '2101202',
36
+ 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; Mi 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.15 Mobile Safari/537.36',
37
+ };
38
+ };
39
+ exports.genCoolapkHeaders = genCoolapkHeaders;
40
+ //# sourceMappingURL=coolapk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coolapk.js","sourceRoot":"","sources":["../../src/token/coolapk.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AAMtB,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7B,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7E,CAAC,CAAC;AAMF,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpC,MAAM,CAAC,GACL,8DAA8D;QAC9D,OAAO;QACP,GAAG;QACH,SAAS;QACT,qBAAqB,CAAC;IACxB,MAAM,KAAK,GAAG,IAAA,aAAG,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAMK,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO;QACL,kBAAkB,EAAE,gBAAgB;QACpC,UAAU,EAAE,oBAAoB;QAChC,aAAa,EAAE,aAAa,EAAE;QAC9B,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,OAAO;QACvB,eAAe,EAAE,MAAM;QACvB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,SAAS;QACvB,YAAY,EACV,yHAAyH;KAC5H,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,iBAAiB,qBAa5B"}
@@ -0,0 +1,2 @@
1
+ export declare class TokenModule {
2
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TokenModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const token_service_1 = require("./token.service");
12
+ const http_module_1 = require("../http/http.module");
13
+ let TokenModule = class TokenModule {
14
+ };
15
+ exports.TokenModule = TokenModule;
16
+ exports.TokenModule = TokenModule = __decorate([
17
+ (0, common_1.Module)({
18
+ imports: [http_module_1.HttpClientModule],
19
+ providers: [token_service_1.TokenService],
20
+ exports: [token_service_1.TokenService],
21
+ })
22
+ ], TokenModule);
23
+ //# sourceMappingURL=token.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.module.js","sourceRoot":"","sources":["../../src/token/token.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,qDAAuD;AAOhD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,8BAAgB,CAAC;QAC3B,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
@@ -0,0 +1,19 @@
1
+ import { HttpClientService } from '../http/http.service';
2
+ interface WbiParams {
3
+ [key: string]: string | number;
4
+ }
5
+ export declare class TokenService {
6
+ private readonly httpClientService;
7
+ private readonly logger;
8
+ private readonly wbiNavRequest;
9
+ private readonly mixinKeyEncTab;
10
+ constructor(httpClientService: HttpClientService);
11
+ private getMixinKey;
12
+ private encWbi;
13
+ private getWbiKeys;
14
+ getBiliWbi(customParams?: WbiParams): Promise<string>;
15
+ clearBiliWbiCache(): Promise<void>;
16
+ generateWbiSignedUrl(baseUrl: string, params: WbiParams): Promise<string>;
17
+ get51ctoToken(): Promise<string>;
18
+ }
19
+ export {};