Fake Mirrors
    Preparing search index...

    Interface TargetRepository

    Defines the public contract for a target repository.

    A target contains the configuration that maps a mirror server to a donor server.

    interface TargetRepository {
        appendLabel(
            campaignId: string,
            targetId: string,
            label: string,
            lockSecret: string,
        ): Promise<void>;
        create(
            campaignId: string,
            targetId: string,
            accessLevel: "transparent" | "landing",
            donorSecure: boolean,
            donorSub: string,
            donorDomain: string,
            donorPort: number,
            mirrorSecure: boolean,
            mirrorSub: string,
            mirrorPort: number,
            connectTimeout: number,
            simpleTimeout: number,
            streamTimeout: number,
            headersSizeLimit: number,
            bodySizeLimit: number,
            mainPage: string,
            notFoundPage: string,
            faviconIco: string,
            robotsTxt: string,
            sitemapXml: string,
            allowWebSockets: boolean,
            lockSecret: string,
        ): Promise<void>;
        delete(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        disable(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        enable(
            campaignId: string,
            targetId: string,
            lockSecret: string,
        ): Promise<void>;
        find(mirrorHost: string): Promise<TargetModel | null>;
        findFull(mirrorHost: string): Promise<FullTargetModel | null>;
        list(campaignId: string): Promise<TargetModel[] | null>;
        listFull(campaignId: string): Promise<FullTargetModel[] | null>;
        read(campaignId: string, targetId: string): Promise<TargetModel | null>;
        readFull(
            campaignId: string,
            targetId: string,
        ): Promise<FullTargetModel | null>;
        readHosts(): Promise<TargetHosts>;
        removeLabel(
            campaignId: string,
            targetId: string,
            label: string,
            lockSecret: string,
        ): Promise<void>;
        update(
            campaignId: string,
            targetId: string,
            connectTimeout: number | null | undefined,
            simpleTimeout: number | null | undefined,
            streamTimeout: number | null | undefined,
            headersSizeLimit: number | null | undefined,
            bodySizeLimit: number | null | undefined,
            mainPage: string | null | undefined,
            notFoundPage: string | null | undefined,
            faviconIco: string | null | undefined,
            robotsTxt: string | null | undefined,
            sitemapXml: string | null | undefined,
            allowWebSockets: boolean | null | undefined,
            lockSecret: string,
        ): Promise<void>;
    }

    Implemented by

    • Appends a label to the target.

      Labels are used for categorization and filtering of targets. The label is automatically converted to lowercase.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to append label to.

      • label: string

        The label to append to the target.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the data validation fails.

    • Creates a new target.

      The target will be created in a disabled state (isEnabled = false). Use enable to activate it for traffic routing.

      Parameters

      • campaignId: string

        The ID of the campaign to create the target in.

      • targetId: string

        The new target ID to create.

      • accessLevel: "transparent" | "landing"

        The access level.

      • donorSecure: boolean

        The flag indicating if the donor server uses HTTPS.

      • donorSub: string

        The donor subdomain.

      • donorDomain: string

        The donor domain name.

      • donorPort: number

        The donor server port.

      • mirrorSecure: boolean

        The flag indicating if the mirror server uses HTTPS.

      • mirrorSub: string

        The mirror subdomain.

      • mirrorPort: number

        The mirror server port.

      • connectTimeout: number

        The connection timeout in milliseconds.

      • simpleTimeout: number

        The simple request timeout in milliseconds.

      • streamTimeout: number

        The streaming request timeout in milliseconds.

      • headersSizeLimit: number

        The maximum headers size in bytes.

      • bodySizeLimit: number

        The maximum body size in bytes.

      • mainPage: string

        The custom main page content.

      • notFoundPage: string

        The custom not-found page content.

      • faviconIco: string

        The custom favicon.ico content.

      • robotsTxt: string

        The custom robots.txt content.

      • sitemapXml: string

        The custom sitemap.xml content.

      • allowWebSockets: boolean

        The flag indicating if WebSocket connections allowed.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If a target with the same ID already exists.

      DatabaseError If the target donor is already used.

      DatabaseError If the target mirror is already used.

      DatabaseError If the data validation fails.

    • Deletes the target by its ID.

      The target must be disabled before it can be deleted.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to delete.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the target is still enabled.

      DatabaseError If the data validation fails.

    • Disables the target, stopping traffic routing.

      When disabled, requests to the mirror hostname will not be proxied.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to disable.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the data validation fails.

    • Enables the target, making it available for traffic routing.

      When enabled, the mirror hostname becomes active and can be used for proxying requests to the donor server.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to enable.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the data validation fails.

    • Finds a target by its mirror hostname.

      This is the primary lookup method for routing incoming HTTP requests. Given a Host header from a request, it returns the corresponding target.

      Parameters

      • mirrorHost: string

        The mirror hostname to look up.

      Returns Promise<TargetModel | null>

      The target model, or null if no target matches the hostname.

      DatabaseError If the data validation fails.

    • Lists all targets for the campaign.

      Targets are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list targets for.

      Returns Promise<TargetModel[] | null>

      The array of target models, or null if the campaign does not exist.

      DatabaseError If the data validation fails.

    • Removes a label from the target.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to remove label from.

      • label: string

        The label to remove from the target.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the data validation fails.

    • Updates the target specific fields.

      All update parameters are optional. Only provided fields will be updated.

      Parameters

      • campaignId: string

        The ID of the campaign containing the target.

      • targetId: string

        The target ID to update.

      • connectTimeout: number | null | undefined

        The connection timeout in milliseconds.

      • simpleTimeout: number | null | undefined

        The simple request timeout in milliseconds.

      • streamTimeout: number | null | undefined

        The streaming request timeout in milliseconds.

      • headersSizeLimit: number | null | undefined

        The maximum headers size in bytes.

      • bodySizeLimit: number | null | undefined

        The maximum body size in bytes.

      • mainPage: string | null | undefined

        The custom main page content.

      • notFoundPage: string | null | undefined

        The custom not-found page content.

      • faviconIco: string | null | undefined

        The custom favicon.ico content.

      • robotsTxt: string | null | undefined

        The custom robots.txt content.

      • sitemapXml: string | null | undefined

        The custom sitemap.xml content.

      • allowWebSockets: boolean | null | undefined

        The flag indicating if WebSocket connections allowed.

      • lockSecret: string

        The campaign lock secret obtained from CampaignRepository.lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the campaign lock secret does not match.

      DatabaseError If the target does not exist.

      DatabaseError If the data validation fails.