4.0.18 • Published 1 month ago

@shopify/shopify-app-session-storage-dynamodb v4.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Session Storage Adapter for AWS DynamoDB

This package implements the SessionStorage interface that works with an AWS DynamoDB database.

Contributed by Chris - thank you :clap:

import {shopifyApp} from '@shopify/shopify-app-express';
import {DynamoDBSessionStorage} from '@shopify/shopify-app-session-storage-dynamodb';

// You can use the default options
const storage = new DynamoDBSessionStorage();

// or, if you want to use a different session table name and shop index name
const storage = new DynamoDBSessionStorage({ sessionTableName: 'my-session-table', shopIndexName: 'my-shop-index' });

// or, if you want to use a different region or credentials
const storage = new DynamoDBSessionStorage({ config: { region: 'us-west-2', credentials: { ... } } });

const shopify = shopifyApp({
  sessionStorage: storage,
  // ...
});

Table Schema

{
  TableName: sessionTableName,
  AttributeDefinitions: [
    {AttributeName: 'id', AttributeType: 'S'},
    {AttributeName: 'shop', AttributeType: 'S'},
  ],
  KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
  GlobalSecondaryIndexes: [
    {
      IndexName: shopIndexName,
      KeySchema: [{AttributeName: 'shop', KeyType: 'HASH'}],
      Projection: {ProjectionType: 'KEYS_ONLY'},
      ProvisionedThroughput: {
        ReadCapacityUnits: 1,
        WriteCapacityUnits: 1,
      },
    },
  ],
  ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1},
}

AWS Policy for DynamoDB

This policy must be attached to a user -- dynamodb:Query does not work with inline policies.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Statement1",
      "Effect": "Allow",
      "Action": [
        "dynamodb:GetItem",
        "dynamodb:DeleteItem",
        "dynamodb:PutItem",
        "dynamodb:Query",
        "dynamodb:DescribeTable"
      ],
      "Resource": ["arn:aws:dynamodb:<region>:<account-id>:table/<table-name>"]
    }
  ]
}

If you prefer to use your own implementation of a session storage mechanism that uses the SessionStorage interface, see the implementing session storage guide.

4.0.9

7 months ago

4.0.10

6 months ago

4.0.16

4 months ago

4.0.15

4 months ago

4.0.18

1 month ago

4.0.17

3 months ago

4.0.12

5 months ago

4.0.11

6 months ago

4.0.14

4 months ago

4.0.13

5 months ago

4.0.8

9 months ago

4.0.7

9 months ago

4.0.5

10 months ago

4.0.4

11 months ago

4.0.6

10 months ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

12 months ago

4.0.2

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.0.4

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago