Skip to content

Commit 89ed7e5

Browse files
committed
Fix compilation warnings
1 parent ff8be18 commit 89ed7e5

File tree

45 files changed

+522
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+522
-405
lines changed
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from '@aws-cdk/core';
4-
import { JProfByBotStack } from '../lib/JProfByBotStack';
4+
import {JProfByBotStack} from '../lib/JProfByBotStack';
55

66
if (process.env.TOKEN_TELEGRAM_BOT == null) {
7-
throw new Error('Undefined TOKEN_TELEGRAM_BOT')
7+
throw new Error('Undefined TOKEN_TELEGRAM_BOT')
88
}
99

1010
if (process.env.TOKEN_YOUTUBE_API == null) {
11-
throw new Error('Undefined TOKEN_YOUTUBE_API')
11+
throw new Error('Undefined TOKEN_YOUTUBE_API')
1212
}
1313

1414
const app = new cdk.App();
1515
new JProfByBotStack(
16-
app,
17-
'JProfByBotStack',
18-
{
19-
telegramToken: process.env.TOKEN_TELEGRAM_BOT,
20-
youtubeToken: process.env.TOKEN_YOUTUBE_API,
21-
env: {
22-
region: 'us-east-1'
16+
app,
17+
'JProfByBotStack',
18+
{
19+
telegramToken: process.env.TOKEN_TELEGRAM_BOT,
20+
youtubeToken: process.env.TOKEN_YOUTUBE_API,
21+
env: {
22+
region: 'us-east-1'
23+
}
2324
}
24-
}
2525
);

.deploy/lambda/cdk.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"app": "npx ts-node --prefer-ts-exts bin/JProfByBotStack.ts",
3-
"context": {
4-
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
5-
"@aws-cdk/core:enableStackNameDuplicates": "true",
6-
"aws-cdk:enableDiffNoFail": "true",
7-
"@aws-cdk/core:stackRelativeExports": "true",
8-
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
9-
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
10-
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
11-
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
12-
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
13-
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
14-
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true
15-
}
2+
"app": "npx ts-node --prefer-ts-exts bin/JProfByBotStack.ts",
3+
"context": {
4+
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
5+
"@aws-cdk/core:enableStackNameDuplicates": "true",
6+
"aws-cdk:enableDiffNoFail": "true",
7+
"@aws-cdk/core:stackRelativeExports": "true",
8+
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
9+
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
10+
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
11+
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
12+
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
13+
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
14+
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true
15+
}
1616
}
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
11
import * as cdk from '@aws-cdk/core';
2-
import { Duration, RemovalPolicy } from '@aws-cdk/core';
3-
import { JProfByBotStackProps } from './JProfByBotStackProps';
2+
import {Duration, RemovalPolicy} from '@aws-cdk/core';
3+
import {JProfByBotStackProps} from './JProfByBotStackProps';
44
import * as dynamodb from '@aws-cdk/aws-dynamodb';
55
import * as lambda from '@aws-cdk/aws-lambda';
66
import * as apigateway from '@aws-cdk/aws-apigateway';
77

88
export class JProfByBotStack extends cdk.Stack {
9-
constructor(scope: cdk.Construct, id: string, props: JProfByBotStackProps) {
10-
super(scope, id, props);
9+
constructor(scope: cdk.Construct, id: string, props: JProfByBotStackProps) {
10+
super(scope, id, props);
1111

12-
const votesTable = new dynamodb.Table(this, 'jprof-by-bot-table-votes', {
13-
tableName: 'jprof-by-bot-table-votes',
14-
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
15-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
16-
removalPolicy: RemovalPolicy.DESTROY,
17-
});
18-
const youtubeChannelsWhitelistTable = new dynamodb.Table(this, 'jprof-by-bot-table-youtube-channels-whitelist', {
19-
tableName: 'jprof-by-bot-table-youtube-channels-whitelist',
20-
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
21-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
22-
});
23-
const kotlinMentionsTable = new dynamodb.Table(this, 'jprof-by-bot-table-kotlin-mentions', {
24-
tableName: 'jprof-by-bot-table-kotlin-mentions',
25-
partitionKey: { name: 'chat', type: dynamodb.AttributeType.NUMBER },
26-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
27-
});
28-
const dialogStatesTable = new dynamodb.Table(this, 'jprof-by-bot-table-dialog-states', {
29-
tableName: 'jprof-by-bot-table-dialog-states',
30-
partitionKey: { name: 'userId', type: dynamodb.AttributeType.NUMBER },
31-
sortKey: { name: 'chatId', type: dynamodb.AttributeType.NUMBER },
32-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
33-
});
34-
const quizojisTable = new dynamodb.Table(this, 'jprof-by-bot-table-quizojis', {
35-
tableName: 'jprof-by-bot-table-quizojis',
36-
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
37-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
38-
});
12+
const votesTable = new dynamodb.Table(this, 'jprof-by-bot-table-votes', {
13+
tableName: 'jprof-by-bot-table-votes',
14+
partitionKey: {name: 'id', type: dynamodb.AttributeType.STRING},
15+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
16+
removalPolicy: RemovalPolicy.DESTROY,
17+
});
18+
const youtubeChannelsWhitelistTable = new dynamodb.Table(this, 'jprof-by-bot-table-youtube-channels-whitelist', {
19+
tableName: 'jprof-by-bot-table-youtube-channels-whitelist',
20+
partitionKey: {name: 'id', type: dynamodb.AttributeType.STRING},
21+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
22+
});
23+
const kotlinMentionsTable = new dynamodb.Table(this, 'jprof-by-bot-table-kotlin-mentions', {
24+
tableName: 'jprof-by-bot-table-kotlin-mentions',
25+
partitionKey: {name: 'chat', type: dynamodb.AttributeType.NUMBER},
26+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
27+
});
28+
const dialogStatesTable = new dynamodb.Table(this, 'jprof-by-bot-table-dialog-states', {
29+
tableName: 'jprof-by-bot-table-dialog-states',
30+
partitionKey: {name: 'userId', type: dynamodb.AttributeType.NUMBER},
31+
sortKey: {name: 'chatId', type: dynamodb.AttributeType.NUMBER},
32+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
33+
});
34+
const quizojisTable = new dynamodb.Table(this, 'jprof-by-bot-table-quizojis', {
35+
tableName: 'jprof-by-bot-table-quizojis',
36+
partitionKey: {name: 'id', type: dynamodb.AttributeType.STRING},
37+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
38+
});
3939

40-
const layerLibGL = new lambda.LayerVersion(this, 'jprof-by-bot-lambda-layer-libGL', {
41-
code: lambda.Code.fromAsset('layers/libGL.zip'),
42-
compatibleRuntimes: [lambda.Runtime.JAVA_11],
43-
});
44-
const layerLibfontconfig = new lambda.LayerVersion(this, 'jprof-by-bot-lambda-layer-libfontconfig', {
45-
code: lambda.Code.fromAsset('layers/libfontconfig.zip'),
46-
compatibleRuntimes: [lambda.Runtime.JAVA_11],
47-
});
40+
const layerLibGL = new lambda.LayerVersion(this, 'jprof-by-bot-lambda-layer-libGL', {
41+
code: lambda.Code.fromAsset('layers/libGL.zip'),
42+
compatibleRuntimes: [lambda.Runtime.JAVA_11],
43+
});
44+
const layerLibfontconfig = new lambda.LayerVersion(this, 'jprof-by-bot-lambda-layer-libfontconfig', {
45+
code: lambda.Code.fromAsset('layers/libfontconfig.zip'),
46+
compatibleRuntimes: [lambda.Runtime.JAVA_11],
47+
});
4848

49-
const lambdaWebhook = new lambda.Function(this, 'jprof-by-bot-lambda-webhook', {
50-
functionName: 'jprof-by-bot-lambda-webhook',
51-
runtime: lambda.Runtime.JAVA_11,
52-
layers: [
53-
layerLibGL,
54-
layerLibfontconfig,
55-
],
56-
timeout: Duration.seconds(30),
57-
memorySize: 1024,
58-
code: lambda.Code.fromAsset('../../runners/lambda/build/libs/jprof_by_bot-runners-lambda-all.jar'),
59-
handler: 'by.jprof.telegram.bot.runners.lambda.JProf',
60-
environment: {
61-
'LOG_THRESHOLD': 'DEBUG',
62-
'TABLE_VOTES': votesTable.tableName,
63-
'TABLE_YOUTUBE_CHANNELS_WHITELIST': youtubeChannelsWhitelistTable.tableName,
64-
'TABLE_KOTLIN_MENTIONS': kotlinMentionsTable.tableName,
65-
'TABLE_DIALOG_STATES': dialogStatesTable.tableName,
66-
'TABLE_QUIZOJIS': quizojisTable.tableName,
67-
'TOKEN_TELEGRAM_BOT': props.telegramToken,
68-
'TOKEN_YOUTUBE_API': props.youtubeToken,
69-
},
70-
});
49+
const lambdaWebhook = new lambda.Function(this, 'jprof-by-bot-lambda-webhook', {
50+
functionName: 'jprof-by-bot-lambda-webhook',
51+
runtime: lambda.Runtime.JAVA_11,
52+
layers: [
53+
layerLibGL,
54+
layerLibfontconfig,
55+
],
56+
timeout: Duration.seconds(30),
57+
memorySize: 1024,
58+
code: lambda.Code.fromAsset('../../runners/lambda/build/libs/jprof_by_bot-runners-lambda-all.jar'),
59+
handler: 'by.jprof.telegram.bot.runners.lambda.JProf',
60+
environment: {
61+
'LOG_THRESHOLD': 'DEBUG',
62+
'TABLE_VOTES': votesTable.tableName,
63+
'TABLE_YOUTUBE_CHANNELS_WHITELIST': youtubeChannelsWhitelistTable.tableName,
64+
'TABLE_KOTLIN_MENTIONS': kotlinMentionsTable.tableName,
65+
'TABLE_DIALOG_STATES': dialogStatesTable.tableName,
66+
'TABLE_QUIZOJIS': quizojisTable.tableName,
67+
'TOKEN_TELEGRAM_BOT': props.telegramToken,
68+
'TOKEN_YOUTUBE_API': props.youtubeToken,
69+
},
70+
});
7171

72-
votesTable.grantReadWriteData(lambdaWebhook);
73-
youtubeChannelsWhitelistTable.grantReadData(lambdaWebhook);
74-
kotlinMentionsTable.grantReadWriteData(lambdaWebhook);
75-
dialogStatesTable.grantReadWriteData(lambdaWebhook);
76-
quizojisTable.grantReadWriteData(lambdaWebhook);
72+
votesTable.grantReadWriteData(lambdaWebhook);
73+
youtubeChannelsWhitelistTable.grantReadData(lambdaWebhook);
74+
kotlinMentionsTable.grantReadWriteData(lambdaWebhook);
75+
dialogStatesTable.grantReadWriteData(lambdaWebhook);
76+
quizojisTable.grantReadWriteData(lambdaWebhook);
7777

78-
const api = new apigateway.RestApi(this, 'jprof-by-bot-api', {
79-
restApiName: 'jprof-by-bot-api',
80-
cloudWatchRole: false,
81-
endpointTypes: [apigateway.EndpointType.REGIONAL],
82-
deployOptions: {
83-
loggingLevel: apigateway.MethodLoggingLevel.INFO,
84-
dataTraceEnabled: true,
85-
metricsEnabled: true,
86-
tracingEnabled: true,
87-
},
88-
});
78+
const api = new apigateway.RestApi(this, 'jprof-by-bot-api', {
79+
restApiName: 'jprof-by-bot-api',
80+
cloudWatchRole: false,
81+
endpointTypes: [apigateway.EndpointType.REGIONAL],
82+
deployOptions: {
83+
loggingLevel: apigateway.MethodLoggingLevel.INFO,
84+
dataTraceEnabled: true,
85+
metricsEnabled: true,
86+
tracingEnabled: true,
87+
},
88+
});
8989

90-
api.root
91-
.addResource(props.telegramToken.replace(':', '_'))
92-
.addMethod('POST', new apigateway.LambdaIntegration(lambdaWebhook));
90+
api.root
91+
.addResource(props.telegramToken.replace(':', '_'))
92+
.addMethod('POST', new apigateway.LambdaIntegration(lambdaWebhook));
9393

94-
new cdk.CfnOutput(this, 'URL', {
95-
value: api.deploymentStage.urlForPath()
96-
});
97-
}
94+
new cdk.CfnOutput(this, 'URL', {
95+
value: api.deploymentStage.urlForPath()
96+
});
97+
}
9898
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as cdk from '@aws-cdk/core';
22

33
export interface JProfByBotStackProps extends cdk.StackProps {
4-
readonly telegramToken: string;
5-
readonly youtubeToken: string;
4+
readonly telegramToken: string;
5+
readonly youtubeToken: string;
66
}

.deploy/lambda/package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
2-
"name": "jprof-by-bot",
3-
"version": "0.1.0",
4-
"bin": {
5-
"lambda": "bin/JProfByBotStack.js"
6-
},
7-
"scripts": {
8-
"build": "tsc",
9-
"watch": "tsc -w",
10-
"test": "jest",
11-
"cdk": "cdk"
12-
},
13-
"devDependencies": {
14-
"@aws-cdk/assert": "1.100.0",
15-
"@types/node": "10.17.27",
16-
"aws-cdk": "1.100.0",
17-
"ts-node": "^9.0.0",
18-
"typescript": "~3.9.7"
19-
},
20-
"dependencies": {
21-
"@aws-cdk/aws-apigateway": "1.100.0",
22-
"@aws-cdk/aws-dynamodb": "1.100.0",
23-
"@aws-cdk/aws-lambda": "1.100.0",
24-
"@aws-cdk/core": "1.100.0",
25-
"source-map-support": "^0.5.16"
26-
}
2+
"name": "jprof-by-bot",
3+
"version": "0.1.0",
4+
"bin": {
5+
"lambda": "bin/JProfByBotStack.js"
6+
},
7+
"scripts": {
8+
"build": "tsc",
9+
"watch": "tsc -w",
10+
"test": "jest",
11+
"cdk": "cdk"
12+
},
13+
"devDependencies": {
14+
"@aws-cdk/assert": "1.100.0",
15+
"@types/node": "10.17.27",
16+
"aws-cdk": "1.100.0",
17+
"ts-node": "^9.0.0",
18+
"typescript": "~3.9.7"
19+
},
20+
"dependencies": {
21+
"@aws-cdk/aws-apigateway": "1.100.0",
22+
"@aws-cdk/aws-dynamodb": "1.100.0",
23+
"@aws-cdk/aws-lambda": "1.100.0",
24+
"@aws-cdk/core": "1.100.0",
25+
"source-map-support": "^0.5.16"
26+
}
2727
}

.deploy/lambda/tsconfig.json

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2018",
4-
"module": "commonjs",
5-
"lib": ["es2018"],
6-
"declaration": true,
7-
"strict": true,
8-
"noImplicitAny": true,
9-
"strictNullChecks": true,
10-
"noImplicitThis": true,
11-
"alwaysStrict": true,
12-
"noUnusedLocals": false,
13-
"noUnusedParameters": false,
14-
"noImplicitReturns": true,
15-
"noFallthroughCasesInSwitch": false,
16-
"inlineSourceMap": true,
17-
"inlineSources": true,
18-
"experimentalDecorators": true,
19-
"strictPropertyInitialization": false,
20-
"typeRoots": ["./node_modules/@types"]
21-
},
22-
"exclude": ["cdk.out"]
2+
"compilerOptions": {
3+
"target": "ES2018",
4+
"module": "commonjs",
5+
"lib": [
6+
"es2018"
7+
],
8+
"declaration": true,
9+
"strict": true,
10+
"noImplicitAny": true,
11+
"strictNullChecks": true,
12+
"noImplicitThis": true,
13+
"alwaysStrict": true,
14+
"noUnusedLocals": false,
15+
"noUnusedParameters": false,
16+
"noImplicitReturns": true,
17+
"noFallthroughCasesInSwitch": false,
18+
"inlineSourceMap": true,
19+
"inlineSources": true,
20+
"experimentalDecorators": true,
21+
"strictPropertyInitialization": false,
22+
"typeRoots": [
23+
"./node_modules/@types"
24+
]
25+
},
26+
"exclude": [
27+
"cdk.out"
28+
]
2329
}

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ subprojects {
1515
}
1616

1717
tasks {
18+
withType<JavaCompile> {
19+
options.release.set(11)
20+
}
1821
withType<KotlinCompile> {
1922
kotlinOptions.jvmTarget = "11"
2023
}

core/src/main/kotlin/by/jprof/telegram/bot/core/UpdateProcessingPipeline.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package by.jprof.telegram.bot.core
22

33
import dev.inmo.tgbotapi.types.update.abstracts.Update
4-
import kotlinx.coroutines.*
4+
import kotlinx.coroutines.CoroutineExceptionHandler
5+
import kotlinx.coroutines.joinAll
6+
import kotlinx.coroutines.launch
7+
import kotlinx.coroutines.runBlocking
8+
import kotlinx.coroutines.supervisorScope
59
import org.apache.logging.log4j.LogManager
610

711
class UpdateProcessingPipeline(

dialogs/dynamodb/src/test/kotlin/by/jprof/telegram/bot/dialogs/dynamodb/dao/DialogStateDAOTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import kotlinx.coroutines.runBlocking
77
import kotlinx.coroutines.withTimeout
88
import me.madhead.aws_junit5.common.AWSClient
99
import me.madhead.aws_junit5.dynamo.v2.DynamoDB
10-
import org.junit.jupiter.api.*
10+
import org.junit.jupiter.api.Assertions
11+
import org.junit.jupiter.api.BeforeAll
12+
import org.junit.jupiter.api.Tag
13+
import org.junit.jupiter.api.Test
14+
import org.junit.jupiter.api.TestInstance
1115
import org.junit.jupiter.api.extension.ExtendWith
1216
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
1317

0 commit comments

Comments
 (0)