diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8fddc71..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "thinapps-shared"] - path = thinapps-shared - url = git@github.com:jina-ai/thinapps-shared.git diff --git a/backend/.firebaserc b/backend/.firebaserc index f585142..e975ebe 100644 --- a/backend/.firebaserc +++ b/backend/.firebaserc @@ -1,5 +1,5 @@ { "projects": { - "default": "reader-6b7dc" + "default": "reader-clone" } } diff --git a/backend/functions/src/cloud-functions/crawler.ts b/backend/functions/src/cloud-functions/crawler.ts index a4a2c8f..3da04f7 100644 --- a/backend/functions/src/cloud-functions/crawler.ts +++ b/backend/functions/src/cloud-functions/crawler.ts @@ -5,7 +5,7 @@ import { AssertionFailureError, ParamValidationError, Defer, } from 'civkit'; import { singleton } from 'tsyringe'; -import { AsyncContext, CloudHTTPv2, FirebaseStorageBucketControl, Logger, OutputServerEventStream, RPCReflect } from '../shared'; +import { AsyncContext, CloudHTTPv2, FirebaseStorageBucketControl, Logger, OutputServerEventStream, RPCReflect } from '../shared/index'; import _ from 'lodash'; import { PageSnapshot, PuppeteerControl, ScrappingOptions } from '../services/puppeteer'; import { Request, Response } from 'express'; @@ -24,6 +24,8 @@ import { JSDomControl } from '../services/jsdom'; const md5Hasher = new HashManager('md5', 'hex'); +// const logger = new Logger('Crawler'); + export interface ExtraScrappingOptions extends ScrappingOptions { withIframe?: boolean; targetSelector?: string | string[]; @@ -61,7 +63,7 @@ const indexProto = { @singleton() export class CrawlerHost extends RPCHost { - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('Crawler'); turnDownPlugins = [require('turndown-plugin-gfm').tables]; @@ -71,7 +73,6 @@ export class CrawlerHost extends RPCHost { abuseBlockMs = 1000 * 3600; constructor( - protected globalLogger: Logger, protected puppeteerControl: PuppeteerControl, protected jsdomControl: JSDomControl, // protected altTextService: AltTextService, diff --git a/backend/functions/src/services/geoip.ts b/backend/functions/src/services/geoip.ts index b6b4781..50e21e5 100644 --- a/backend/functions/src/services/geoip.ts +++ b/backend/functions/src/services/geoip.ts @@ -2,7 +2,7 @@ import { container, singleton } from 'tsyringe'; import fsp from 'fs/promises'; import { CityResponse, Reader } from 'maxmind'; import { AsyncService, AutoCastable, Prop, runOnce } from 'civkit'; -import { Logger } from '../shared'; +import { Logger } from '../shared/index'; import path from 'path'; export enum GEOIP_SUPPORTED_LANGUAGES { @@ -56,12 +56,11 @@ export class GeoIPCityResponse extends AutoCastable { @singleton() export class GeoIPService extends AsyncService { - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('CHANGE_LOGGER_NAME') mmdbCity!: Reader; constructor( - protected globalLogger: Logger, ) { super(...arguments); } diff --git a/backend/functions/src/services/jsdom.ts b/backend/functions/src/services/jsdom.ts index 6e67043..020ffa8 100644 --- a/backend/functions/src/services/jsdom.ts +++ b/backend/functions/src/services/jsdom.ts @@ -1,6 +1,6 @@ import { container, singleton } from 'tsyringe'; import { AsyncService, marshalErrorLike } from 'civkit'; -import { Logger } from '../shared/logger'; +import { Logger } from '../shared/index'; import { ExtendedSnapshot, PageSnapshot } from './puppeteer'; import { JSDOM, VirtualConsole } from 'jsdom'; import { Readability } from '@mozilla/readability'; @@ -12,10 +12,9 @@ virtualConsole.on('error', () => void 0); @singleton() export class JSDomControl extends AsyncService { - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('CHANGE_LOGGER_NAME') constructor( - protected globalLogger: Logger, ) { super(...arguments); } diff --git a/backend/functions/src/services/puppeteer.ts b/backend/functions/src/services/puppeteer.ts index 24c22e0..8d53311 100644 --- a/backend/functions/src/services/puppeteer.ts +++ b/backend/functions/src/services/puppeteer.ts @@ -2,7 +2,7 @@ import os from 'os'; import fs from 'fs'; import { container, singleton } from 'tsyringe'; import { AsyncService, Defer, marshalErrorLike, AssertionFailureError, delay, maxConcurrency } from 'civkit'; -import { Logger } from '../shared/logger'; +import { Logger } from '../shared/index'; import type { Browser, CookieParam, Page } from 'puppeteer'; import puppeteer from 'puppeteer-extra'; @@ -11,7 +11,7 @@ import puppeteerBlockResources from 'puppeteer-extra-plugin-block-resources'; import puppeteerPageProxy from 'puppeteer-extra-plugin-page-proxy'; import { SecurityCompromiseError, ServiceCrashedError } from '../shared/errors'; import { TimeoutError } from 'puppeteer'; -const tldExtract = require('tld-extract'); +import tldExtract from 'tld-extract'; const READABILITY_JS = fs.readFileSync(require.resolve('@mozilla/readability/Readability.js'), 'utf-8'); @@ -203,7 +203,7 @@ export class PuppeteerControl extends AsyncService { _sn = 0; browser!: Browser; - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('CHANGE_LOGGER_NAME') private __healthCheckInterval?: NodeJS.Timeout; @@ -217,7 +217,6 @@ export class PuppeteerControl extends AsyncService { circuitBreakerHosts: Set = new Set(); constructor( - protected globalLogger: Logger, ) { super(...arguments); this.setMaxListeners(2 * Math.floor(os.totalmem() / (256 * 1024 * 1024)) + 1); 148 - 95; diff --git a/backend/functions/src/shared/logger.ts b/backend/functions/src/shared/logger.ts index fa258b5..02040d0 100644 --- a/backend/functions/src/shared/logger.ts +++ b/backend/functions/src/shared/logger.ts @@ -1,3 +1,6 @@ +import { injectable } from 'tsyringe'; + +@injectable() export class Logger { constructor(private name: string) {} diff --git a/backend/functions/src/shared/services/canvas.ts b/backend/functions/src/shared/services/canvas.ts index 70787c2..8fb6ff4 100644 --- a/backend/functions/src/shared/services/canvas.ts +++ b/backend/functions/src/shared/services/canvas.ts @@ -4,9 +4,9 @@ import { Logger } from '../logger'; @singleton() export class CanvasService extends AsyncService { - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('CHANGE_LOGGER_NAME') - constructor(protected globalLogger: Logger) { + constructor() { super(); } diff --git a/backend/functions/src/shared/services/secrets.ts b/backend/functions/src/shared/services/secrets.ts index 2fc76fd..e56656a 100644 --- a/backend/functions/src/shared/services/secrets.ts +++ b/backend/functions/src/shared/services/secrets.ts @@ -4,11 +4,11 @@ import { Logger } from '../logger'; @singleton() export class SecretExposer extends AsyncService { - logger = this.globalLogger.child({ service: this.constructor.name }); + logger = new Logger('CHANGE_LOGGER_NAME') BRAVE_SEARCH_API_KEY: string = 'mock_brave_search_api_key'; - constructor(protected globalLogger: Logger) { + constructor() { super(); } diff --git a/thinapps-shared b/thinapps-shared deleted file mode 160000 index fe71cc2..0000000 --- a/thinapps-shared +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fe71cc2433f60ada86622f1670a752da40806e4d