-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (25 loc) · 1.06 KB
/
index.js
File metadata and controls
28 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as load from '../util/load'
import parseApi from '../util/parse-api'
export default async function list (opts) {
const api = await load.api() || {}
let endpoints = parseApi(api)
endpoints = endpoints
.filter(endpoint => endpoint.method !== 'options')
.map(endpoint => ({
path: endpoint.path,
method: endpoint.method,
handler: getFunction(endpoint.integration.uri),
region: getRegion(endpoint.integration.uri)
}))
return endpoints
}
function getRegion (uri) {
// `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${region}:${accountId}:function:${functionName}:\${stageVariables.functionAlias}/invocations`
const uriParts = uri.split(':')
return uriParts[3]
}
function getFunction (uri) {
// `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${region}:${accountId}:function:${functionName}:\${stageVariables.functionAlias}/invocations`
const uriParts = uri.split(':')
return uriParts[11]
}