Exports an async function that creates the "/client" resource with a GET method on it. This is the endpoint our users can hit to verify that one of their users hasn't skipped the waiting room. That request from the final destination to here will have the cookie, which has the token. This endpoint takes that token and checks the DB to see if it is there.
(require("deployClientCheckRoute"))(restApiId, region, apiGatewayName, dynamoName, roleArn, stageName, protectUrl) → {String}
Exports deployClientCheckRoute()
Parameters:
Name | Type | Description |
---|---|---|
restApiId |
String | The id referring to the API Gateway |
region |
String | A constant destructured from the CLI user's answers in |
apiGatewayName |
String | A constant created in |
dynamoName |
String | Constant initialized in |
roleArn |
String | Amazon resource number for the kitchen sink role returned by |
stageName |
String | A constant "prod" |
protectUrl |
String | A constant destructured from the CLI user's answers in |
Returns:
A URL that the final destination can use to check that a given user didn't skip the waiting room, looks like https://${restApiId}.execute-api.${region}.amazonaws.com/${stageName}/${clientCheckResourceName}
;
- Type
- String
Methods
(async, inner) createResource(apiGateway, restApiId, resourceParentId, resourceName) → {String}
Creates a subresource "/client" of root
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
restApiId |
String | The string returned from |
resourceParentId |
String | The id of the root resource returned from |
resourceName |
String | A constant "client" |
Returns:
A resourceId referring to this new resource
- Type
- String
(async, inner) deployResource(apiGateway, restApiId, stageName)
Now that the API Gateway was created and all resources and their methods are added, we deploy the API Gateway.
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
restApiId |
String | The string returned from |
stageName |
String | A constant "prod" |
(async, inner) getResources(apiGateway, restApiId, apiGatewayName) → {String}
Function which gets the id of the root resource "/" of the API Gateway originally created in deployApiGateway()
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
restApiId |
String | ID refering to the API Gateway. Was returned from |
apiGatewayName |
String | A constant from |
Returns:
An id which refers to the root resource of the API Gateway, i.e. "/"
- Type
- String
(async, inner) putMethodRequest(apiGateway, restApiId, clientCheckResourceId, clientCheckResourceName)
Our "/client" endpoint has one method it handles, a GET request. This function creates it and customizes a header for the request named cookie
so that it can be grabbed off the request at the next stage.
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like new |
restApiId |
String | The string returned from |
clientCheckResourceId |
String | Id referring to the "/client" resource returned from |
clientCheckResourceName |
String | A constant "client" |
(async, inner) setIntegrationRequest(apiGateway, clientCheckResourceId, restApiId, dynamoDbUri, clientCheckResourceName, roleArn, dynamoName)
Instead of triggering a Lambda, this resource uses a template to access the cookie
value off the request headers and then performs a direct query of the DB to see if the token exists.
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
clientCheckResourceId |
String | Id referring to the the "/client" resource we created. |
restApiId |
String | The string returned from |
dynamoDbUri |
String | Uri that references the DynamoDB |
clientCheckResourceName |
String | Constant is "client" |
roleArn |
String | Amazon resource number for the kitchen sink role returned by |
dynamoName |
String | Constant initialized in |
(async, inner) setIntegrationResponse(apiGateway, clientCheckResourceId, restApiId, clientCheckResourceName, protectUrl)
Creates the Integration Response stage of the API Gateway and makes customizations. We add specific headers to the response to allow CORS and since credentials are being sent with the original request to this resource, we have to specifically interpolate the URL we want the browswer to allow for Access-Control-Allow-Origin. We also use a template to take the response from the DB and construct an object to send back to the client with one property "allow" that will be a boolean.
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
clientCheckResourceId |
String | Id referring to the the "/client" resource we created. |
restApiId |
String | The string returned from |
clientCheckResourceName |
String | Constant is "client" |
protectUrl |
String | A constant destructured from the CLI user's answers in |
(async, inner) setMethodResponse(apiGateway, clientCheckResourceId, restApiId, clientCheckResourceName)
Creates the Method Response stage. Of note is the creation of headers for CORS purposes. The values start out as false when creating them, but are changed in setIntegrationResponse()
Parameters:
Name | Type | Description |
---|---|---|
apiGateway |
APIGatewayClient | Looks like |
clientCheckResourceId |
String | Id referring to the the "/client" resource we created. |
restApiId |
String | The string returned from |
clientCheckResourceName |
String | Constant is "client" |