Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
"deploy": "cdk deploy --all"
},
"dependencies": {
"@aws-sdk/client-dynamodb": "3.917.0",
"@aws-sdk/lib-dynamodb": "3.917.0",
"constructs": "10.4.2",
"@aws-sdk/client-dynamodb": "3.946.0",
"@aws-sdk/lib-dynamodb": "3.946.0",
"constructs": "10.4.3",
"source-map-support": "0.5.21"
},
"devDependencies": {
"@troyblank/eslint-config-troyblank": "2.4.0",
"@types/chance": "1.1.7",
"@types/aws-lambda": "8.10.156",
"@types/aws-lambda": "8.10.159",
"@types/jest": "30.0.0",
"@types/node": "24.9.1",
"@types/node": "24.10.1",
"aws-cdk": "2.1031.0",
"aws-cdk-lib": "2.221.0",
"aws-lambda": "1.0.7",
"chance": "1.1.13",
"esbuild": "0.25.11",
"esbuild": "0.27.1",
"jest": "30.2.0",
"ts-jest": "29.4.5",
"ts-jest": "29.4.6",
"typescript": "5.9.3"
},
"author": "Troy Blank",
Expand Down
3 changes: 2 additions & 1 deletion src/types/lambdas/foodHow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ShoppingItemStore = typeof SHOPPING_ITEM_STORE[number];
export type ShoppingListItem = {
amount: number,
name: string,
store: ShoppingItemStore,
recipe?: string,
type: ShoppingItemType,
store: ShoppingItemStore,
}
2 changes: 1 addition & 1 deletion src/utils/apiGateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('API Gateway Utils', () => {
expect(integrationProps.integrationResponses[0].responseParameters).toMatchObject({
'method.response.header.Access-Control-Allow-Headers': `'Content-Type,X-Amz-Date,Authorization,X-Api-Key'`,
'method.response.header.Access-Control-Allow-Origin': `'${origin}'`,
'method.response.header.Access-Control-Allow-Methods': `'GET,POST,OPTIONS'`,
'method.response.header.Access-Control-Allow-Methods': `'GET,POST,DELETE,OPTIONS'`,
})
expect(integrationProps.requestTemplates).toMatchObject({
'application/json': '{"statusCode": 200}',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/apiGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function addCorsOptions(resource: Resource, accessControlAllowOrigin: str
responseParameters: {
'method.response.header.Access-Control-Allow-Headers': `'Content-Type,X-Amz-Date,Authorization,X-Api-Key'`,
'method.response.header.Access-Control-Allow-Origin': `'${accessControlAllowOrigin}'`,
'method.response.header.Access-Control-Allow-Methods': `'GET,POST,OPTIONS'`,
'method.response.header.Access-Control-Allow-Methods': `'GET,POST,DELETE,OPTIONS'`,
},
},
],
Expand Down
8 changes: 8 additions & 0 deletions src/utils/foodHow/shoppingListItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ describe('Shopping List util', () => {

it('Should determine what is a shopping list item.', async () => {
expect(isAShoppingListItem(mockShoppingListItem())).toBe(true)
expect(isAShoppingListItem({
...mockShoppingListItem(),
recipe: chance.word(),
})).toBe(true)
expect(isAShoppingListItem(undefined)).toBe(false)
expect(isAShoppingListItem({
...mockShoppingListItem(),
Expand All @@ -35,6 +39,10 @@ describe('Shopping List util', () => {
...mockShoppingListItem(),
name: '',
})).toBe(false)
expect(isAShoppingListItem({
...mockShoppingListItem(),
recipe: chance.integer(),
})).toBe(false)
expect(isAShoppingListItem({
...mockShoppingListItem(),
type: chance.word({ syllables: 5 }),
Expand Down
3 changes: 2 additions & 1 deletion src/utils/foodHow/shoppingListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export const isAShoppingItemStore = (shoppingItemStore: any): boolean => {
}

export const isAShoppingListItem = (shoppingListItem: any): boolean => {
const { amount, name, type, store } = shoppingListItem || {}
const { amount, name, recipe, type, store } = shoppingListItem || {}

return (
typeof amount === 'number' &&
typeof name === 'string' && name.length > 0 &&
(recipe === undefined || typeof recipe === 'string') &&
isAShoppingItemType(type) &&
isAShoppingItemStore(store)
)
Expand Down
Loading