Skip to content
Draft
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
25 changes: 25 additions & 0 deletions packages/paykit/src/secondary-storage/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface PayKitSecondaryStorage {
/**
* Retrieve a value by key.
*
* @param key - The storage key.
* @returns The stored string value, or null if not found.
*/
get: (key: string) => Promise<string | null>;

/**
* Store a value with an optional TTL.
*
* @param key - The storage key.
* @param value - The value to store.
* @param ttl - Time to live in seconds. If ommitted, the value should be stored indefinitely.
*/
set: (key: string, value: string, ttl?: number) => Promise<void> | void;

/**
* Delete a value by key.
*
* @param key - The storage key.
*/
delete: (key: string) => Promise<void> | void;
}
2 changes: 2 additions & 0 deletions packages/paykit/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Pool } from "pg";
import type { LevelWithSilent, Logger } from "pino";

import type { StripeProviderConfig } from "../providers/provider";
import type { PayKitSecondaryStorage } from "../secondary-storage/options";
import type { PayKitEventHandlers } from "./events";
import type { PayKitPlugin } from "./plugin";
import type { PayKitPlansModule } from "./schema";
Expand All @@ -27,6 +28,7 @@ export interface PayKitOptions {
} | null>;
on?: PayKitEventHandlers;
plugins?: PayKitPlugin[];
secondaryStorage?: PayKitSecondaryStorage;
logging?: PayKitLoggingOptions;
testing?: PayKitTestingOptions;
}