@stacksjs/cloud
Version:
The Stacks cloud/serverless integration & implementation.
34 lines (29 loc) • 1.3 kB
TypeScript
import type { CfnResource } from 'aws-cdk-lib';
import type { Construct } from 'constructs';
import type { NestedCloudProps } from '../types';
export declare interface DocsStackProps extends NestedCloudProps {
}
export declare class DocsStack {
originRequestFunction: lambda.Function
constructor(scope: Construct, props: DocsStackProps) {
const docsPrefix = 'docs'
this.originRequestFunction = new lambda.Function(scope, 'OriginRequestFunction', {
functionName: `${props.slug}-${props.appEnv}-origin-request-${props.timestamp}`,
description: 'The Stacks Origin Request function that prettifies URLs by removing the .html extension',
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'dist/origin-request.handler',
code: lambda.Code.fromAsset(p.cloudPath('dist.zip'), {
assetHash: originRequestFunctionHash(),
assetHashType: AssetHashType.CUSTOM,
}),
})
const cfnOriginRequestFunction = this.originRequestFunction.node.defaultChild as CfnResource
cfnOriginRequestFunction.applyRemovalPolicy(RemovalPolicy.RETAIN)
if (!config.app.docMode && storage.hasFiles(p.projectPath('docs'))) {
new Output(scope, 'DocsUrl', {
value: `https:
description: 'The URL of the deployed documentation',
})
}
}
}