-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,880 additions
and
2,882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,91 @@ | ||
import { | ||
APIGatewayClient, | ||
CreateRestApiCommand, | ||
CreateRestApiCommandOutput, | ||
DeleteRestApiCommand, | ||
GetBasePathMappingsCommand, | ||
GetBasePathMappingsCommandOutput, GetDomainNameCommand, GetDomainNameCommandOutput, | ||
GetResourcesCommand, | ||
GetResourcesCommandOutput | ||
APIGatewayClient, | ||
CreateRestApiCommand, | ||
CreateRestApiCommandOutput, | ||
DeleteRestApiCommand, | ||
GetBasePathMappingsCommand, | ||
GetBasePathMappingsCommandOutput, GetDomainNameCommand, GetDomainNameCommandOutput, | ||
GetResourcesCommand, | ||
GetResourcesCommandOutput | ||
} from "@aws-sdk/client-api-gateway"; | ||
import Globals from "../../src/globals"; | ||
|
||
export default class APIGatewayWrap { | ||
private client: APIGatewayClient; | ||
|
||
constructor(region: string) { | ||
this.client = new APIGatewayClient({ | ||
region, | ||
retryStrategy: Globals.getRetryStrategy() | ||
}); | ||
constructor (region: string) { | ||
this.client = new APIGatewayClient({ | ||
region, | ||
retryStrategy: Globals.getRetryStrategy() | ||
}); | ||
} | ||
|
||
/** | ||
* Make API Gateway calls to create an API Gateway | ||
* @param {string} restApiName | ||
* @return {Object} Contains restApiId and resourceId | ||
*/ | ||
public async setupApiGatewayResources(restApiName) { | ||
const restAPI: CreateRestApiCommandOutput = await this.client.send( | ||
new CreateRestApiCommand({name: restApiName}) | ||
) | ||
public async setupApiGatewayResources (restApiName) { | ||
const restAPI: CreateRestApiCommandOutput = await this.client.send( | ||
new CreateRestApiCommand({ name: restApiName }) | ||
); | ||
|
||
const restApiId = restAPI.id; | ||
const resources: GetResourcesCommandOutput = await this.client.send( | ||
new GetResourcesCommand({restApiId}) | ||
) | ||
const restApiId = restAPI.id; | ||
const resources: GetResourcesCommandOutput = await this.client.send( | ||
new GetResourcesCommand({ restApiId }) | ||
); | ||
|
||
const resourceId = resources.items[0].id; | ||
return {restApiId, resourceId}; | ||
const resourceId = resources.items[0].id; | ||
return { restApiId, resourceId }; | ||
} | ||
|
||
/** | ||
* Make API Gateway calls to delete an API Gateway | ||
* @param {string} restApiId | ||
* @return {boolean} Returns true if deleted | ||
*/ | ||
public async deleteApiGatewayResources(restApiId) { | ||
return await this.client.send( | ||
new DeleteRestApiCommand({restApiId}) | ||
); | ||
public async deleteApiGatewayResources (restApiId) { | ||
return await this.client.send( | ||
new DeleteRestApiCommand({ restApiId }) | ||
); | ||
} | ||
|
||
/** | ||
* Gets stage of given URL from AWS | ||
* @param domainName | ||
* @returns {Promise<String>} | ||
*/ | ||
public async getStage(domainName) { | ||
const result: GetBasePathMappingsCommandOutput = await this.client.send( | ||
new GetBasePathMappingsCommand({domainName}) | ||
) | ||
public async getStage (domainName) { | ||
const result: GetBasePathMappingsCommandOutput = await this.client.send( | ||
new GetBasePathMappingsCommand({ domainName }) | ||
); | ||
|
||
return result.items[0].stage; | ||
return result.items[0].stage; | ||
} | ||
|
||
/** | ||
* Gets basePath of given URL from AWS | ||
* @param domainName | ||
* @returns {Promise<String>} | ||
*/ | ||
public async getBasePath(domainName) { | ||
const result: GetBasePathMappingsCommandOutput = await this.client.send( | ||
new GetBasePathMappingsCommand({domainName}) | ||
) | ||
public async getBasePath (domainName) { | ||
const result: GetBasePathMappingsCommandOutput = await this.client.send( | ||
new GetBasePathMappingsCommand({ domainName }) | ||
); | ||
|
||
return result.items[0].basePath; | ||
return result.items[0].basePath; | ||
} | ||
|
||
/** | ||
* Gets endpoint type of given URL from AWS | ||
* @param domainName | ||
* @returns {Promise<String>} | ||
*/ | ||
public async getEndpointType(domainName) { | ||
const result: GetDomainNameCommandOutput = await this.client.send( | ||
new GetDomainNameCommand({domainName}) | ||
) | ||
public async getEndpointType (domainName) { | ||
const result: GetDomainNameCommandOutput = await this.client.send( | ||
new GetDomainNameCommand({ domainName }) | ||
); | ||
|
||
return result.endpointConfiguration.types[0]; | ||
return result.endpointConfiguration.types[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.