Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"method.response.header.Content-Length": true,
"method.response.header.Content-Type": true,
},
statusCode: '200',
},
{statusCode: '403'},
{statusCode: '404'},
{statusCode: '500'},
],
requestParameters: {
"method.request.path.key": true
},
}
const segments = root.site.split('/').slice(1)
return pure.use({ content: iaac(SiteContent), default: iaac(SiteDefault) })
.effect(x => {
const p = segments.reduce(
(acc, seg) => acc.getResource(seg) || acc.addResource(seg), gw.root)
p.addMethod('GET', x.default, spec)
p.addResource('{key+}').addMethod('GET', x.content, spec)
})
.yield('content')
}
export function Api(props: GatewayProps): pure.IPure {
const zone = hoc.HostedZone(props.domain)
return pure.use({ zone })
.flatMap(x => ({ cert: hoc.Certificate(site(props), x.zone, props.tlsCertificate) }))
.flatMap(x => ({ gateway: Gateway(props, x.cert) }))
.flatMap(x => ({ dns: GatewayDNS(props, x.zone, x.gateway) }))
.yield('gateway')
}
export function Gateway(props: StaticSiteProps): pure.IPure {
const zone = hoc.HostedZone(props.domain)
const origin = Origin(props, false)
let gateway = pure.use({ zone, origin })
.flatMap(x => ({ cert: hoc.Certificate(site(props), x.zone, props.tlsCertificate) }))
.flatMap(x => ({ role: OriginAccessPolicy(x.origin) }))
.flatMap(x => ({ gateway: SiteGateway(props, x.cert) }))
.flatMap(x => ({ dns: GatewayDNS(props, x.zone, x.gateway) }))
if (props.sites) {
props.sites.forEach(spec =>
gateway = gateway.flatMap(
x => ({[spec.origin]: StaticContent(x.origin, x.role, x.gateway, spec)})
)
)
}
return gateway.yield('gateway')
}
export function CloudFront(props: StaticSiteProps): pure.IPure {
const zone = hoc.HostedZone(props.domain)
const origin = Origin(props)
return pure.use({ zone, origin })
.flatMap(x => ({ cert: hoc.Certificate(site(props), x.zone, props.tlsCertificate) }))
.flatMap(x => ({ cdn: CDN(props, x.cert.certificateArn, x.origin) }))
.flatMap(x => ({ dns: CloudFrontDNS(props, x.zone, x.cdn) }))
.yield('cdn')
}