Skip to content

Commit

Permalink
feat: api for put-timetable lambda. (#179)
Browse files Browse the repository at this point in the history
* feat: api for put-timetable lambda.

* feat: fixed syntax errors

* feat: fixed syntax error (2)
  • Loading branch information
JasonNotJson authored Apr 8, 2022
1 parent 2b463ee commit bb3e6d6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/constructs/business/rest-api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ export class TimetableApiService extends RestApiService {
const patchIntegration = new apigw.LambdaIntegration(
timetableFunctions.patchFunction, { proxy: true },
);
const putIntergation = new apigw.LambdaIntegration(
timetableFunctions.putFunction, { proxy: true },
);
// const importIntegration = new apigw.LambdaIntegration(
// timetableFunctions.importFunction, {proxy: true},
// );
Expand Down Expand Up @@ -447,6 +450,15 @@ export class TimetableApiService extends RestApiService {
authorizer: props.authorizer,
requestValidator: props.validator,
});
const putTimetable = root.addMethod(apigw2.HttpMethod.PUT, putIntergation, {
operationName: 'PutTimetable',
methodResponses: [{
statusCode: '200',
responseParameters: lambdaRespParams,
}],
authorizer: props.authorizer,
requestValidator: props.validator,
});

// [timetableImport, timetableExport].forEach(value => value.addCorsPreflight({
// allowOrigins: allowOrigins,
Expand Down Expand Up @@ -476,6 +488,7 @@ export class TimetableApiService extends RestApiService {
[apigw2.HttpMethod.GET]: getTimetable,
[apigw2.HttpMethod.PATCH]: patchTimetable,
[apigw2.HttpMethod.POST]: postTimetable,
[apigw2.HttpMethod.PUT]: putTimetable,
},
// "/timetable/export": {
// [apigw2.HttpMethod.POST]: exportTimetable,
Expand Down
13 changes: 13 additions & 0 deletions lib/constructs/common/lambda-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class TimetableFunctions extends Construct {
readonly postFunction: lambda.Function;
readonly patchFunction: lambda.Function;
readonly deleteFunction: lambda.Function;
readonly putFunction: lambda.Function;
// readonly importFunction: lambda.Function;
// readonly exportFunction: lambda.Function;

Expand Down Expand Up @@ -257,6 +258,18 @@ export class TimetableFunctions extends Construct {
environment: props.envVars,
});

this.putFunction = new lambda_py.PythonFunction(this, 'put-timetable', {
entry: 'src/lambda/put-timetable',
description: 'Put timetable in the database.',
functionName: 'put-timetable',
logRetention: logs.RetentionDays.ONE_MONTH,
memorySize: 128,
role: dynamoDBPutRole,
runtime: lambda.Runtime.PYTHON_3_9,
timeout: Duration.seconds(3),
environment: props.envVars,
});

// this.importFunction = new lambda_py.PythonFunction(this, 'import-timetable', {
// entry: 'src/lambda/import-timetable',
// description: "Import timetable from pdf.",
Expand Down

0 comments on commit bb3e6d6

Please sign in to comment.