Fake Mirrors
    Preparing search index...

    Class RedisCampaignRepository

    Redis-based campaign repository implementation.

    Depends:

    import { DIContainer } from '@famir/common'
    import { CAMPAIGN_REPOSITORY, CampaignRepository, RedisCampaignRepository } from '@famir/database'

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

    // Register dependency in container
    RedisCampaignRepository.register(container)

    // Resolve dependency from container
    const campaignRepository = container.resolve<CampaignRepository>(CAMPAIGN_REPOSITORY)

    // TODO more examples

    Implements

    • Creates a new campaign.

      Parameters

      • campaignId: string

        The new campaign ID to create.

      • mirrorDomain: string

        The public-facing mirror domain for the campaign.

      • description: string

        The human-readable description for the campaign.

      • cryptSecret: string

        The secret used for encrypting session data.

      • upgradeSessionPath: string

        The URL path that triggers session upgrade.

      • sessionCookieName: string

        The name of the cookie used to track authorized sessions.

      • sessionExpire: number

        The TTL for an authorized session in milliseconds.

      • newSessionExpire: number

        The TTL for a not-yet-authorized session in milliseconds.

      • messageExpire: number

        The TTL for a message in milliseconds.

      Returns Promise<void>

      DatabaseError If a campaign with the same ID already exists.

      DatabaseError If the mirror domain is already used by another campaign.

      DatabaseError If the session cookie name is already used by another campaign.

      DatabaseError If the data validation fails.

    • Updates the campaign specific fields.

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

      Parameters

      • campaignId: string

        The campaign ID to update.

      • description: string | null | undefined

        The new human-readable description for the campaign.

      • sessionExpire: number | null | undefined

        The new TTL for an authorized session in milliseconds.

      • newSessionExpire: number | null | undefined

        The new TTL for a not-yet-authorized session in milliseconds.

      • messageExpire: number | null | undefined

        The new TTL for a message in milliseconds.

      • lockSecret: string

        The lock secret obtained from lock.

      Returns Promise<void>

      DatabaseError If the campaign does not exist.

      DatabaseError If the campaign is not locked.

      DatabaseError If the lock secret does not match.

      DatabaseError If the data validation fails.