Skip to main content

Function: createPostgresdbOAuthStores()

createPostgresdbOAuthStores(__namedParameters): PostgresdbOAuthStores

Defined in: packages/auth-postgresdb/src/createPostgresdbOAuthStores.ts:47

Creates every durable OAuth store from a @ttoss/postgresdb db handle.

The stores are mechanical adapters between the @ttoss/auth-core store contracts and Sequelize, so an app that already uses @ttoss/postgresdb does not have to write them — nor reach around its own ORM to inject a raw pg query runner.

Parameters

ParameterTypeDescription
__namedParameters{ db: { OAuthAuthCode: typeof OAuthAuthCode; OAuthClient: typeof OAuthClient; OAuthConsent: typeof OAuthConsent; OAuthRefreshToken: typeof OAuthRefreshToken; }; }-
__namedParameters.db{ OAuthAuthCode: typeof OAuthAuthCode; OAuthClient: typeof OAuthClient; OAuthConsent: typeof OAuthConsent; OAuthRefreshToken: typeof OAuthRefreshToken; }The handle returned by @ttoss/postgresdb's initialize, with oauthModels among its registered models.
__namedParameters.db.OAuthAuthCodetypeof OAuthAuthCode-
__namedParameters.db.OAuthClienttypeof OAuthClient-
__namedParameters.db.OAuthConsenttypeof OAuthConsent-
__namedParameters.db.OAuthRefreshTokentypeof OAuthRefreshToken-

Returns

PostgresdbOAuthStores

Example

import { createPostgresdbOAuthStores, oauthModels } from '@ttoss/auth-postgresdb';
import { initialize } from '@ttoss/postgresdb';

const db = await initialize({ models: { ...oauthModels, User } });

const { clientStore, authCodeStore, consentStore, refreshTokenStore } =
createPostgresdbOAuthStores({ db });