Skip to content

Commit

Permalink
✨ Add Talk Identifier (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
spontoreau authored Nov 15, 2022
1 parent cd4a2a4 commit 2ec25ad
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/getTalks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient, QueryCommand } from '@aws-sdk/lib-dynamodb';
import { APIGatewayProxyHandler } from 'aws-lambda';
import { unflatten } from 'flat';
import { Talk } from './types/talk';

let client: DynamoDBDocumentClient;

Expand All @@ -28,7 +29,11 @@ export const handler: APIGatewayProxyHandler = async () => {

const talks = Items?.map((i) => {
const { partitionKey, sortKey, ...flattenData } = i;
return unflatten(flattenData);
const talkWithoutId = unflatten(flattenData) as Talk;
return {
...talkWithoutId,
id: sortKey.split('|')[1],
};
});

return {
Expand Down
5 changes: 5 additions & 0 deletions packages/getTalks/src/types/speaker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Speaker = {
firstName: string;
lastName: string;
email: string;
};
13 changes: 13 additions & 0 deletions packages/getTalks/src/types/talk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Speaker } from './speaker';
import { TalkCategory } from './talkCategory';
import { TalkFormat } from './talkFormat';
import { TalkStatus } from './talkStatus';

export type Talk = {
title: string;
abstract: string;
speaker: Speaker;
category: TalkCategory;
format: TalkFormat;
status: TalkStatus;
};
8 changes: 8 additions & 0 deletions packages/getTalks/src/types/talkCategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type TalkCategory =
| 'languages'
| 'agile'
| 'web'
| 'data'
| 'mobile'
| 'cloud'
| 'architecture';
1 change: 1 addition & 0 deletions packages/getTalks/src/types/talkFormat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TalkFormat = 'conference' | 'workshop' | 'quickies';
1 change: 1 addition & 0 deletions packages/getTalks/src/types/talkStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TalkStatus = 'submitted' | 'accepted' | 'rejected';

0 comments on commit 2ec25ad

Please sign in to comment.