Socket
Socket
Sign inDemoInstall

@queue-it/connector-cloudfront

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @queue-it/connector-cloudfront

Connector Cloudfront


Version published
Maintainers
1
Created

Readme

Source

connector-cloudfront

npm version

Before getting started please read the documentation to get acquainted with edge connectors.

This repository contains two AWS lambda functions you can add to your CloudFront distribution events ViewerRequest and ViewerResponse to integrate queue-it functionality into your backend.

Installation

  • Download the ViewerRequest.zip and ViewerResponse.zip files from the latest release.

  • Set your CustomerId, SecretKey and ApiKey in environmentvariables.json file in ViewerRequest folder.

  • Create two lambda edge functions, one for ViewerRequest and one for ViewerResponse and put the code from this repository there respectively.

  • Define your desired CloudFront behaviours where you want to be protected by queue and set CloudFront events ViewerRequest and ViewerResponse to point to the two functions you just created.

** Please make sure the code is living in the highest level in our lambda definition as it shown here.

Using the NPM package

Install @queue-it/connector-cloudfront and use it like this:

  • In your ViewerRequest lambda you need to add this.
import {onClientRequest, setIntegrationDetails} from "@queue-it/connector-cloudfront";

// Remember to set your environment variables 

const queueItResponse = await onClientRequest(cloudfrontEvent);
// We got a valid response, return it to the user.
if (queueItResponse.status) {
    return queueItResponse;
}
  • In your ViewerResponse lambda you need to add this.
import {onClientResponse} from "../";

// Place this in the place where you handle the incoming cloudfront events.

const response = await onClientResponse(cloudfrontEvent);
return response;

Request body trigger (advanced)

The connector supports triggering on request body content. An example could be a POST call with specific item ID where you want end-users to queue up for. For this to work, you will need to contact queue-it support, so it can be enabled on your GO Queue-it platform account.
Once enabled, you will need to check the Include body checkbox in the ViewerRequest function associations. This can be done by editing your CloudFront distribution behaviors.

Queue-it variables

VariableRequiredValue
QUEUEIT_CUSTOMER_IDYesFind your Customer ID in the GO Queue-it platform.
QUEUEIT_SECRET_KEYYesYour 72 char secret key as specified in Go Queue-it self-service platform.
QUEUEIT_API_KEYYesFind your API key in the GO Queue-it platform.
QUEUEIT_ENQT_ENABLEDNoDefault: true If you do not need to add the enqueue token then set the value to false.
QUEUEIT_ENQT_VALIDITY_TIMENoRecommandation: 240000 ms or > 30000 ms
QUEUEIT_ENQT_KEY_ENABLEDNoDefault: false If you need to include custom key in the enqueue token then set value to true.

EnqueueToken

An enqueue token can be used for allowing access to waiting room(s). Any user without it can't join the queue. The token will be included when the user is redirected from the connector to the queue. QueueToken package has been used to generate this token. The generated token will be valid for 4 minute.

Follow the steps below to enable use of enqueue token:

  • The waiting room should be configured to require token to enter it. Use Queue-it Go platform or API to setup your waiting room.
  • Add a variable with name QUEUEIT_ENQT_ENABLED in settings as mentioned in the example code and value 'true'.

FAQs

Last updated on 14 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc