Skip to content

Commit

Permalink
feat: Update all dependencies and make code migrations to support them
Browse files Browse the repository at this point in the history
This commit includes a large-scale update to all of the project's dependencies. Changes were made throughout the codebase to adapt to these new versions. Notably, the codebase has been migrated from AWS SDK V2 to V3, involving significant changes to the database service. The TypeScript version was also updated, and its configuration file was properly adjusted.
  • Loading branch information
kudoh committed Feb 28, 2024
1 parent 6e6c7bd commit 32b6a45
Show file tree
Hide file tree
Showing 17 changed files with 8,169 additions and 4,574 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jspm_packages

.vscode
.idea
.dynamodb
.dynamodb
*.iml
12,399 changes: 7,995 additions & 4,404 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@
"prettier": "prettier -w src"
},
"dependencies": {
"aws-sdk": "^2.848.0",
"@aws-sdk/client-dynamodb": "^3.521.0",
"@aws-sdk/lib-dynamodb": "^3.521.0",
"uuid": "^8.3.2",
"validate.js": "^0.13.1"
},
"devDependencies": {
"@serverless/typescript": "^3.17.0",
"@types/aws-lambda": "^8.10.17",
"@types/node": "^10.12.18",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"esbuild": "^0.14.39",
"eslint": "^7.22.0",
"@serverless/typescript": "^3.38.0",
"@types/aws-lambda": "^8.10.134",
"@types/node": "^20.11.20",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"esbuild": "^0.20.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"serverless": "^3.15.2",
"serverless-api-gateway-throttling": "^1.1.0",
"serverless-dynamodb-local": "^0.2.39",
"serverless-esbuild": "^1.27.0",
"serverless-offline": "^6.8.0",
"serverless-plugin-aws-alerts": "^1.7.1",
"serverless-plugin-subscription-filter": "^1.0.7",
"serverless": "^3.38.0",
"serverless-api-gateway-throttling": "^2.0.3",
"serverless-dynamodb": "^0.2.50",
"serverless-esbuild": "^1.51.0",
"serverless-offline": "^13.3.3",
"serverless-plugin-aws-alerts": "^1.7.5",
"source-map-support": "^0.5.21",
"ts-node": "^10.7.0",
"typescript": "^4.1.5"
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"author": "noboru-kudo",
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion resources/cloudwatch-alarms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ export default {
Period: 60,
Statistic: "Sum",
},
} ,
},
};
10 changes: 4 additions & 6 deletions resources/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ export default {
handler: "ops-handler.handleApiGatewayLog",
events: [
{
subscriptionFilter: {
stage: "${self:custom.stage}",
logGroupName: "/aws/api-gateway/${self:service}-${self:custom.stage}",
filterPattern:
'{$.status = "429" || $.status = "502" || $.status = "504"}',
cloudwatchLog: {
logGroup: "/aws/api-gateway/${self:service}-${self:custom.stage}",
filter: '{$.status = "429" || $.status = "502" || $.status = "504"}',
},
} as any,
},
],
},
};
25 changes: 14 additions & 11 deletions serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ const serverlessConfiguration: AWS = {
frameworkVersion: "3",
plugins: [
"serverless-esbuild",
"serverless-dynamodb-local",
"serverless-dynamodb",
"serverless-offline",
"serverless-api-gateway-throttling",
"serverless-plugin-subscription-filter",
"serverless-plugin-aws-alerts",
],
package: {
individually: true,
},
provider: {
name: "aws",
runtime: "nodejs14.x",
runtime: "nodejs20.x",
stage: "dev",
region: "ap-northeast-1",
logs: {
Expand Down Expand Up @@ -76,13 +75,17 @@ const serverlessConfiguration: AWS = {
{
"Fn::Join": [
"/",
[{ "Fn::GetAtt": ["TasksTable", "Arn"] }, "index", "list_index"],
[
{ "Fn::GetAtt": ["TasksTable", "Arn"] },
"index",
"list_index",
],
],
},
],
},
]
}
],
},
},
},
custom: {
Expand Down Expand Up @@ -113,10 +116,10 @@ const serverlessConfiguration: AWS = {
bundle: true,
minify: true,
sourcemap: true,
exclude: ['aws-sdk'],
target: 'node14',
define: { 'require.resolve': undefined },
platform: 'node',
exclude: ["aws-sdk"],
target: "node20",
define: { "require.resolve": undefined },
platform: "node",
concurrency: 10,
},
"serverless-offline": {
Expand All @@ -130,7 +133,7 @@ const serverlessConfiguration: AWS = {
maxConcurrentRequests: 5,
},
alerts: {
stages: ["prod"],
stages: ["dev", "prod"],
topics: {
alarm: {
topic: "${self:service}-${self:custom.stage}-alerts-alarm",
Expand Down
19 changes: 10 additions & 9 deletions src/actions/list/create-list.action.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import "source-map-support/register";

import ListModel, { IListInterface } from "../../models/list.model";
import ResponseModel from "../../models/response.model";
import ListModel, { IListInterface } from "~/models/list.model";
import ResponseModel from "~/models/response.model";

import DatabaseService, { PutItem } from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";

import requestConstraints from "../../constraints/list/create.constraint.json";
import { wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import requestConstraints from "~/constraints/list/create.constraint.json";
import { wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import { PutCommandInput } from "@aws-sdk/lib-dynamodb";

const createListHandler = async (
body: IListInterface
Expand All @@ -20,7 +21,7 @@ const createListHandler = async (

const listModel = new ListModel(body);
const data = listModel.toEntityMappings();
const params: PutItem = {
const params: PutCommandInput = {
TableName: databaseTables().listTable,
Item: {
id: data.id,
Expand Down
26 changes: 10 additions & 16 deletions src/actions/list/delete-list.action.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import "source-map-support/register";

import ResponseModel from "../../models/response.model";
import DatabaseService, {
DeleteItem,
QueryItem,
} from "../../services/database.service";
import {
createChunks,
databaseTables,
validateRequest,
} from "../../utils/util";
import requestConstraints from "../../constraints/list/get.constraint.json";
import { QueryParams, wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import ResponseModel from "~/models/response.model";
import { createChunks, databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/list/get.constraint.json";
import { QueryParams, wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import DatabaseService from "~/services/database.service";
import { DeleteCommandInput, QueryCommandInput } from "@aws-sdk/lib-dynamodb";

const deleteListHandler = async (
_body: never,
Expand All @@ -39,13 +33,13 @@ const deleteListHandler = async (
);
}

const params: DeleteItem = {
const params: DeleteCommandInput = {
TableName: listTable,
Key: { id: listId },
};
await databaseService.delete(params); // Delete to-do list

const taskParams: QueryItem = {
const taskParams: QueryCommandInput = {
TableName: tasksTable,
IndexName: "list_index",
KeyConditionExpression: "listId = :listIdVal",
Expand Down
17 changes: 9 additions & 8 deletions src/actions/list/get-list.action.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import "source-map-support/register";

import ResponseModel from "../../models/response.model";
import DatabaseService, { QueryItem } from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import requestConstraints from "../../constraints/list/get.constraint.json";
import { QueryParams, wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import ResponseModel from "~/models/response.model";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/list/get.constraint.json";
import { QueryParams, wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import { QueryCommandInput } from "@aws-sdk/lib-dynamodb";

const getListHandler = async (
_body: never,
Expand All @@ -23,7 +24,7 @@ const getListHandler = async (
tableName: listTable,
});

const params: QueryItem = {
const params: QueryCommandInput = {
TableName: tasksTable,
IndexName: "list_index",
KeyConditionExpression: "listId = :listIdVal",
Expand Down
17 changes: 9 additions & 8 deletions src/actions/list/update-list.action.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import "source-map-support/register";

import ResponseModel from "../../models/response.model";
import DatabaseService, { UpdateItem } from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import requestConstraints from "../../constraints/list/update.constraint.json";
import { wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import ResponseModel from "~/models/response.model";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/list/update.constraint.json";
import { wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import { UpdateCommandInput } from "@aws-sdk/lib-dynamodb";

const updateListHandler = async (body: {
listId: string;
Expand All @@ -22,7 +23,7 @@ const updateListHandler = async (body: {
databaseService.getItem({ key: listId, tableName: listTable }),
]);

const params: UpdateItem = {
const params: UpdateCommandInput = {
TableName: listTable,
Key: {
id: listId,
Expand Down
19 changes: 10 additions & 9 deletions src/actions/task/create-task.action.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import "source-map-support/register";

import TaskModel, { ITaskInterface } from "../../models/task.model";
import ResponseModel from "../../models/response.model";
import DatabaseService, { PutItem } from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import requestConstraints from "../../constraints/task/create.constraint.json";
import { wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import TaskModel, { ITaskInterface } from "~/models/task.model";
import ResponseModel from "~/models/response.model";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/task/create.constraint.json";
import { wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import { PutCommandInput } from '@aws-sdk/lib-dynamodb';

const createTaskHandler = async (
body: ITaskInterface
Expand All @@ -26,7 +27,7 @@ const createTaskHandler = async (
const taskModel = new TaskModel(body);
const data = taskModel.toEntityMapping();

const params: PutItem = {
const params: PutCommandInput = {
TableName: tasksTable,
Item: {
id: data.id,
Expand Down
17 changes: 9 additions & 8 deletions src/actions/task/delete-task.action.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import "source-map-support/register";

import ResponseModel from "../../models/response.model";
import DatabaseService, { DeleteItem } from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import requestConstraints from "../../constraints/task/delete.constraint.json";
import { QueryParams, wrapAsRequest } from "../../utils/lambda-handler";
import { StatusCode } from "../../enums/status-code.enum";
import { ResponseMessage } from "../../enums/response-message.enum";
import ResponseModel from "~/models/response.model";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/task/delete.constraint.json";
import { QueryParams, wrapAsRequest } from "~/utils/lambda-handler";
import { StatusCode } from "~/enums/status-code.enum";
import { ResponseMessage } from "~/enums/response-message.enum";
import { DeleteCommandInput } from '@aws-sdk/lib-dynamodb';

const deleteTaskHandler = async (
_body: never,
Expand All @@ -31,7 +32,7 @@ const deleteTaskHandler = async (
ResponseMessage.DELETE_TASK_NOTFOUND
);
}
const params: DeleteItem = {
const params: DeleteCommandInput = {
TableName: tasksTable,
Key: {
id: taskId,
Expand Down
14 changes: 7 additions & 7 deletions src/actions/task/get-task.action.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import "source-map-support/register";

import ResponseModel from "../../models/response.model";
import DatabaseService from "../../services/database.service";
import { databaseTables, validateRequest } from "../../utils/util";
import requestConstraints from "../../constraints/task/get.constraint.json";
import { QueryParams, wrapAsRequest } from "../../utils/lambda-handler";
import { ResponseMessage } from "../../enums/response-message.enum";
import { StatusCode } from "../../enums/status-code.enum";
import ResponseModel from "~/models/response.model";
import DatabaseService from "~/services/database.service";
import { databaseTables, validateRequest } from "~/utils/util";
import requestConstraints from "~/constraints/task/get.constraint.json";
import { QueryParams, wrapAsRequest } from "~/utils/lambda-handler";
import { ResponseMessage } from "~/enums/response-message.enum";
import { StatusCode } from "~/enums/status-code.enum";

const getTaskHandler = async (
_body: never,
Expand Down
Loading

0 comments on commit 32b6a45

Please sign in to comment.