@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.
- package/.env.example +77 -0
- package/LICENSE +21 -0
- package/README.md +317 -2
- package/bin/daily-hot-api.js +25 -0
- package/dist/app.controller.d.ts +41 -0
- package/dist/app.controller.js +91 -0
- package/dist/app.controller.js.map +1 -0
- package/dist/app.module.d.ts +4 -0
- package/dist/app.module.js +44 -0
- package/dist/app.module.js.map +1 -0
- package/dist/app.service.d.ts +19 -0
- package/dist/app.service.js +57 -0
- package/dist/app.service.js.map +1 -0
- package/dist/cache/cache.module.d.ts +2 -0
- package/dist/cache/cache.module.js +52 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +26 -0
- package/dist/cache/cache.service.js +163 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cli/args.d.ts +24 -0
- package/dist/cli/args.js +261 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +3 -0
- package/dist/cli/commands/logs.js +55 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/restart.d.ts +3 -0
- package/dist/cli/commands/restart.js +62 -0
- package/dist/cli/commands/restart.js.map +1 -0
- package/dist/cli/commands/start.d.ts +3 -0
- package/dist/cli/commands/start.js +280 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.js +78 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +12 -0
- package/dist/cli/commands/stop.js +135 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/context.d.ts +4 -0
- package/dist/cli/context.js +3 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/env.d.ts +2 -0
- package/dist/cli/env.js +80 -0
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/errors.d.ts +14 -0
- package/dist/cli/errors.js +25 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/health.d.ts +2 -0
- package/dist/cli/health.js +44 -0
- package/dist/cli/health.js.map +1 -0
- package/dist/cli/help.d.ts +3 -0
- package/dist/cli/help.js +158 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +94 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/log-file.d.ts +8 -0
- package/dist/cli/log-file.js +58 -0
- package/dist/cli/log-file.js.map +1 -0
- package/dist/cli/output.d.ts +7 -0
- package/dist/cli/output.js +46 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/paths.d.ts +33 -0
- package/dist/cli/paths.js +76 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/run-state.d.ts +25 -0
- package/dist/cli/run-state.js +159 -0
- package/dist/cli/run-state.js.map +1 -0
- package/dist/common/middlewares/logger.middleware.d.ts +7 -0
- package/dist/common/middlewares/logger.middleware.js +29 -0
- package/dist/common/middlewares/logger.middleware.js.map +1 -0
- package/dist/config/config.module.d.ts +2 -0
- package/dist/config/config.module.js +47 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/configuration.d.ts +3 -0
- package/dist/config/configuration.js +5 -0
- package/dist/config/configuration.js.map +1 -0
- package/dist/config/validation.schema.d.ts +114 -0
- package/dist/config/validation.schema.js +69 -0
- package/dist/config/validation.schema.js.map +1 -0
- package/dist/daily-brief/clients/ai-analysis.client.d.ts +20 -0
- package/dist/daily-brief/clients/ai-analysis.client.js +217 -0
- package/dist/daily-brief/clients/ai-analysis.client.js.map +1 -0
- package/dist/daily-brief/clients/brief-search.service.d.ts +11 -0
- package/dist/daily-brief/clients/brief-search.service.js +52 -0
- package/dist/daily-brief/clients/brief-search.service.js.map +1 -0
- package/dist/daily-brief/clients/deepseek-search.client.d.ts +11 -0
- package/dist/daily-brief/clients/deepseek-search.client.js +70 -0
- package/dist/daily-brief/clients/deepseek-search.client.js.map +1 -0
- package/dist/daily-brief/clients/tavily-search.client.d.ts +11 -0
- package/dist/daily-brief/clients/tavily-search.client.js +72 -0
- package/dist/daily-brief/clients/tavily-search.client.js.map +1 -0
- package/dist/daily-brief/daily-brief.config.d.ts +31 -0
- package/dist/daily-brief/daily-brief.config.js +108 -0
- package/dist/daily-brief/daily-brief.config.js.map +1 -0
- package/dist/daily-brief/daily-brief.controller.d.ts +72 -0
- package/dist/daily-brief/daily-brief.controller.js +169 -0
- package/dist/daily-brief/daily-brief.controller.js.map +1 -0
- package/dist/daily-brief/daily-brief.module.d.ts +2 -0
- package/dist/daily-brief/daily-brief.module.js +49 -0
- package/dist/daily-brief/daily-brief.module.js.map +1 -0
- package/dist/daily-brief/daily-brief.scheduler.d.ts +30 -0
- package/dist/daily-brief/daily-brief.scheduler.js +113 -0
- package/dist/daily-brief/daily-brief.scheduler.js.map +1 -0
- package/dist/daily-brief/daily-brief.service.d.ts +101 -0
- package/dist/daily-brief/daily-brief.service.js +412 -0
- package/dist/daily-brief/daily-brief.service.js.map +1 -0
- package/dist/daily-brief/dto/brief-date-param.dto.d.ts +3 -0
- package/dist/daily-brief/dto/brief-date-param.dto.js +23 -0
- package/dist/daily-brief/dto/brief-date-param.dto.js.map +1 -0
- package/dist/daily-brief/dto/generate-brief.dto.d.ts +6 -0
- package/dist/daily-brief/dto/generate-brief.dto.js +39 -0
- package/dist/daily-brief/dto/generate-brief.dto.js.map +1 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.d.ts +6 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.js +42 -0
- package/dist/daily-brief/dto/list-briefs-query.dto.js.map +1 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.d.ts +6 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.js +46 -0
- package/dist/daily-brief/dto/stock-ranking-query.dto.js.map +1 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.d.ts +59 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.js +3 -0
- package/dist/daily-brief/interfaces/daily-brief.interface.js.map +1 -0
- package/dist/daily-brief/interfaces/search-provider.interface.d.ts +11 -0
- package/dist/daily-brief/interfaces/search-provider.interface.js +3 -0
- package/dist/daily-brief/interfaces/search-provider.interface.js.map +1 -0
- package/dist/daily-brief/utils/brief-date.d.ts +2 -0
- package/dist/daily-brief/utils/brief-date.js +16 -0
- package/dist/daily-brief/utils/brief-date.js.map +1 -0
- package/dist/daily-brief/utils/concurrency.d.ts +1 -0
- package/dist/daily-brief/utils/concurrency.js +20 -0
- package/dist/daily-brief/utils/concurrency.js.map +1 -0
- package/dist/database/database.module.d.ts +2 -0
- package/dist/database/database.module.js +57 -0
- package/dist/database/database.module.js.map +1 -0
- package/dist/database/repositories/daily-brief.repository.d.ts +96 -0
- package/dist/database/repositories/daily-brief.repository.js +457 -0
- package/dist/database/repositories/daily-brief.repository.js.map +1 -0
- package/dist/database/repositories/hot-item.repository.d.ts +52 -0
- package/dist/database/repositories/hot-item.repository.js +255 -0
- package/dist/database/repositories/hot-item.repository.js.map +1 -0
- package/dist/database/repositories/source-config.repository.d.ts +15 -0
- package/dist/database/repositories/source-config.repository.js +77 -0
- package/dist/database/repositories/source-config.repository.js.map +1 -0
- package/dist/database/schemas/daily-brief.schema.d.ts +30 -0
- package/dist/database/schemas/daily-brief.schema.js +103 -0
- package/dist/database/schemas/daily-brief.schema.js.map +1 -0
- package/dist/database/schemas/hot-item.schema.d.ts +20 -0
- package/dist/database/schemas/hot-item.schema.js +72 -0
- package/dist/database/schemas/hot-item.schema.js.map +1 -0
- package/dist/database/schemas/source-config.schema.d.ts +15 -0
- package/dist/database/schemas/source-config.schema.js +47 -0
- package/dist/database/schemas/source-config.schema.js.map +1 -0
- package/dist/history/dto/history-response.dto.d.ts +17 -0
- package/dist/history/dto/history-response.dto.js +13 -0
- package/dist/history/dto/history-response.dto.js.map +1 -0
- package/dist/history/dto/search-history.dto.d.ts +10 -0
- package/dist/history/dto/search-history.dto.js +72 -0
- package/dist/history/dto/search-history.dto.js.map +1 -0
- package/dist/history/history.controller.d.ts +13 -0
- package/dist/history/history.controller.js +92 -0
- package/dist/history/history.controller.js.map +1 -0
- package/dist/history/history.module.d.ts +2 -0
- package/dist/history/history.module.js +25 -0
- package/dist/history/history.module.js.map +1 -0
- package/dist/history/history.service.d.ts +15 -0
- package/dist/history/history.service.js +68 -0
- package/dist/history/history.service.js.map +1 -0
- package/dist/host-lists/decorators/hot-source.decorator.d.ts +9 -0
- package/dist/host-lists/decorators/hot-source.decorator.js +11 -0
- package/dist/host-lists/decorators/hot-source.decorator.js.map +1 -0
- package/dist/host-lists/dto/hot-list.dto.d.ts +14 -0
- package/dist/host-lists/dto/hot-list.dto.js +94 -0
- package/dist/host-lists/dto/hot-list.dto.js.map +1 -0
- package/dist/host-lists/hot-lists.controller.d.ts +39 -0
- package/dist/host-lists/hot-lists.controller.js +87 -0
- package/dist/host-lists/hot-lists.controller.js.map +1 -0
- package/dist/host-lists/hot-lists.module.d.ts +2 -0
- package/dist/host-lists/hot-lists.module.js +36 -0
- package/dist/host-lists/hot-lists.module.js.map +1 -0
- package/dist/host-lists/hot-lists.service.d.ts +21 -0
- package/dist/host-lists/hot-lists.service.js +115 -0
- package/dist/host-lists/hot-lists.service.js.map +1 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.d.ts +5 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.js +3 -0
- package/dist/host-lists/interfaces/hot-list-source.interface.js.map +1 -0
- package/dist/host-lists/interfaces/hot-list.interface.d.ts +31 -0
- package/dist/host-lists/interfaces/hot-list.interface.js +3 -0
- package/dist/host-lists/interfaces/hot-list.interface.js.map +1 -0
- package/dist/host-lists/interfaces/router-data.interface.d.ts +19 -0
- package/dist/host-lists/interfaces/router-data.interface.js +3 -0
- package/dist/host-lists/interfaces/router-data.interface.js.map +1 -0
- package/dist/host-lists/sources/36kr.source.d.ts +9 -0
- package/dist/host-lists/sources/36kr.source.js +89 -0
- package/dist/host-lists/sources/36kr.source.js.map +1 -0
- package/dist/host-lists/sources/51cto.source.d.ts +11 -0
- package/dist/host-lists/sources/51cto.source.js +71 -0
- package/dist/host-lists/sources/51cto.source.js.map +1 -0
- package/dist/host-lists/sources/52pojie.source.d.ts +9 -0
- package/dist/host-lists/sources/52pojie.source.js +109 -0
- package/dist/host-lists/sources/52pojie.source.js.map +1 -0
- package/dist/host-lists/sources/acfun.source.d.ts +9 -0
- package/dist/host-lists/sources/acfun.source.js +90 -0
- package/dist/host-lists/sources/acfun.source.js.map +1 -0
- package/dist/host-lists/sources/baidu.source.d.ts +9 -0
- package/dist/host-lists/sources/baidu.source.js +85 -0
- package/dist/host-lists/sources/baidu.source.js.map +1 -0
- package/dist/host-lists/sources/bilibili.source.d.ts +14 -0
- package/dist/host-lists/sources/bilibili.source.js +188 -0
- package/dist/host-lists/sources/bilibili.source.js.map +1 -0
- package/dist/host-lists/sources/caixin.source.d.ts +9 -0
- package/dist/host-lists/sources/caixin.source.js +102 -0
- package/dist/host-lists/sources/caixin.source.js.map +1 -0
- package/dist/host-lists/sources/cls.source.d.ts +9 -0
- package/dist/host-lists/sources/cls.source.js +62 -0
- package/dist/host-lists/sources/cls.source.js.map +1 -0
- package/dist/host-lists/sources/coolapk.source.d.ts +9 -0
- package/dist/host-lists/sources/coolapk.source.js +57 -0
- package/dist/host-lists/sources/coolapk.source.js.map +1 -0
- package/dist/host-lists/sources/csdn.source.d.ts +9 -0
- package/dist/host-lists/sources/csdn.source.js +59 -0
- package/dist/host-lists/sources/csdn.source.js.map +1 -0
- package/dist/host-lists/sources/dgtle.source.d.ts +9 -0
- package/dist/host-lists/sources/dgtle.source.js +57 -0
- package/dist/host-lists/sources/dgtle.source.js.map +1 -0
- package/dist/host-lists/sources/douban-group.source.d.ts +11 -0
- package/dist/host-lists/sources/douban-group.source.js +100 -0
- package/dist/host-lists/sources/douban-group.source.js.map +1 -0
- package/dist/host-lists/sources/douban-movie.source.d.ts +10 -0
- package/dist/host-lists/sources/douban-movie.source.js +103 -0
- package/dist/host-lists/sources/douban-movie.source.js.map +1 -0
- package/dist/host-lists/sources/douyin.d.ts +16 -0
- package/dist/host-lists/sources/douyin.js +215 -0
- package/dist/host-lists/sources/douyin.js.map +1 -0
- package/dist/host-lists/sources/eastmoney-stock.source.d.ts +11 -0
- package/dist/host-lists/sources/eastmoney-stock.source.js +151 -0
- package/dist/host-lists/sources/eastmoney-stock.source.js.map +1 -0
- package/dist/host-lists/sources/eastmoney.source.d.ts +9 -0
- package/dist/host-lists/sources/eastmoney.source.js +86 -0
- package/dist/host-lists/sources/eastmoney.source.js.map +1 -0
- package/dist/host-lists/sources/geekpark.source.d.ts +9 -0
- package/dist/host-lists/sources/geekpark.source.js +60 -0
- package/dist/host-lists/sources/geekpark.source.js.map +1 -0
- package/dist/host-lists/sources/gelonghui.source.d.ts +9 -0
- package/dist/host-lists/sources/gelonghui.source.js +139 -0
- package/dist/host-lists/sources/gelonghui.source.js.map +1 -0
- package/dist/host-lists/sources/github.source.d.ts +12 -0
- package/dist/host-lists/sources/github.source.js +171 -0
- package/dist/host-lists/sources/github.source.js.map +1 -0
- package/dist/host-lists/sources/guokr.source.d.ts +11 -0
- package/dist/host-lists/sources/guokr.source.js +98 -0
- package/dist/host-lists/sources/guokr.source.js.map +1 -0
- package/dist/host-lists/sources/hackernews.source.d.ts +11 -0
- package/dist/host-lists/sources/hackernews.source.js +121 -0
- package/dist/host-lists/sources/hackernews.source.js.map +1 -0
- package/dist/host-lists/sources/hellogithub.source.d.ts +11 -0
- package/dist/host-lists/sources/hellogithub.source.js +98 -0
- package/dist/host-lists/sources/hellogithub.source.js.map +1 -0
- package/dist/host-lists/sources/history.source.d.ts +11 -0
- package/dist/host-lists/sources/history.source.js +92 -0
- package/dist/host-lists/sources/history.source.js.map +1 -0
- package/dist/host-lists/sources/honkai.source.d.ts +9 -0
- package/dist/host-lists/sources/honkai.source.js +72 -0
- package/dist/host-lists/sources/honkai.source.js.map +1 -0
- package/dist/host-lists/sources/hostloc.source.d.ts +9 -0
- package/dist/host-lists/sources/hostloc.source.js +75 -0
- package/dist/host-lists/sources/hostloc.source.js.map +1 -0
- package/dist/host-lists/sources/hupu.source.d.ts +9 -0
- package/dist/host-lists/sources/hupu.source.js +73 -0
- package/dist/host-lists/sources/hupu.source.js.map +1 -0
- package/dist/host-lists/sources/huxiu.source.d.ts +9 -0
- package/dist/host-lists/sources/huxiu.source.js +153 -0
- package/dist/host-lists/sources/huxiu.source.js.map +1 -0
- package/dist/host-lists/sources/ifanr.source.d.ts +9 -0
- package/dist/host-lists/sources/ifanr.source.js +57 -0
- package/dist/host-lists/sources/ifanr.source.js.map +1 -0
- package/dist/host-lists/sources/index.d.ts +2 -0
- package/dist/host-lists/sources/index.js +134 -0
- package/dist/host-lists/sources/index.js.map +1 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.d.ts +9 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.js +75 -0
- package/dist/host-lists/sources/ithome-xijiayi.source.js.map +1 -0
- package/dist/host-lists/sources/ithome.source.d.ts +9 -0
- package/dist/host-lists/sources/ithome.source.js +71 -0
- package/dist/host-lists/sources/ithome.source.js.map +1 -0
- package/dist/host-lists/sources/jd.source.d.ts +9 -0
- package/dist/host-lists/sources/jd.source.js +82 -0
- package/dist/host-lists/sources/jd.source.js.map +1 -0
- package/dist/host-lists/sources/jianshu.source.d.ts +9 -0
- package/dist/host-lists/sources/jianshu.source.js +72 -0
- package/dist/host-lists/sources/jianshu.source.js.map +1 -0
- package/dist/host-lists/sources/jin10.source.d.ts +9 -0
- package/dist/host-lists/sources/jin10.source.js +63 -0
- package/dist/host-lists/sources/jin10.source.js.map +1 -0
- package/dist/host-lists/sources/juejin.source.d.ts +10 -0
- package/dist/host-lists/sources/juejin.source.js +81 -0
- package/dist/host-lists/sources/juejin.source.js.map +1 -0
- package/dist/host-lists/sources/kuaishou.source.d.ts +13 -0
- package/dist/host-lists/sources/kuaishou.source.js +179 -0
- package/dist/host-lists/sources/kuaishou.source.js.map +1 -0
- package/dist/host-lists/sources/linuxdo.source.d.ts +9 -0
- package/dist/host-lists/sources/linuxdo.source.js +62 -0
- package/dist/host-lists/sources/linuxdo.source.js.map +1 -0
- package/dist/host-lists/sources/lol.source.d.ts +9 -0
- package/dist/host-lists/sources/lol.source.js +58 -0
- package/dist/host-lists/sources/lol.source.js.map +1 -0
- package/dist/host-lists/sources/miyoushe.source.d.ts +9 -0
- package/dist/host-lists/sources/miyoushe.source.js +88 -0
- package/dist/host-lists/sources/miyoushe.source.js.map +1 -0
- package/dist/host-lists/sources/netease-news.source.d.ts +9 -0
- package/dist/host-lists/sources/netease-news.source.js +56 -0
- package/dist/host-lists/sources/netease-news.source.js.map +1 -0
- package/dist/host-lists/sources/ngabbs.source.d.ts +9 -0
- package/dist/host-lists/sources/ngabbs.source.js +70 -0
- package/dist/host-lists/sources/ngabbs.source.js.map +1 -0
- package/dist/host-lists/sources/nodeseek.source.d.ts +9 -0
- package/dist/host-lists/sources/nodeseek.source.js +62 -0
- package/dist/host-lists/sources/nodeseek.source.js.map +1 -0
- package/dist/host-lists/sources/nytimes.source.d.ts +9 -0
- package/dist/host-lists/sources/nytimes.source.js +77 -0
- package/dist/host-lists/sources/nytimes.source.js.map +1 -0
- package/dist/host-lists/sources/producthunt.source.d.ts +9 -0
- package/dist/host-lists/sources/producthunt.source.js +75 -0
- package/dist/host-lists/sources/producthunt.source.js.map +1 -0
- package/dist/host-lists/sources/qq-news.source.d.ts +9 -0
- package/dist/host-lists/sources/qq-news.source.js +53 -0
- package/dist/host-lists/sources/qq-news.source.js.map +1 -0
- package/dist/host-lists/sources/sina-news.source.d.ts +9 -0
- package/dist/host-lists/sources/sina-news.source.js +98 -0
- package/dist/host-lists/sources/sina-news.source.js.map +1 -0
- package/dist/host-lists/sources/sina.source.d.ts +9 -0
- package/dist/host-lists/sources/sina.source.js +78 -0
- package/dist/host-lists/sources/sina.source.js.map +1 -0
- package/dist/host-lists/sources/smzdm.source.d.ts +9 -0
- package/dist/host-lists/sources/smzdm.source.js +71 -0
- package/dist/host-lists/sources/smzdm.source.js.map +1 -0
- package/dist/host-lists/sources/sspai.source.d.ts +9 -0
- package/dist/host-lists/sources/sspai.source.js +69 -0
- package/dist/host-lists/sources/sspai.source.js.map +1 -0
- package/dist/host-lists/sources/starrail.source.d.ts +9 -0
- package/dist/host-lists/sources/starrail.source.js +72 -0
- package/dist/host-lists/sources/starrail.source.js.map +1 -0
- package/dist/host-lists/sources/taobao.source.d.ts +10 -0
- package/dist/host-lists/sources/taobao.source.js +169 -0
- package/dist/host-lists/sources/taobao.source.js.map +1 -0
- package/dist/host-lists/sources/thepaper.source.d.ts +9 -0
- package/dist/host-lists/sources/thepaper.source.js +56 -0
- package/dist/host-lists/sources/thepaper.source.js.map +1 -0
- package/dist/host-lists/sources/tieba.source.d.ts +9 -0
- package/dist/host-lists/sources/tieba.source.js +58 -0
- package/dist/host-lists/sources/tieba.source.js.map +1 -0
- package/dist/host-lists/sources/tonghuashun.source.d.ts +9 -0
- package/dist/host-lists/sources/tonghuashun.source.js +112 -0
- package/dist/host-lists/sources/tonghuashun.source.js.map +1 -0
- package/dist/host-lists/sources/toutiao.source.d.ts +9 -0
- package/dist/host-lists/sources/toutiao.source.js +56 -0
- package/dist/host-lists/sources/toutiao.source.js.map +1 -0
- package/dist/host-lists/sources/v2ex.source.d.ts +9 -0
- package/dist/host-lists/sources/v2ex.source.js +67 -0
- package/dist/host-lists/sources/v2ex.source.js.map +1 -0
- package/dist/host-lists/sources/wallstreet.source.d.ts +9 -0
- package/dist/host-lists/sources/wallstreet.source.js +59 -0
- package/dist/host-lists/sources/wallstreet.source.js.map +1 -0
- package/dist/host-lists/sources/weatheralarm.source.d.ts +9 -0
- package/dist/host-lists/sources/weatheralarm.source.js +68 -0
- package/dist/host-lists/sources/weatheralarm.source.js.map +1 -0
- package/dist/host-lists/sources/weibo.source.d.ts +15 -0
- package/dist/host-lists/sources/weibo.source.js +180 -0
- package/dist/host-lists/sources/weibo.source.js.map +1 -0
- package/dist/host-lists/sources/weread.source.d.ts +9 -0
- package/dist/host-lists/sources/weread.source.js +82 -0
- package/dist/host-lists/sources/weread.source.js.map +1 -0
- package/dist/host-lists/sources/xinyu.source.d.ts +9 -0
- package/dist/host-lists/sources/xinyu.source.js +151 -0
- package/dist/host-lists/sources/xinyu.source.js.map +1 -0
- package/dist/host-lists/sources/yicai.source.d.ts +9 -0
- package/dist/host-lists/sources/yicai.source.js +113 -0
- package/dist/host-lists/sources/yicai.source.js.map +1 -0
- package/dist/host-lists/sources/yystv.source.d.ts +9 -0
- package/dist/host-lists/sources/yystv.source.js +57 -0
- package/dist/host-lists/sources/yystv.source.js.map +1 -0
- package/dist/host-lists/sources/zhihu-daily.source.d.ts +9 -0
- package/dist/host-lists/sources/zhihu-daily.source.js +60 -0
- package/dist/host-lists/sources/zhihu-daily.source.js.map +1 -0
- package/dist/host-lists/sources/zhihu.source.d.ts +12 -0
- package/dist/host-lists/sources/zhihu.source.js +195 -0
- package/dist/host-lists/sources/zhihu.source.js.map +1 -0
- package/dist/http/http.module.d.ts +2 -0
- package/dist/http/http.module.js +30 -0
- package/dist/http/http.module.js.map +1 -0
- package/dist/http/http.service.d.ts +53 -0
- package/dist/http/http.service.js +277 -0
- package/dist/http/http.service.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +70 -0
- package/dist/main.js.map +1 -0
- package/dist/rss/rss.module.d.ts +2 -0
- package/dist/rss/rss.module.js +21 -0
- package/dist/rss/rss.module.js.map +1 -0
- package/dist/rss/rss.service.d.ts +5 -0
- package/dist/rss/rss.service.js +55 -0
- package/dist/rss/rss.service.js.map +1 -0
- package/dist/scheduler/dto/trigger-fetch.dto.d.ts +3 -0
- package/dist/scheduler/dto/trigger-fetch.dto.js +22 -0
- package/dist/scheduler/dto/trigger-fetch.dto.js.map +1 -0
- package/dist/scheduler/dto/update-source-config.dto.d.ts +4 -0
- package/dist/scheduler/dto/update-source-config.dto.js +29 -0
- package/dist/scheduler/dto/update-source-config.dto.js.map +1 -0
- package/dist/scheduler/scheduler.controller.d.ts +52 -0
- package/dist/scheduler/scheduler.controller.js +132 -0
- package/dist/scheduler/scheduler.controller.js.map +1 -0
- package/dist/scheduler/scheduler.module.d.ts +2 -0
- package/dist/scheduler/scheduler.module.js +34 -0
- package/dist/scheduler/scheduler.module.js.map +1 -0
- package/dist/scheduler/scheduler.service.d.ts +54 -0
- package/dist/scheduler/scheduler.service.js +238 -0
- package/dist/scheduler/scheduler.service.js.map +1 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.d.ts +34 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.js +175 -0
- package/dist/scheduler/tasks/fetch-hot-data.task.js.map +1 -0
- package/dist/token/coolapk.d.ts +11 -0
- package/dist/token/coolapk.js +40 -0
- package/dist/token/coolapk.js.map +1 -0
- package/dist/token/token.module.d.ts +2 -0
- package/dist/token/token.module.js +23 -0
- package/dist/token/token.module.js.map +1 -0
- package/dist/token/token.service.d.ts +19 -0
- package/dist/token/token.service.js +115 -0
- package/dist/token/token.service.js.map +1 -0
- package/dist/token/tools.d.ts +1 -0
- package/dist/token/tools.js +15 -0
- package/dist/token/tools.js.map +1 -0
- package/dist/token/weread.d.ts +2 -0
- package/dist/token/weread.js +55 -0
- package/dist/token/weread.js.map +1 -0
- package/dist/utils/getNum.d.ts +1 -0
- package/dist/utils/getNum.js +20 -0
- package/dist/utils/getNum.js.map +1 -0
- package/dist/utils/getTime.d.ts +11 -0
- package/dist/utils/getTime.js +134 -0
- package/dist/utils/getTime.js.map +1 -0
- package/dist/utils/headers.d.ts +16 -0
- package/dist/utils/headers.js +20 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/parseRSS.d.ts +11 -0
- package/dist/utils/parseRSS.js +47 -0
- package/dist/utils/parseRSS.js.map +1 -0
- package/package.json +148 -4
- package/views/home.hbs +65 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LOG_TAIL_MAX_BYTES = void 0;
|
|
4
|
+
exports.tailFile = tailFile;
|
|
5
|
+
exports.readLogChunk = readLogChunk;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const errors_1 = require("./errors");
|
|
8
|
+
exports.LOG_TAIL_MAX_BYTES = 256 * 1024;
|
|
9
|
+
function tailFile(file, lines, maxBytes = exports.LOG_TAIL_MAX_BYTES) {
|
|
10
|
+
if (!(0, fs_1.existsSync)(file)) {
|
|
11
|
+
throw new errors_1.CliError(`日志文件不存在: ${file}`);
|
|
12
|
+
}
|
|
13
|
+
const size = (0, fs_1.statSync)(file).size;
|
|
14
|
+
if (size === 0 || lines <= 0) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
const start = Math.max(0, size - maxBytes);
|
|
18
|
+
const fd = (0, fs_1.openSync)(file, 'r');
|
|
19
|
+
try {
|
|
20
|
+
const buffer = Buffer.alloc(size - start);
|
|
21
|
+
(0, fs_1.readSync)(fd, buffer, 0, buffer.length, start);
|
|
22
|
+
let text = buffer.toString('utf8');
|
|
23
|
+
if (start > 0) {
|
|
24
|
+
const firstNewline = text.indexOf('\n');
|
|
25
|
+
text = firstNewline >= 0 ? text.slice(firstNewline + 1) : '';
|
|
26
|
+
}
|
|
27
|
+
text = text.replace(/\r?\n$/, '');
|
|
28
|
+
if (!text) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
const allLines = text.split(/\r?\n/);
|
|
32
|
+
return allLines.slice(Math.max(0, allLines.length - lines)).join('\n');
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
(0, fs_1.closeSync)(fd);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function readLogChunk(file, fromPosition) {
|
|
39
|
+
if (!(0, fs_1.existsSync)(file)) {
|
|
40
|
+
return { text: '', nextPosition: 0, truncated: fromPosition > 0 };
|
|
41
|
+
}
|
|
42
|
+
const size = (0, fs_1.statSync)(file).size;
|
|
43
|
+
const truncated = size < fromPosition;
|
|
44
|
+
const start = truncated ? 0 : fromPosition;
|
|
45
|
+
if (size <= start) {
|
|
46
|
+
return { text: '', nextPosition: start, truncated };
|
|
47
|
+
}
|
|
48
|
+
const fd = (0, fs_1.openSync)(file, 'r');
|
|
49
|
+
try {
|
|
50
|
+
const buffer = Buffer.alloc(size - start);
|
|
51
|
+
(0, fs_1.readSync)(fd, buffer, 0, buffer.length, start);
|
|
52
|
+
return { text: buffer.toString('utf8'), nextPosition: size, truncated };
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
(0, fs_1.closeSync)(fd);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=log-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-file.js","sourceRoot":"","sources":["../../src/cli/log-file.ts"],"names":[],"mappings":";;;AAMA,4BAgCC;AAUD,oCAkBC;AAlED,2BAAyE;AACzE,qCAAoC;AAEvB,QAAA,kBAAkB,GAAG,GAAG,GAAG,IAAI,CAAC;AAG7C,SAAgB,QAAQ,CACtB,IAAY,EACZ,KAAa,EACb,QAAQ,GAAG,0BAAkB;IAE7B,IAAI,CAAC,IAAA,eAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,iBAAQ,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IACjC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAC;IAC3C,MAA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,CAAC,EAAE,CAAC;IACpE,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IACjC,MAAM,SAAS,GAAG,IAAI,GAAG,YAAY,CAAC;IACtC,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3C,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACtD,CAAC;IACD,MAAM,EAAE,GAAG,IAAA,aAAQ,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;QAC1C,IAAA,aAAQ,EAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC1E,CAAC;YAAS,CAAC;QACT,IAAA,cAAS,EAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CLI_PREFIX = "[daily-hot-api]";
|
|
2
|
+
export declare function info(message: string): void;
|
|
3
|
+
export declare function progress(message: string): void;
|
|
4
|
+
export declare function warn(message: string): void;
|
|
5
|
+
export declare function fail(message: string): void;
|
|
6
|
+
export declare function field(label: string, value: string | number): void;
|
|
7
|
+
export declare function formatDuration(totalSeconds: number): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLI_PREFIX = void 0;
|
|
4
|
+
exports.info = info;
|
|
5
|
+
exports.progress = progress;
|
|
6
|
+
exports.warn = warn;
|
|
7
|
+
exports.fail = fail;
|
|
8
|
+
exports.field = field;
|
|
9
|
+
exports.formatDuration = formatDuration;
|
|
10
|
+
exports.CLI_PREFIX = '[daily-hot-api]';
|
|
11
|
+
function info(message) {
|
|
12
|
+
console.log(`${exports.CLI_PREFIX} ${message}`);
|
|
13
|
+
}
|
|
14
|
+
function progress(message) {
|
|
15
|
+
console.error(`${exports.CLI_PREFIX} ${message}`);
|
|
16
|
+
}
|
|
17
|
+
function warn(message) {
|
|
18
|
+
console.warn(`${exports.CLI_PREFIX} 警告: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
function fail(message) {
|
|
21
|
+
console.error(`${exports.CLI_PREFIX} 错误: ${message}`);
|
|
22
|
+
}
|
|
23
|
+
function field(label, value) {
|
|
24
|
+
console.log(` ${label}: ${value}`);
|
|
25
|
+
}
|
|
26
|
+
function formatDuration(totalSeconds) {
|
|
27
|
+
const seconds = Math.max(0, Math.floor(totalSeconds));
|
|
28
|
+
if (seconds < 60) {
|
|
29
|
+
return `${seconds} 秒`;
|
|
30
|
+
}
|
|
31
|
+
const minutes = Math.floor(seconds / 60);
|
|
32
|
+
if (minutes < 60) {
|
|
33
|
+
return `${minutes} 分钟`;
|
|
34
|
+
}
|
|
35
|
+
const hours = Math.floor(minutes / 60);
|
|
36
|
+
const restMinutes = minutes % 60;
|
|
37
|
+
if (hours < 24) {
|
|
38
|
+
return restMinutes > 0
|
|
39
|
+
? `${hours} 小时 ${restMinutes} 分钟`
|
|
40
|
+
: `${hours} 小时`;
|
|
41
|
+
}
|
|
42
|
+
const days = Math.floor(hours / 24);
|
|
43
|
+
const restHours = hours % 24;
|
|
44
|
+
return restHours > 0 ? `${days} 天 ${restHours} 小时` : `${days} 天`;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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GAAG,EAAE,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,OAAO,GAAG,EAAE,CAAC;IACjC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,OAAO,WAAW,GAAG,CAAC;YACpB,CAAC,CAAC,GAAG,KAAK,OAAO,WAAW,KAAK;YACjC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,GAAG,EAAE,CAAC;IAC7B,OAAO,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const APP_NAME = "daily-hot-api";
|
|
2
|
+
export declare const DEFAULT_PORT = 6689;
|
|
3
|
+
export declare const DEFAULT_STOP_TIMEOUT_SECONDS = 10;
|
|
4
|
+
export declare const START_TIMEOUT_MS = 60000;
|
|
5
|
+
export declare const START_POLL_INTERVAL_MS = 200;
|
|
6
|
+
export declare const HOME_ENV = "DAILY_HOT_API_HOME";
|
|
7
|
+
export declare const ENV_FILE_ENV = "DAILY_HOT_API_ENV_FILE";
|
|
8
|
+
export declare const DAEMON_CHILD_ENV = "DAILY_HOT_API_DAEMON_CHILD";
|
|
9
|
+
export interface CliPaths {
|
|
10
|
+
homeDir: string;
|
|
11
|
+
stateFile: string;
|
|
12
|
+
logDir: string;
|
|
13
|
+
logFile: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EnvFileResolution {
|
|
16
|
+
path: string;
|
|
17
|
+
explicit: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function getPackageRoot(): string;
|
|
20
|
+
export declare function getBinPath(): string;
|
|
21
|
+
export declare function getPackageVersion(): string;
|
|
22
|
+
export declare function resolveHomeDir(options: {
|
|
23
|
+
home?: string;
|
|
24
|
+
cwd: string;
|
|
25
|
+
env?: NodeJS.ProcessEnv;
|
|
26
|
+
}): string;
|
|
27
|
+
export declare function buildCliPaths(homeDir: string): CliPaths;
|
|
28
|
+
export declare function resolveEnvFile(options: {
|
|
29
|
+
cwd: string;
|
|
30
|
+
homeDir: string;
|
|
31
|
+
envFile?: string;
|
|
32
|
+
env?: NodeJS.ProcessEnv;
|
|
33
|
+
}): EnvFileResolution | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DAEMON_CHILD_ENV = exports.ENV_FILE_ENV = exports.HOME_ENV = exports.START_POLL_INTERVAL_MS = exports.START_TIMEOUT_MS = exports.DEFAULT_STOP_TIMEOUT_SECONDS = exports.DEFAULT_PORT = exports.APP_NAME = void 0;
|
|
4
|
+
exports.getPackageRoot = getPackageRoot;
|
|
5
|
+
exports.getBinPath = getBinPath;
|
|
6
|
+
exports.getPackageVersion = getPackageVersion;
|
|
7
|
+
exports.resolveHomeDir = resolveHomeDir;
|
|
8
|
+
exports.buildCliPaths = buildCliPaths;
|
|
9
|
+
exports.resolveEnvFile = resolveEnvFile;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const os_1 = require("os");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
exports.APP_NAME = 'daily-hot-api';
|
|
14
|
+
exports.DEFAULT_PORT = 6689;
|
|
15
|
+
exports.DEFAULT_STOP_TIMEOUT_SECONDS = 10;
|
|
16
|
+
exports.START_TIMEOUT_MS = 60_000;
|
|
17
|
+
exports.START_POLL_INTERVAL_MS = 200;
|
|
18
|
+
exports.HOME_ENV = 'DAILY_HOT_API_HOME';
|
|
19
|
+
exports.ENV_FILE_ENV = 'DAILY_HOT_API_ENV_FILE';
|
|
20
|
+
exports.DAEMON_CHILD_ENV = 'DAILY_HOT_API_DAEMON_CHILD';
|
|
21
|
+
function getPackageRoot() {
|
|
22
|
+
return (0, path_1.resolve)(__dirname, '..', '..');
|
|
23
|
+
}
|
|
24
|
+
function getBinPath() {
|
|
25
|
+
return (0, path_1.join)(getPackageRoot(), 'bin', `${exports.APP_NAME}.js`);
|
|
26
|
+
}
|
|
27
|
+
function getPackageVersion() {
|
|
28
|
+
try {
|
|
29
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(getPackageRoot(), 'package.json'), 'utf8'));
|
|
30
|
+
return typeof packageJson.version === 'string'
|
|
31
|
+
? packageJson.version
|
|
32
|
+
: '0.0.0';
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return '0.0.0';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function resolveHomeDir(options) {
|
|
39
|
+
const env = options.env ?? process.env;
|
|
40
|
+
const raw = options.home?.trim() || env[exports.HOME_ENV]?.trim();
|
|
41
|
+
if (!raw) {
|
|
42
|
+
return (0, path_1.join)((0, os_1.homedir)(), `.${exports.APP_NAME}`);
|
|
43
|
+
}
|
|
44
|
+
return (0, path_1.isAbsolute)(raw) ? (0, path_1.resolve)(raw) : (0, path_1.resolve)(options.cwd, raw);
|
|
45
|
+
}
|
|
46
|
+
function buildCliPaths(homeDir) {
|
|
47
|
+
const logDir = (0, path_1.join)(homeDir, 'logs');
|
|
48
|
+
return {
|
|
49
|
+
homeDir,
|
|
50
|
+
stateFile: (0, path_1.join)(homeDir, `${exports.APP_NAME}.json`),
|
|
51
|
+
logDir,
|
|
52
|
+
logFile: (0, path_1.join)(logDir, `${exports.APP_NAME}.log`),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function resolveEnvFile(options) {
|
|
56
|
+
const env = options.env ?? process.env;
|
|
57
|
+
const explicit = options.envFile?.trim() || env[exports.ENV_FILE_ENV]?.trim();
|
|
58
|
+
if (explicit) {
|
|
59
|
+
return {
|
|
60
|
+
path: (0, path_1.isAbsolute)(explicit)
|
|
61
|
+
? (0, path_1.resolve)(explicit)
|
|
62
|
+
: (0, path_1.resolve)(options.cwd, explicit),
|
|
63
|
+
explicit: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const cwdEnvFile = (0, path_1.join)(options.cwd, '.env');
|
|
67
|
+
if ((0, fs_1.existsSync)(cwdEnvFile)) {
|
|
68
|
+
return { path: cwdEnvFile, explicit: false };
|
|
69
|
+
}
|
|
70
|
+
const homeEnvFile = (0, path_1.join)(options.homeDir, '.env');
|
|
71
|
+
if ((0, fs_1.existsSync)(homeEnvFile)) {
|
|
72
|
+
return { path: homeEnvFile, explicit: false };
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/cli/paths.ts"],"names":[],"mappings":";;;AA4CA,wCAEC;AAGD,gCAEC;AAED,8CAWC;AAMD,wCAWC;AAED,sCAQC;AAUD,wCA4BC;AAjID,2BAA8C;AAC9C,2BAA6B;AAC7B,+BAAiD;AAEpC,QAAA,QAAQ,GAAG,eAAe,CAAC;AAG3B,QAAA,YAAY,GAAG,IAAI,CAAC;AAGpB,QAAA,4BAA4B,GAAG,EAAE,CAAC;AAGlC,QAAA,gBAAgB,GAAG,MAAM,CAAC;AAG1B,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAG7B,QAAA,QAAQ,GAAG,oBAAoB,CAAC;AAGhC,QAAA,YAAY,GAAG,wBAAwB,CAAC;AAMxC,QAAA,gBAAgB,GAAG,4BAA4B,CAAC;AAgB7D,SAAgB,cAAc;IAC5B,OAAO,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAGD,SAAgB,UAAU;IACxB,OAAO,IAAA,WAAI,EAAC,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,gBAAQ,KAAK,CAAC,CAAC;AAC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;AAUD,SAAgB,cAAc,CAAC,OAK9B;IACC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,oBAAY,CAAC,EAAE,IAAI,EAAE,CAAC;IACtE,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,IAAI,EAAE,IAAA,iBAAU,EAAC,QAAQ,CAAC;gBACxB,CAAC,CAAC,IAAA,cAAO,EAAC,QAAQ,CAAC;gBACnB,CAAC,CAAC,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC;YAClC,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC/C,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,IAAI,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type RunMode = 'foreground' | 'daemon';
|
|
2
|
+
export interface RunState {
|
|
3
|
+
pid: number;
|
|
4
|
+
port: number;
|
|
5
|
+
mode: RunMode;
|
|
6
|
+
startedAt: string;
|
|
7
|
+
cwd: string;
|
|
8
|
+
envFile: string | null;
|
|
9
|
+
logFile: string | null;
|
|
10
|
+
version: string;
|
|
11
|
+
entry: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RunStateReadResult {
|
|
14
|
+
state: RunState | null;
|
|
15
|
+
corrupt: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseRunState(raw: unknown): RunState | null;
|
|
18
|
+
export declare function readRunState(stateFile: string): RunStateReadResult;
|
|
19
|
+
export declare function writeRunState(stateFile: string, state: RunState): void;
|
|
20
|
+
export declare function clearRunState(stateFile: string, expectedPid?: number): 'cleared' | 'kept' | 'missing';
|
|
21
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
22
|
+
export declare function processLooksLikeService(pid: number, packageRoot?: string): boolean;
|
|
23
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
24
|
+
export declare function waitForProcessExit(pid: number, timeoutMs: number, intervalMs?: number): Promise<boolean>;
|
|
25
|
+
export declare function isPortInUse(port: number, host?: string, timeoutMs?: number): Promise<boolean>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRunState = parseRunState;
|
|
4
|
+
exports.readRunState = readRunState;
|
|
5
|
+
exports.writeRunState = writeRunState;
|
|
6
|
+
exports.clearRunState = clearRunState;
|
|
7
|
+
exports.isProcessAlive = isProcessAlive;
|
|
8
|
+
exports.processLooksLikeService = processLooksLikeService;
|
|
9
|
+
exports.sleep = sleep;
|
|
10
|
+
exports.waitForProcessExit = waitForProcessExit;
|
|
11
|
+
exports.isPortInUse = isPortInUse;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const net_1 = require("net");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const paths_1 = require("./paths");
|
|
17
|
+
function parseRunState(raw) {
|
|
18
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const value = raw;
|
|
22
|
+
const pid = value.pid;
|
|
23
|
+
const port = value.port;
|
|
24
|
+
if (typeof pid !== 'number' ||
|
|
25
|
+
!Number.isInteger(pid) ||
|
|
26
|
+
pid <= 0 ||
|
|
27
|
+
typeof port !== 'number' ||
|
|
28
|
+
!Number.isInteger(port) ||
|
|
29
|
+
port < 1 ||
|
|
30
|
+
port > 65535) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (value.mode !== 'foreground' && value.mode !== 'daemon') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value.startedAt !== 'string') {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
pid,
|
|
41
|
+
port,
|
|
42
|
+
mode: value.mode,
|
|
43
|
+
startedAt: value.startedAt,
|
|
44
|
+
cwd: typeof value.cwd === 'string' ? value.cwd : '',
|
|
45
|
+
envFile: typeof value.envFile === 'string' ? value.envFile : null,
|
|
46
|
+
logFile: typeof value.logFile === 'string' ? value.logFile : null,
|
|
47
|
+
version: typeof value.version === 'string' ? value.version : 'unknown',
|
|
48
|
+
entry: typeof value.entry === 'string' ? value.entry : '',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function readRunState(stateFile) {
|
|
52
|
+
if (!(0, fs_1.existsSync)(stateFile)) {
|
|
53
|
+
return { state: null, corrupt: false };
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse((0, fs_1.readFileSync)(stateFile, 'utf8'));
|
|
57
|
+
const state = parseRunState(parsed);
|
|
58
|
+
return { state, corrupt: state === null };
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return { state: null, corrupt: true };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeRunState(stateFile, state) {
|
|
65
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(stateFile), { recursive: true });
|
|
66
|
+
const tempFile = `${stateFile}.${process.pid}.tmp`;
|
|
67
|
+
(0, fs_1.writeFileSync)(tempFile, `${JSON.stringify(state, null, 2)}\n`, {
|
|
68
|
+
mode: 0o600,
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
(0, fs_1.renameSync)(tempFile, stateFile);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
(0, fs_1.rmSync)(stateFile, { force: true });
|
|
75
|
+
(0, fs_1.renameSync)(tempFile, stateFile);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function clearRunState(stateFile, expectedPid) {
|
|
79
|
+
if (!(0, fs_1.existsSync)(stateFile)) {
|
|
80
|
+
return 'missing';
|
|
81
|
+
}
|
|
82
|
+
if (expectedPid !== undefined) {
|
|
83
|
+
const { state } = readRunState(stateFile);
|
|
84
|
+
if (state && state.pid !== expectedPid) {
|
|
85
|
+
return 'kept';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
(0, fs_1.rmSync)(stateFile, { force: true });
|
|
89
|
+
return 'cleared';
|
|
90
|
+
}
|
|
91
|
+
function isProcessAlive(pid) {
|
|
92
|
+
if (!Number.isInteger(pid) || pid <= 0) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
process.kill(pid, 0);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return error.code === 'EPERM';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function processLooksLikeService(pid, packageRoot = (0, paths_1.getPackageRoot)()) {
|
|
104
|
+
if (!isProcessAlive(pid)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const result = (0, child_process_1.spawnSync)('ps', ['-p', String(pid), '-o', 'command='], {
|
|
108
|
+
encoding: 'utf8',
|
|
109
|
+
timeout: 2000,
|
|
110
|
+
});
|
|
111
|
+
if (result.error || result.status !== 0 || !result.stdout) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const commandLine = result.stdout.trim();
|
|
115
|
+
if (!commandLine) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
const markers = [
|
|
119
|
+
paths_1.APP_NAME,
|
|
120
|
+
`${packageRoot}/dist/main.js`,
|
|
121
|
+
`${packageRoot}/dist/cli/index.js`,
|
|
122
|
+
`${packageRoot}\\dist\\main.js`,
|
|
123
|
+
];
|
|
124
|
+
return markers.some((marker) => commandLine.includes(marker));
|
|
125
|
+
}
|
|
126
|
+
function sleep(ms) {
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
setTimeout(resolve, ms);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async function waitForProcessExit(pid, timeoutMs, intervalMs = 100) {
|
|
132
|
+
const deadline = Date.now() + timeoutMs;
|
|
133
|
+
while (Date.now() < deadline) {
|
|
134
|
+
if (!isProcessAlive(pid)) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
await sleep(intervalMs);
|
|
138
|
+
}
|
|
139
|
+
return !isProcessAlive(pid);
|
|
140
|
+
}
|
|
141
|
+
function isPortInUse(port, host = '127.0.0.1', timeoutMs = 500) {
|
|
142
|
+
return new Promise((resolve) => {
|
|
143
|
+
let settled = false;
|
|
144
|
+
const finish = (inUse) => {
|
|
145
|
+
if (settled) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
settled = true;
|
|
149
|
+
socket.destroy();
|
|
150
|
+
resolve(inUse);
|
|
151
|
+
};
|
|
152
|
+
const socket = (0, net_1.connect)({ host, port });
|
|
153
|
+
socket.setTimeout(timeoutMs);
|
|
154
|
+
socket.once('connect', () => finish(true));
|
|
155
|
+
socket.once('timeout', () => finish(false));
|
|
156
|
+
socket.once('error', () => finish(false));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=run-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../src/cli/run-state.ts"],"names":[],"mappings":";;AAkCA,sCAmCC;AAED,oC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AAG,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAGD,SAAgB,WAAW,CACzB,IAAY,EACZ,IAAI,GAAG,WAAW,EAClB,SAAS,GAAG,GAAG;IAEf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;YACtC,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,aAAO,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
2
|
+
import { NextFunction, Request, Response } from 'express';
|
|
3
|
+
export declare class LoggerMiddleware implements NestMiddleware {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
constructor();
|
|
6
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LoggerMiddleware = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
let LoggerMiddleware = class LoggerMiddleware {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logger = new common_1.Logger('daily-hot-api');
|
|
17
|
+
}
|
|
18
|
+
use(req, res, next) {
|
|
19
|
+
const info = `访问ip:${req.ip},访问路径:${req.originalUrl}`;
|
|
20
|
+
this.logger.log(info);
|
|
21
|
+
next();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.LoggerMiddleware = LoggerMiddleware;
|
|
25
|
+
exports.LoggerMiddleware = LoggerMiddleware = __decorate([
|
|
26
|
+
(0, common_1.Injectable)(),
|
|
27
|
+
__metadata("design:paramtypes", [])
|
|
28
|
+
], LoggerMiddleware);
|
|
29
|
+
//# sourceMappingURL=logger.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.middleware.js","sourceRoot":"","sources":["../../../src/common/middlewares/logger.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoE;AAI7D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,CAAC;IAC5C,CAAC;IACD,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACjD,MAAM,IAAI,GAAG,QAAQ,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,EAAE,CAAC;IACT,CAAC;CACF,CAAA;AAVY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;;GACA,gBAAgB,CAU5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AppConfigModule = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const validation_schema_1 = require("./validation.schema");
|
|
16
|
+
const configuration_1 = __importDefault(require("./configuration"));
|
|
17
|
+
let AppConfigModule = class AppConfigModule {
|
|
18
|
+
};
|
|
19
|
+
exports.AppConfigModule = AppConfigModule;
|
|
20
|
+
exports.AppConfigModule = AppConfigModule = __decorate([
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [
|
|
23
|
+
config_1.ConfigModule.forRoot({
|
|
24
|
+
isGlobal: true,
|
|
25
|
+
load: [configuration_1.default],
|
|
26
|
+
validate: (config) => {
|
|
27
|
+
try {
|
|
28
|
+
const validated = validation_schema_1.configValidationSchema.parse(config);
|
|
29
|
+
if (config.NODE_ENV === 'production' && !validated.MONGODB_URI) {
|
|
30
|
+
throw new Error('MONGODB_URI is required when NODE_ENV=production. ' +
|
|
31
|
+
'Set it in .env (see .env.example), or pass it to the process: ' +
|
|
32
|
+
'docker run -e MONGODB_URI=mongodb://<host>:27017/daily-hot-api');
|
|
33
|
+
}
|
|
34
|
+
return validated;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new Error(`配置验证失败: ${error}`);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
validationOptions: {
|
|
41
|
+
abortEarly: true,
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
], AppConfigModule);
|
|
47
|
+
//# sourceMappingURL=config.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../src/config/config.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAC9C,2DAA6D;AAC7D,oEAA4C;AA8BrC,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IA5B3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,CAAC,uBAAa,CAAC;gBACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;oBACnB,IAAI,CAAC;wBACH,MAAM,SAAS,GAAG,0CAAsB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;wBACvD,IAAI,MAAM,CAAC,QAAQ,KAAK,YAAY,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;4BAG/D,MAAM,IAAI,KAAK,CACb,oDAAoD;gCAClD,gEAAgE;gCAChE,gEAAgE,CACnE,CAAC;wBACJ,CAAC;wBACD,OAAO,SAAS,CAAC;oBACnB,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC;gBACD,iBAAiB,EAAE;oBACjB,UAAU,EAAE,IAAI;iBACjB;aACF,CAAC;SACH;KACF,CAAC;GACW,eAAe,CAAG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validation_schema_1 = require("./validation.schema");
|
|
4
|
+
exports.default = () => validation_schema_1.configValidationSchema.parse(process.env);
|
|
5
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/config/configuration.ts"],"names":[],"mappings":";;AAAA,2DAAyE;AAGzE,kBAAe,GAAe,EAAE,CAAC,0CAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC"}
|