@webshop/root - v1.0.0
    Preparing search index...

    Service responsible for handling shipping logic. Calculates shipping costs, creates fake deliveries and sends fake track & trace emails.

    apps/api/src/services/ShippingService.ts

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _databaseService: DatabaseService = ...
    FREE_SHIPPING_THRESHOLD: number = 50
    SHIPPING_COST: number = 4.99

    Methods

    • Generates a fake track & trace code. starting with "TT".

      Returns string

      A random track & trace string.

    • Calculates an estimated delivery date 3 business days from now.

      Returns string

      A date string in Dutch format.

    • Calculates the shipping cost based on the order total. Orders above €50 get free shipping.

      Parameters

      • orderTotal: number

        The total price of the order.

      Returns IShippingCostResult

      The shipping cost and total including shipping.

    • Creates a fake delivery for a user and returns a track & trace code. Also sends a track & trace email to the customer.

      Parameters

      • userId: number

        The ID of the user placing the order.

      • orderTotal: number

        The total price of the order.

      Returns Promise<IDeliveryResult>

      A DeliveryResult with track & trace and cost details.

    • Retrieves all deliveries for a given user, ordered by creation date descending.

      Parameters

      • userId: number

        The ID of the user.

      Returns Promise<IUserDelivery[]>

      An array of UserDelivery objects.

    • Sends a fake track & trace email to the customer (logs to console).

      Parameters

      • email: string

        The customer's email address.

      • trackAndTrace: string

        The track & trace code.

      • estimatedDelivery: string

        The estimated delivery date.

      Returns void