@@ -9,6 +9,8 @@ export interface AiStackProps extends NestedCloudProps {
9
9
}
10
10
11
11
export class AiStack {
12
+ askAiUrl : lambda . FunctionUrl
13
+
12
14
constructor ( scope : Construct , props : AiStackProps ) {
13
15
// Define the Lambda Layer for aws-sdk
14
16
const awsSdkLayer = new lambda . LayerVersion ( scope , 'AwsSdkLayer' , {
@@ -46,6 +48,14 @@ export class AiStack {
46
48
timeout : Duration . seconds ( 30 ) ,
47
49
} )
48
50
51
+ this . askAiUrl = new lambda . FunctionUrl ( scope , 'AskAiFunctionUrl' , {
52
+ function : askAi ,
53
+ authType : lambda . FunctionUrlAuthType . NONE ,
54
+ cors : {
55
+ allowedOrigins : [ '*' ] ,
56
+ } ,
57
+ } )
58
+
49
59
const summarizeAi = new lambda . Function ( scope , 'AiFunction' , {
50
60
functionName : `${ props . slug } -${ props . appEnv } -ai-summarize` ,
51
61
description : 'Lambda function to summarize any given text' ,
@@ -57,51 +67,51 @@ export class AiStack {
57
67
timeout : Duration . seconds ( 30 ) ,
58
68
} )
59
69
60
- const api = new RestApi ( scope , 'AiRestApi' , {
61
- restApiName : `${ props . slug } -${ props . appEnv } -ai` ,
62
- description : 'Stacks AI API' ,
63
- defaultCorsPreflightOptions : {
64
- allowOrigins : Cors . ALL_ORIGINS ,
65
- allowMethods : Cors . ALL_METHODS ,
70
+ const summarizeAiUrl = new lambda . FunctionUrl ( scope , 'SummarizeAiFunctionUrl' , {
71
+ function : summarizeAi ,
72
+ authType : lambda . FunctionUrlAuthType . NONE ,
73
+ cors : {
74
+ allowedOrigins : [ '*' ] ,
66
75
} ,
67
76
} )
68
77
69
- const askResource = api . root . addResource ( 'ask' )
70
- const askIntegration = new LambdaIntegration ( askAi )
71
- askResource . addMethod ( 'POST' , askIntegration , {
72
- operationName : 'Stacks AI Ask' ,
73
- authorizationType : AuthorizationType . NONE ,
74
- } )
78
+ // const api = new RestApi(scope, 'AiRestApi', {
79
+ // restApiName: `${props.slug}-${props.appEnv}-ai`,
80
+ // description: 'Stacks AI API',
81
+ // defaultCorsPreflightOptions: {
82
+ // allowOrigins: Cors.ALL_ORIGINS,
83
+ // allowMethods: Cors.ALL_METHODS,
84
+ // },
85
+ // })
75
86
76
- // alias to ask
77
- const promptResource = api . root . addResource ( 'prompt' )
78
- const promptIntegration = new LambdaIntegration ( askAi )
79
- promptResource . addMethod ( 'POST' , promptIntegration , {
80
- operationName : 'Stacks AI Ask' ,
81
- authorizationType : AuthorizationType . NONE ,
82
- } )
87
+ // const askResource = api.root.addResource('ask')
88
+ // const askIntegration = new LambdaIntegration(askAi)
89
+ // askResource.addMethod('POST', askIntegration, {
90
+ // operationName: 'Stacks AI Ask',
91
+ // authorizationType: AuthorizationType.NONE,
92
+ // })
83
93
84
- const summarizeResource = api . root . addResource ( 'summarize' )
85
- const summarizeIntegration = new LambdaIntegration ( summarizeAi )
86
- summarizeResource . addMethod ( 'POST' , summarizeIntegration , {
87
- operationName : 'Stacks AI Summarize' ,
88
- authorizationType : AuthorizationType . NONE ,
89
- } )
94
+ // alias to ask
95
+ // const promptResource = api.root.addResource('prompt')
96
+ // const promptIntegration = new LambdaIntegration(askAi)
97
+ // promptResource.addMethod('POST', promptIntegration, {
98
+ // operationName: 'Stacks AI Ask',
99
+ // authorizationType: AuthorizationType.NONE,
100
+ // })
90
101
91
- // const api = new lambda.FunctionUrl(scope, 'AiLambdaUrl', {
92
- // function: aiLambda,
93
- // authType: lambda.FunctionUrlAuthType.NONE,
94
- // cors: {
95
- // allowedOrigins: ['*'],
96
- // },
102
+ // const summarizeResource = api.root.addResource('summarize')
103
+ // const summarizeIntegration = new LambdaIntegration(summarizeAi)
104
+ // summarizeResource.addMethod('POST', summarizeIntegration, {
105
+ // operationName: 'Stacks AI Summarize',
106
+ // authorizationType: AuthorizationType.NONE,
97
107
// })
98
108
99
109
new Output ( scope , 'AiVanityAskApiUrl' , {
100
- value : ` ${ api . url } ask` ,
110
+ value : this . askAiUrl . url ,
101
111
} )
102
112
103
113
new Output ( scope , 'AiVanitySummarizeApiUrl' , {
104
- value : ` ${ api . url } summarize` ,
114
+ value : summarizeAiUrl . url ,
105
115
} )
106
116
107
117
new Output ( scope , 'AiAskApiUrl' , {
0 commit comments