Skip to content

Commit

Permalink
create list fn with all endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ebisbe committed Jul 6, 2024
1 parent 8bc2287 commit 1464a01
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 20 deletions.
8 changes: 0 additions & 8 deletions functions/handler.ts

This file was deleted.

45 changes: 45 additions & 0 deletions functions/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Handler, APIGatewayProxyEventV2 } from "aws-lambda";

export const create: Handler<APIGatewayProxyEventV2> = async (event) => {
console.log("event", event.body, event.pathParameters);

return {
statusCode: 200,
body: JSON.stringify({
message: "Go Serverless v4! Your function executed successfully!",
}),
};
};

export const get: Handler<APIGatewayProxyEventV2> = async (event) => {
console.log("event", event.body, event.pathParameters);

return {
statusCode: 200,
body: JSON.stringify({
message: "Go Serverless v4! Your function executed successfully!",
}),
};
};

export const update: Handler<APIGatewayProxyEventV2> = async (event) => {
console.log("event", event.body, event.pathParameters);

return {
statusCode: 200,
body: JSON.stringify({
message: "Go Serverless v4! Your function executed successfully!",
}),
};
};

export const remove: Handler<APIGatewayProxyEventV2> = async (event) => {
console.log("event", event.body, event.pathParameters);

return {
statusCode: 200,
body: JSON.stringify({
message: "Go Serverless v4! Your function executed successfully!",
}),
};
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
"packageManager": "[email protected]",
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.609.0",
"@types/serverless": "^3.12.22",
"dynamodb-onetable": "^2.7.4",
"serverless": "^4.1.11"
"dynamodb-onetable": "^2.7.4"
},
"devDependencies": {
"@eslint/js": "^9.6.0",
"@types/aws-lambda": "^8.10.140",
"@types/node": "^20.14.10",
"@types/serverless": "^3.12.22",
"eslint": "9.x",
"globals": "^15.8.0",
"prettier": "3.3.2",
"serverless": "^4.1.11",
"typescript-eslint": "^7.15.0"
}
}
20 changes: 14 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 45 additions & 3 deletions serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,62 @@ const serverlessConfig: Serverless = {
},

functions: {
hello: {
handler: "functions/handler.hello",
createList: {
handler: "functions/list.create",
environment: {
ddb_table: { Ref: "DdbTable" },
},
events: [
{
httpApi: {
path: "/",
path: "/list",
method: "post",
},
},
],
},
getList: {
handler: "functions/list.get",
environment: {
ddb_table: { Ref: "DdbTable" },
},
events: [
{
httpApi: {
path: "/list/{id}",
method: "get",
},
},
],
},
updateList: {
handler: "functions/list.update",
environment: {
ddb_table: { Ref: "DdbTable" },
},
events: [
{
httpApi: {
path: "/list/{id}",
method: "patch",
},
},
],
},
removeList: {
handler: "functions/list.remove",
environment: {
ddb_table: { Ref: "DdbTable" },
},
events: [
{
httpApi: {
path: "/list/{id}",
method: "delete",
},
},
],
},
},

resources: {
Expand Down

0 comments on commit 1464a01

Please sign in to comment.