Skip to content

Commit

Permalink
feat: export dynamo table props
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Jun 11, 2024
1 parent 74ce82d commit 0faa8f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 11 additions & 0 deletions packages/infra/src/lib/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ import retry from 'p-retry'

export { BlockIndexClaimFetcher } from './block-index.js'

/** Properties for DynamoDB claims table. */
export const tableProps = {
fields: {
claim: 'string',
content: 'string',
expiration: 'number'
},
primaryIndex: { partitionKey: 'content', sortKey: 'claim' },
timeToLiveAttribute: 'expiration'
}

/** @implements {ClaimStore} */
export class ClaimStorage {
/** @type {Table} */
Expand Down
16 changes: 7 additions & 9 deletions stacks/db.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Table } from 'sst/constructs'
import { tableProps } from '../packages/infra/src/lib/store/index.js'

/**
* @param {import('sst/constructs').StackContext} config
*/
export function DB ({ stack }) {
const claimsTable = new Table(stack, 'claims-v1', {
fields: {
claim: 'string',
content: 'string',
expiration: 'number'
},
primaryIndex: { partitionKey: 'content', sortKey: 'claim' },
timeToLiveAttribute: 'expiration'
})
const claimsTable = new Table(
stack,
'claims-v1',
/** @type {import('sst/constructs').TableProps} */
(tableProps)
)

return { claimsTable }
}

0 comments on commit 0faa8f9

Please sign in to comment.