Skip to content

Commit 20d8c55

Browse files
committed
chore: updates
1 parent e6653b9 commit 20d8c55

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

.projen/deps.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lambda/rest.myapi.getTodoById.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
import { api, errors } from 'cdk-serverless/lib/lambda';
2+
import { Todo } from '../generated/datastore.mymodel-model.generated';
23
import { operations } from '../generated/rest.myapi-model.generated';
34

45
export const handler = api.createOpenApiHandler<operations['getTodoById']>(async (ctx) => {
56
ctx.logger.info(JSON.stringify(ctx.event));
67

7-
throw new errors.HttpError(500, 'Not yet implemented');
8+
const todo = await Todo.get({ id: ctx.event.pathParameters!.id });
9+
if (!todo) {
10+
throw new errors.NotFoundError();
11+
}
12+
13+
return {
14+
id: todo.id!,
15+
title: todo.title!,
16+
description: todo.description ?? 'N/A',
17+
lastUpdate: todo.lastUpdated!,
18+
state: todo.state!,
19+
};
820
});

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class MyStack extends Stack {
2222
stageName: 'dev',
2323
singleTableDatastore: datastore,
2424
authentication,
25+
cors: true,
2526
});
2627

2728
const workflow = new TodoLifecycleWorkflow(this, 'Workflow', {

yarn.lock

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)