Skip to content

Commit

Permalink
Merge pull request #105 from wasedatime/develop
Browse files Browse the repository at this point in the history
Remove blog app
  • Loading branch information
AustinZhu authored Nov 30, 2021
2 parents e3129ef + 0f1d289 commit c3a662f
Show file tree
Hide file tree
Showing 23 changed files with 542 additions and 663 deletions.
35 changes: 35 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How has this been tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
9 changes: 5 additions & 4 deletions .github/workflows/cdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.4.1
- uses: actions/setup-node@v2.5.0
with:
node-version: 16.x

Expand All @@ -59,7 +59,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.4.1
- uses: actions/setup-node@v2.5.0
with:
node-version: 16.x

Expand All @@ -76,8 +76,9 @@ jobs:
- name: Diff
id: diff
run: |
cdk diff --no-color &> diff.txt
LOG="$(cat diff.txt)"
echo "::add-mask::$DEPLOY_KEY"
echo "::add-mask::$BIT_TOKEN"
LOG="$(cdk diff --no-color 2>&1)"
LOG="${LOG//'%'/'%25'}"
LOG="${LOG//$'\n'/'%0A'}"
LOG="${LOG//$'\r'/'%0D'}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.4.1
- uses: actions/setup-node@v2.5.0
with:
node-version: 16.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.4.1
- uses: actions/setup-node@v2.5.0
with:
node-version: 16.x

Expand Down
2 changes: 0 additions & 2 deletions lib/configs/common/arn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const AUTH_CERT_ARN = 'arn:aws:acm:us-east-1:564383102056:certificate/7e29831d-9eb9-4212-9856-4f5fd0d3cafe';

export const API_CERT_ARN = 'arn:aws:acm:ap-northeast-1:564383102056:certificate/f5ae3aa1-b20c-40e5-8dfe-4baabb1540fd';

export const CF_TOPIC_ARN = 'arn:aws:sns:ap-northeast-1:564383102056:cfn-alert';
1 change: 0 additions & 1 deletion lib/configs/common/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export enum ServiceEndpoint {

export const enum DataEndpoint {
SYLLABUS,
FEEDS,
COURSE_REVIEWS,
CAREER,
TIMETABLE,
Expand Down
20 changes: 0 additions & 20 deletions lib/constructs/admin/chatbot.ts

This file was deleted.

10 changes: 6 additions & 4 deletions lib/constructs/admin/status-notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum StatusNotifier {
}

export interface StatusNotifierProps {
targets?: [string];
targets?: { [key: string]: string };
}

export abstract class AbstractStatusNotifier extends Construct {
Expand All @@ -38,7 +38,9 @@ export class AmplifyBuildStatusNotifier extends AbstractStatusNotifier {
constructor(scope: cdk.Construct, id: string, props: StatusNotifierProps) {
super(scope, id, props);

this.subscriber = new AmplifyStatusPublisher(this, 'subscriber-function').baseFunction;
const subscriber = new AmplifyStatusPublisher(this, 'subscriber-function').baseFunction;
subscriber.addEnvironment('APP_ENDPOINTS', JSON.stringify(props.targets));
this.subscriber = subscriber;

this.publisher = new Rule(this, 'build-sentinel', {
ruleName: "amplify-build-event",
Expand All @@ -52,7 +54,7 @@ export class AmplifyBuildStatusNotifier extends AbstractStatusNotifier {
"Amplify Deployment Status Change",
],
detail: {
"appId": props.targets,
"appId": Object.keys(props.targets!),
"jobStatus": [
"SUCCEED",
"FAILED",
Expand Down Expand Up @@ -97,7 +99,7 @@ export class SyllabusScraperStatusNotifier extends AbstractStatusNotifier {
"TIMED_OUT",
"ABORTED",
],
"stateMachineArn": props.targets,
"stateMachineArn": Object.keys(props.targets!),
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion lib/constructs/business/api-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {IUserPool} from "@aws-cdk/aws-cognito";
import * as flatted from 'flatted';

import {AbstractRestApiService} from "./rest-api-service";
import {apiServiceMap} from "../../configs/api-gateway/service";
import {apiServiceMap} from "./service";
import {AbstractGraphqlApiService} from "./graphql-api-service";
import {STAGE} from "../../configs/common/aws";
import {defaultHeaders} from "../../configs/api-gateway/cors";
Expand Down
5 changes: 2 additions & 3 deletions lib/constructs/business/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
UserPool,
UserPoolClient,
UserPoolDomain,
UserPoolEmail,
UserPoolIdentityProviderGoogle,
} from "@aws-cdk/aws-cognito";
import {Certificate} from "@aws-cdk/aws-certificatemanager";
Expand Down Expand Up @@ -59,9 +60,7 @@ export class WasedaTimeUserAuth extends AbstractAuthProvider {
this.pool = new UserPool(this, 'main-user-pool', {
accountRecovery: AccountRecovery.NONE,
autoVerify: {email: false, phone: false},
emailSettings: {
// from: "[email protected]"
},
email: UserPoolEmail.withCognito(),
enableSmsRole: false,
mfa: Mfa.OFF,
passwordPolicy: {
Expand Down
143 changes: 34 additions & 109 deletions lib/constructs/business/rest-api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@ import {ManagedPolicy, Role, ServicePrincipal} from "@aws-cdk/aws-iam";
import {AbstractRestApiEndpoint} from "./api-endpoint";
import {allowHeaders, allowOrigins} from "../../configs/api-gateway/cors";
import {
articleListSchema,
courseReviewGetRespSchema,
courseReviewPatchReqSchema,
courseReviewPostReqSchema,
syllabusSchema,
} from "../../configs/api-gateway/schema";
import {AwsServicePrincipal} from "../../configs/common/aws";
import {
CourseReviewsFunctions,
FeedsFunctions,
SyllabusFunctions,
TimetableFunctions,
} from "../common/lambda-functions";
import {CourseReviewsFunctions, SyllabusFunctions, TimetableFunctions} from "../common/lambda-functions";
import {lambdaRespParams, s3RespMapping, syllabusRespParams} from "../../configs/api-gateway/mapping";

export interface RestApiServiceProps {
Expand Down Expand Up @@ -307,75 +301,6 @@ export class CourseReviewsApiService extends AbstractRestApiService {
}
}

export class FeedsApiService extends AbstractRestApiService {
readonly resourceMapping: { [path: string]: { [method in HttpMethod]?: Method } } = {};

constructor(scope: AbstractRestApiEndpoint, id: string, props: RestApiServiceProps) {
super(scope, id, props);

const root = scope.apiEndpoint.root.addResource("feeds");
const feedsFunctions = new FeedsFunctions(this, 'crud-functions', {
envVars: {
'TABLE_NAME': props.dataSource!,
},
});

const getRespModel = scope.apiEndpoint.addModel('feeds-get-resp-model', {
schema: articleListSchema,
contentType: "application/json",
description: "List of articles in feeds",
modelName: "GetFeedsResp",
});

const getIntegration = new LambdaIntegration(
feedsFunctions.getFunction, {proxy: true},
);

const postIntegration = new MockIntegration({
requestTemplates: {["application/json"]: '{"statusCode": 200}'},
passthroughBehavior: PassthroughBehavior.WHEN_NO_TEMPLATES,
integrationResponses: [{
statusCode: '200',
}],
});

const optionsFeeds = root.addCorsPreflight({
allowOrigins: allowOrigins,
allowHeaders: allowHeaders,
allowMethods: [HttpMethod.GET, HttpMethod.OPTIONS],
});
const getFeeds = root.addMethod(HttpMethod.GET, getIntegration, {
requestParameters: {
'method.request.querystring.offset': true,
'method.request.querystring.limit': true,
},
operationName: "ListArticles",
methodResponses: [{
statusCode: '200',
responseModels: {["application/json"]: getRespModel},
responseParameters: lambdaRespParams,
}],
requestValidator: props.validator,
});
const postFeeds = root.addMethod(HttpMethod.POST, postIntegration, {
operationName: "PostArticles",
methodResponses: [{
statusCode: '200',
responseParameters: lambdaRespParams,
}],
requestValidator: props.validator,
});

this.resourceMapping = {
"/feeds": {
[HttpMethod.OPTIONS]: optionsFeeds,
[HttpMethod.GET]: getFeeds,
[HttpMethod.POST]: postFeeds,
},
};
}
}

export class CareerApiService extends AbstractRestApiService {
readonly resourceMapping: { [path: string]: { [method in HttpMethod]?: Method } } = {};

Expand Down Expand Up @@ -496,12 +421,12 @@ export class TimetableApiService extends AbstractRestApiService {
const patchIntegration = new LambdaIntegration(
timetableFunctions.patchFunction, {proxy: true},
);
const importIntegration = new LambdaIntegration(
timetableFunctions.importFunction, {proxy: true},
);
const exportIntegration = new LambdaIntegration(
timetableFunctions.exportFunction, {proxy: true},
);
// const importIntegration = new LambdaIntegration(
// timetableFunctions.importFunction, {proxy: true},
// );
// const exportIntegration = new LambdaIntegration(
// timetableFunctions.exportFunction, {proxy: true},
// );

const optionsTimetable = root.addCorsPreflight({
allowOrigins: allowOrigins,
Expand Down Expand Up @@ -536,27 +461,27 @@ export class TimetableApiService extends AbstractRestApiService {
requestValidator: props.validator,
});

[timetableImport, timetableExport].forEach(value => value.addCorsPreflight({
allowOrigins: allowOrigins,
allowHeaders: allowHeaders,
allowMethods: [HttpMethod.POST, HttpMethod.OPTIONS],
}));
const importTimetable = timetableImport.addMethod(HttpMethod.POST, importIntegration, {
operationName: "ImportTimetable",
methodResponses: [{
statusCode: '200',
responseParameters: lambdaRespParams,
}],
requestValidator: props.validator,
});
const exportTimetable = timetableExport.addMethod(HttpMethod.POST, exportIntegration, {
operationName: "ExportTimetable",
methodResponses: [{
statusCode: '200',
responseParameters: lambdaRespParams,
}],
requestValidator: props.validator,
});
// [timetableImport, timetableExport].forEach(value => value.addCorsPreflight({
// allowOrigins: allowOrigins,
// allowHeaders: allowHeaders,
// allowMethods: [HttpMethod.POST, HttpMethod.OPTIONS],
// }));
// const importTimetable = timetableImport.addMethod(HttpMethod.POST, importIntegration, {
// operationName: "ImportTimetable",
// methodResponses: [{
// statusCode: '200',
// responseParameters: lambdaRespParams,
// }],
// requestValidator: props.validator,
// });
// const exportTimetable = timetableExport.addMethod(HttpMethod.POST, exportIntegration, {
// operationName: "ExportTimetable",
// methodResponses: [{
// statusCode: '200',
// responseParameters: lambdaRespParams,
// }],
// requestValidator: props.validator,
// });

this.resourceMapping = {
"/timetable": {
Expand All @@ -565,12 +490,12 @@ export class TimetableApiService extends AbstractRestApiService {
[HttpMethod.PATCH]: patchTimetable,
[HttpMethod.POST]: postTimetable,
},
"/timetable/export": {
[HttpMethod.POST]: exportTimetable,
},
"/timetable/import": {
[HttpMethod.POST]: importTimetable,
},
// "/timetable/export": {
// [HttpMethod.POST]: exportTimetable,
// },
// "/timetable/import": {
// [HttpMethod.POST]: importTimetable,
// },
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as rest from "../../constructs/business/rest-api-service";
import * as gql from "../../constructs/business/graphql-api-service";
import * as rest from "./rest-api-service";
import * as gql from "./graphql-api-service";

export enum ApiEndpoint {
REST,
Expand All @@ -11,7 +11,6 @@ export const apiServiceMap: { [name: string]: any } = {
"syllabus": rest.SyllabusApiService,
"course-reviews": rest.CourseReviewsApiService,
"career": rest.CareerApiService,
"feeds": rest.FeedsApiService,
"timetable": rest.TimetableApiService,
"graphql": rest.GraphqlApiService,
"course": gql.CourseApiService,
Expand Down
Loading

0 comments on commit c3a662f

Please sign in to comment.