mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-04-18 11:50:00 +08:00

* fix: fine allow redefining Function.prototype.toString * wip * wip * wip * wip * wip * wip * wip * fix: contentType encoding * wip * fix: error throwing * wip * fix * wip * fix * fix * fix: jsdom * wip * wip * fix: links summary uniqueness * wip * wip * robots-txt catch no robots.txt * deps: remove puppeteer-extra-plugin-stealth * fix: dont change waring type * fix: curl * fix: replace firebase-roundtrip-check with blackhole-detector * fix: black hole detection * sercher: black hole detecting * fix: no h2c for searcher * fix: bhd * fix: search and crawl conflict * fix: bhd * fix * fix: server script * canvas: fixed avif issue * logging: move some to debug * fix * fix: pptr declare ready only when page can be created without issues * fix: bhd * cd: cloud run deploy-health-check cannot complete pptr newPage * cd: fix * fix: curl body can be null * fix * fix * fix: major fix regarding TC pdfs * fix * fix * deps: fix civkit trie router issue * fix * boom: total restructure * cd: fix docker ctx * fix * fix: switch to h2c * cd: ensure http2
39 lines
1018 B
TypeScript
39 lines
1018 B
TypeScript
import { container, singleton } from 'tsyringe';
|
|
import { AsyncService } from 'civkit/async-service';
|
|
import { Logger, SecretExposer } from '../shared';
|
|
import { CloudFlareHTTP } from '../shared/3rd-party/cloud-flare';
|
|
|
|
@singleton()
|
|
export class CFBrowserRendering extends AsyncService {
|
|
|
|
logger = this.globalLogger.child({ service: this.constructor.name });
|
|
client!: CloudFlareHTTP;
|
|
|
|
constructor(
|
|
protected globalLogger: Logger,
|
|
protected secretExposer: SecretExposer,
|
|
) {
|
|
super(...arguments);
|
|
}
|
|
|
|
|
|
override async init() {
|
|
await this.dependencyReady();
|
|
const [account, key] = this.secretExposer.CLOUD_FLARE_API_KEY?.split(':');
|
|
this.client = new CloudFlareHTTP(account, key);
|
|
|
|
this.emit('ready');
|
|
}
|
|
|
|
async fetchContent(url: string) {
|
|
const r = await this.client.fetchBrowserRenderedHTML({ url });
|
|
|
|
return r.parsed.result;
|
|
}
|
|
|
|
}
|
|
|
|
const instance = container.resolve(CFBrowserRendering);
|
|
|
|
export default instance;
|