Skip to content

Commit 728e631

Browse files
refactor(oauth): add typed OAuthRoutesConfig to ConstructiveOptions
Move OAuthRoutesConfig interface to graphql/types package and add oauth property to ConstructiveOptions, removing the need for `(opts as any).oauth` type assertion. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 24b965d commit 728e631

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

graphql/server/src/middleware/oauth.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,6 @@ async function generateCrossOriginToken(
224224
// OAuth Routes
225225
// =============================================================================
226226

227-
export interface OAuthRoutesConfig {
228-
/** @deprecated baseUrl is now derived from request headers for multi-tenant support */
229-
baseUrl?: string;
230-
errorRedirectPath?: string;
231-
allowSignup?: boolean;
232-
requireVerifiedEmail?: boolean;
233-
}
234-
235227
function getBaseUrl(req: Request): string {
236228
const protocol = req.protocol || 'http';
237229
const host = req.get('host') || 'localhost:3000';
@@ -240,7 +232,7 @@ function getBaseUrl(req: Request): string {
240232

241233
export function createOAuthRoutes(opts: ConstructiveOptions): Router {
242234
const router = Router();
243-
const oauthConfig = (opts as any).oauth as OAuthRoutesConfig | undefined;
235+
const oauthConfig = opts.oauth;
244236

245237
const errorRedirectPath = oauthConfig?.errorRedirectPath ?? '/auth/error';
246238
const allowSignup = oauthConfig?.allowSignup ?? true;

graphql/types/src/constructive.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ import {
2020
} from './graphile';
2121
import { LlmOptions } from './llm';
2222

23+
/**
24+
* OAuth routes configuration
25+
*/
26+
export interface OAuthRoutesConfig {
27+
/** @deprecated baseUrl is now derived from request headers for multi-tenant support */
28+
baseUrl?: string;
29+
/** Path to redirect on error (default: /auth/error) */
30+
errorRedirectPath?: string;
31+
/** Allow signup via OAuth (default: true) */
32+
allowSignup?: boolean;
33+
/** Require verified email for OAuth signup (default: true) */
34+
requireVerifiedEmail?: boolean;
35+
}
36+
2337
/**
2438
* GraphQL-specific options for Constructive
2539
*/
@@ -59,6 +73,8 @@ export interface ConstructiveOptions extends PgpmOptions, ConstructiveGraphQLOpt
5973
jobs?: JobsConfig;
6074
/** LLM provider configuration (embeddings, chat, RAG) */
6175
llm?: LlmOptions;
76+
/** OAuth routes configuration */
77+
oauth?: OAuthRoutesConfig;
6278
}
6379

6480
/**

graphql/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export {
1212
export {
1313
ConstructiveGraphQLOptions,
1414
ConstructiveOptions,
15+
OAuthRoutesConfig,
1516
constructiveGraphqlDefaults,
1617
constructiveDefaults
1718
} from './constructive';

0 commit comments

Comments
 (0)