Skip to content

Commit

Permalink
Revert "fix: configuring-rest-api (#219)" (#220)
Browse files Browse the repository at this point in the history
This reverts commit 665e252.
  • Loading branch information
JasonNotJson authored Nov 11, 2022
1 parent 665e252 commit e337e01
Show file tree
Hide file tree
Showing 17 changed files with 1,632 additions and 1,671 deletions.
4 changes: 2 additions & 2 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ description: 'Workflow for installing dependencies'
runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v2.0.1
with:
version: latest
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'pnpm'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -67,7 +67,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -81,4 +81,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v1
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Setup AWS
uses: Fooji/create-aws-profile-action@v2
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ deploy ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
repository: wasedatime/wasedatime.github.io
token: ${{ env.GITHUB_OAUTH_TOKEN }}
Expand All @@ -69,7 +69,7 @@ jobs:
aws apigateway get-export --rest-api-id 'anvonkl0fd' --stage-name 'dev' --export-type 'swagger' --accepts 'application/yaml' ./dev.yml
aws apigateway get-export --rest-api-id 'anvonkl0fd' --stage-name 'prod' --export-type 'swagger' --accepts 'application/yaml' ./prod.yml
- name: Push
uses: EndBug/add-and-commit@v9
uses: EndBug/add-and-commit@v7
with:
author_name: GitHub Actions
author_email: [email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: amannn/action-semantic-pull-request@v4.5.0
- uses: amannn/action-semantic-pull-request@v4.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Lint
run: pnpm run lint
Expand All @@ -44,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Synth
run: cdk synth
Expand All @@ -53,7 +53,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ synth ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Test
run: pnpm test
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ test ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Diff
id: diff
Expand All @@ -74,15 +74,15 @@ jobs:
LOG="${LOG//$'\r'/'%0D'}"
echo "::set-output name=log::$LOG"
- name: Find Comment
uses: peter-evans/find-comment@v2
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: "### Diff Output:"
- name: Comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v2
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Expand All @@ -93,7 +93,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update Comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v2
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Lint
run: pnpm run lint
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ lint ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Build
run: pnpm run build
Expand All @@ -51,9 +51,9 @@ jobs:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: ./.github/actions/install-deps
- name: Test
run: pnpm test -- --coverage
- name: Test Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ node_modules
# CDK asset staging directory
.cdk.staging
cdk.out

# husky
.husky/_/
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ if [ ! -z "$js_diff" ]; then
else
echo "Seems you haven't changed any JavaScript, skip checks. "
fi

npx lint-staged
3 changes: 1 addition & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Config } from '@jest/types';
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
testEnvironment: 'node',
Expand All @@ -7,7 +7,6 @@ const config: Config.InitialOptions = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
moduleDirectories: ['<rootDir>/node_modules'],
};

export default config;
2 changes: 1 addition & 1 deletion lib/configs/api-gateway/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const allowHeaders = [

export const defaultHeaders = {
'Access-Control-Allow-Headers': '\'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token\'',
'Access-Control-Allow-Methods': '\'GET,POST,PUT,OPTIONS\'',
'Access-Control-Allow-Methods': '\'GET,POST,OPTIONS\'',
'Access-Control-Allow-Origin': '\'*\'',
};
17 changes: 1 addition & 16 deletions lib/constructs/business/rest-api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,22 +408,17 @@ 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},
// );
// const exportIntegration = new apigw.LambdaIntegration(
// timetableFunctions.exportFunction, {proxy: true},
// );

// , apigw2.HttpMethod.DELETE

const optionsTimetable = root.addCorsPreflight({
allowOrigins: allowOrigins,
allowHeaders: allowHeaders,
allowMethods: [apigw2.HttpMethod.GET, apigw2.HttpMethod.PUT, apigw2.HttpMethod.POST, apigw2.HttpMethod.PATCH, apigw2.HttpMethod.OPTIONS],
allowMethods: [apigw2.HttpMethod.GET, apigw2.HttpMethod.POST, apigw2.HttpMethod.PATCH, apigw2.HttpMethod.OPTIONS, apigw2.HttpMethod.DELETE],
});
const getTimetable = root.addMethod(apigw2.HttpMethod.GET, getIntegration, {
operationName: 'GetTimetable',
Expand Down Expand Up @@ -452,15 +447,6 @@ 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 @@ -490,7 +476,6 @@ 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: 0 additions & 13 deletions lib/constructs/common/lambda-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ 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 @@ -258,18 +257,6 @@ 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
57 changes: 26 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,40 @@
"lint": "eslint . --ext .ts"
},
"peerDependencies": {
"aws-cdk-lib": "2.27.0",
"constructs": "10.1.32"
"aws-cdk-lib": "2.13.0",
"constructs": "10.0.66"
},
"devDependencies": {
"@aws-cdk/assert": "2.27.0",
"@commitlint/cli": "17.0.2",
"@commitlint/config-conventional": "17.0.2",
"@types/jest": "28.1.1",
"@types/node": "17.0.41",
"@aws-cdk/assert": "2.13.0",
"@commitlint/cli": "16.2.1",
"@commitlint/config-conventional": "16.2.1",
"@types/jest": "27.4.1",
"@types/node": "17.0.18",
"@types/pluralize": "0.0.29",
"@typescript-eslint/eslint-plugin": "5.27.1",
"@typescript-eslint/parser": "5.27.1",
"aws-cdk-lib": "2.27.0",
"constructs": "10.1.32",
"esbuild": "^0.15.12",
"eslint": "8.17.0",
"@typescript-eslint/eslint-plugin": "5.10.2",
"@typescript-eslint/parser": "5.10.2",
"aws-cdk-lib": "2.13.0",
"constructs": "10.0.66",
"eslint": "8.8.0",
"eslint-import-resolver-node": "0.3.6",
"eslint-import-resolver-typescript": "2.7.1",
"eslint-plugin-import": "2.26.0",
"husky": "8.0.1",
"jest": "28.1.1",
"standard-version": "9.5.0",
"ts-jest": "28.0.4",
"ts-node": "10.8.1",
"typescript": "4.7.3"
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-import": "2.25.4",
"husky": "7.0.4",
"jest": "27.5.1",
"standard-version": "9.3.2",
"ts-jest": "27.1.3",
"ts-node": "10.5.0",
"typescript": "4.5.5"
},
"dependencies": {
"@aws-cdk/aws-amplify-alpha": "2.27.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-alpha": "2.27.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "2.27.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "2.27.0-alpha.0",
"@aws-cdk/aws-appsync-alpha": "2.27.0-alpha.0",
"@aws-cdk/aws-lambda-python-alpha": "2.27.0-alpha.0",
"@jest/types": "^29.3.1",
"@aws-cdk/aws-amplify-alpha": "2.13.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-alpha": "2.13.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "2.13.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "2.13.0-alpha.0",
"@aws-cdk/aws-appsync-alpha": "2.13.0-alpha.0",
"@aws-cdk/aws-lambda-python-alpha": "2.13.0-alpha.0",
"flatted": "3.2.5",
"pluralize": "8.0.0",
"source-map-support": "0.5.21"
},
"lint-staged": {
"*.ts": "eslint --cache --fix"
}
}
Loading

0 comments on commit e337e01

Please sign in to comment.