
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
@shopify/shopify-app-session-storage-prisma
Advanced tools
Shopify App Session Storage for Prisma
This package implements the SessionStorage
interface that works with an instance of Prisma.
Session storage for prisma requires a schema.prisma
with a Session table with at-least the following columns:
model Session {
id String @id
shop String
state String
isOnline Boolean @default(false)
scope String?
expires DateTime?
accessToken String
userId BigInt?
firstName String?
lastName String?
email String?
accountOwner Boolean?
locale String?
collaborator Boolean?
emailVerified Boolean?
}
[!WARNING] Some DB adapters adapters may set a maximum length for the String type by default, please ensure your fields allow for long enough strings. See https://www.prisma.io/docs/orm/reference/prisma-schema-reference#string for more information
You can then instantiate and use PrismaSessionStorage
like so:
import {shopifyApp} from '@shopify/shopify-app-express';
import {PrismaSessionStorage} from '@shopify/shopify-app-session-storage-prisma';
import {PrismaClient} from '@prisma/client';
const prisma = new PrismaClient();
const storage = new PrismaSessionStorage(prisma);
const shopify = shopifyApp({
sessionStorage: storage,
// ...
});
You can also pass in some optional flags to tweak the behavior of the adapter.
You can pass in the tableName
option if you want to use a different table name in your schema.
For example:
const storage = new PrismaSessionStorage(prisma, {
tableName: 'MyCustomSession',
});
Note: If you use SQLite with Prisma note that sqlite is a local, file-based SQL database. It persists all tables to a single file on your local disk. As such, it’s simple to set up and is a great choice for getting started with Shopify App development. However, it won’t work when your app getting scaled across multiple instances because they would each create their own database.
If you prefer to use your own implementation of a session storage mechanism that is compatible with the @shopify/shopify-app-express
package, see the implementing session storage guide.
When the storage starts up, it will connect to the database during startup so the app can start. If the DB server takes too long to start, the setup may fail.
To avoid that, you can pass in the connectionRetries
and connectionRetryIntervalMs
options to control how many times to retry, and how long to wait between tries, respectively.
For example:
const storage = new PrismaSessionStorage(prisma, {
// Default values
connectionRetries: 2,
connectionRetryIntervalMs: 5000,
});
When updating the type of database you are using, you may need to make some changes to your project for Prisma to work correctly. Please review the prisma documentation for your specific database type for configuration.
MissingSessionTableError
error is thrownSome common reasons for that are:
Session
table above was not added to the schema.Session
.Here are some possible solutions for this issue:
migrate
command to apply the schema.prisma.schema
file.Session
.MongoDB does not support the prisma migrate command. If you are using MongoDB please see the Prisma documentation for configuring your database.
FAQs
Shopify App Session Storage for Prisma
We found that @shopify/shopify-app-session-storage-prisma demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.