@@ -6,33 +6,26 @@ import * as iam from 'aws-cdk-lib/aws-iam';
66import * as runtime from 'aws-cdk-lib/aws-lambda' ;
77import * as lambda from 'aws-cdk-lib/aws-lambda-nodejs' ;
88import type { Construct } from 'constructs' ;
9+ import { loadEnv } from '../../src/env.ts' ;
910
1011export class TimesAllBotStack extends cdk . Stack {
1112 constructor ( scope : Construct , id : string , props ?: cdk . StackProps ) {
1213 super ( scope , id , props ) ;
1314
14- const slackBotToken = process . env [ 'SLACK_BOT_TOKEN' ] ;
15- if ( ! slackBotToken ) throw new Error ( 'SLACK_BOT_TOKEN is required' ) ;
16- const slackSigningSecret = process . env [ 'SLACK_SIGNING_SECRET' ] ;
17- if ( ! slackSigningSecret )
18- throw new Error ( 'SLACK_SIGNING_SECRET is required' ) ;
19- const timesAllChannelId = process . env [ 'TIMES_ALL_CHANNEL_ID' ] ;
20- if ( ! timesAllChannelId ) throw new Error ( 'TIMES_ALL_CHANNEL_ID is required' ) ;
21- const workspaceUrl = process . env [ 'WORKSPACE_URL' ] ;
22- if ( ! workspaceUrl ) throw new Error ( 'WORKSPACE_URL is required' ) ;
15+ const env = loadEnv ( ) ;
2316
2417 const projectRoot = path . join ( import . meta. dirname , '../..' ) ;
2518
2619 const fn = new lambda . NodejsFunction ( this , 'SlackHandler' , {
27- entry : path . join ( projectRoot , 'index .ts' ) ,
20+ entry : path . join ( projectRoot , 'src/handler .ts' ) ,
2821 handler : 'handler' ,
2922 runtime : runtime . Runtime . NODEJS_24_X ,
3023 timeout : cdk . Duration . seconds ( 30 ) ,
3124 environment : {
32- SLACK_BOT_TOKEN : slackBotToken ,
33- SLACK_SIGNING_SECRET : slackSigningSecret ,
34- TIMES_ALL_CHANNEL_ID : timesAllChannelId ,
35- WORKSPACE_URL : workspaceUrl ,
25+ SLACK_BOT_TOKEN : env . slackBotToken ,
26+ SLACK_SIGNING_SECRET : env . slackSigningSecret ,
27+ TIMES_ALL_CHANNEL_ID : env . timesAllChannelId ,
28+ WORKSPACE_URL : env . workspaceUrl ,
3629 } ,
3730 bundling : {
3831 nodeModules : [ '@slack/bolt' ] ,
0 commit comments