Fake Mirrors
    Preparing search index...

    Class RedisRedirectorRepository

    Redis-based redirector repository implementation.

    Depends:

    import { DIContainer } from '@famir/common'
    import { RedisRedirectorRepository } from '@famir/database'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register dependency in container
    RedisRedirectorRepository.register(container)
    import { DIContainer } from '@famir/common'
    import { REDIRECTOR_REPOSITORY, RedirectorRepository } from '@famir/domain'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Resolve dependency from container
    const redirectorRepository = container.resolve<RedirectorRepository>(REDIRECTOR_REPOSITORY)

    // Read 'simple' redirector from 'hackernews' campaign
    const redirector = await redirectorRepository.read('hackernews', 'simple')
    console.log(redirector)

    Hierarchy (View Summary)

    Implements

    • Appends multiple required fields to the redirector.

      When rendering a redirector with required fields, all specified fields must be provided in the parameters. If the fields array is empty, the redirector is 'loose' and accepts any parameters.

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector ID to append field to.

      • fields: string[]

        The field names to append to the fields list.

      • 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 redirector does not exist.

      DatabaseError If the data validation fails.

    • Creates a new redirector.

      The redirector is created with an empty fields array, meaning it is initially 'loose' (accepts any parameters). Use appendFields or removeFields to manage required fields.

      Parameters

      • campaignId: string

        The ID of the campaign to create the redirector in.

      • redirectorId: string

        The new redirector ID to create.

      • page: string

        The page template.

      • 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 redirector with the same ID already exists.

      DatabaseError If the data validation fails.

    • Deletes the redirector by its ID.

      A redirector cannot be deleted if it has any lures pointing to it.

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector 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 redirector does not exist.

      DatabaseError If the redirector still has lures.

      DatabaseError If the data validation fails.

    • Lists all redirectors for the campaign.

      Redirectors are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list redirectors for.

      Returns Promise<RedirectorModel[] | null>

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

      DatabaseError If the data validation fails.

    • Lists all full redirectors for the campaign.

      Redirectors are ordered by creation time (oldest first).

      Parameters

      • campaignId: string

        The ID of the campaign to list redirectors for.

      Returns Promise<FullRedirectorModel[] | null>

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

      DatabaseError If the data validation fails.

    • Reads the redirector by its ID.

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector ID to read.

      Returns Promise<RedirectorModel | null>

      The redirector model, or null if the redirector is not found.

      DatabaseError If the data validation fails.

    • Reads the full redirector by its ID.

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector ID to read.

      Returns Promise<FullRedirectorModel | null>

      The full redirector model, or null if the redirector is not found.

      DatabaseError If the data validation fails.

    • Removes all fields from the redirector.

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector ID to remove fields from.

      • 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 redirector does not exist.

      DatabaseError If the data validation fails.

    • Updates the redirector specific fields.

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

      Parameters

      • campaignId: string

        The ID of the campaign containing the redirector.

      • redirectorId: string

        The redirector ID to update.

      • page: string

        The page template.

      • 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 redirector does not exist.

      DatabaseError If the data validation fails.

    • Registers the redirector repository as a singleton in the DI container.

      Parameters

      • container: DIContainer

        The DI container to register in.

      Returns void