@@ -188,6 +188,26 @@ export class DiscordStack extends cdk.Stack {
188
188
rankNodesTable . grantReadData ( leaderboardHandler ) ;
189
189
rankLeaderboardsTable . grantReadData ( leaderboardHandler ) ;
190
190
191
+ const leaderboardFetchHandler = new lambda . Function (
192
+ this ,
193
+ "leaderboardFetchHandler" ,
194
+ {
195
+ runtime : lambda . Runtime . NODEJS_14_X ,
196
+ code : lambda . Code . fromAsset (
197
+ path . join ( __dirname , "../../../.layers/leaderboard-fetch" )
198
+ ) ,
199
+ handler : "index.handler" ,
200
+ timeout : cdk . Duration . seconds ( 10 ) ,
201
+ memorySize : 256 ,
202
+ environment : {
203
+ MINIMUM_LOG_LEVEL : "INFO" ,
204
+ TABLE_NAME_RANKER_BOARDS : rankBoardTable . tableName ,
205
+ } ,
206
+ }
207
+ ) ;
208
+
209
+ rankBoardTable . grantReadData ( leaderboardFetchHandler ) ;
210
+
191
211
const deferredMessageHandler = new lambda . Function (
192
212
this ,
193
213
"deferredMessageHandler" ,
@@ -330,6 +350,13 @@ export class DiscordStack extends cdk.Stack {
330
350
const discordResource = discordApi . root . addResource ( "discord" ) ;
331
351
discordResource . addMethod ( "POST" , discordIntegration ) ;
332
352
const experienceResource = leaderboardApi . root . addResource ( "{experience}" ) ;
353
+ experienceResource . addMethod (
354
+ "GET" ,
355
+ new apigateway . LambdaIntegration ( leaderboardFetchHandler ) ,
356
+ {
357
+ apiKeyRequired : true ,
358
+ }
359
+ ) ;
333
360
const leaderboardResource = experienceResource . addResource ( "leaderboard" ) ;
334
361
leaderboardResource . addMethod (
335
362
"GET" ,
0 commit comments