Repository navigation
Fix TypeScript compilation errors in adapters - add AuthService type parameter #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,13 @@ export const ConnectReq = createParamDecorator( | |
| }, | ||
| ); | ||
|
|
||
| /** | ||
| * Auth service interface with handleRequest method | ||
| */ | ||
| interface AuthService { | ||
| handleRequest(request: Request): Promise<Response>; | ||
| } | ||
|
|
||
| // --- Service --- | ||
|
|
||
| @Injectable() | ||
|
|
@@ -109,7 +116,7 @@ export class ObjectStackController { | |
| // Try AuthPlugin service first (preferred path) | ||
| const kernel = this.service.getKernel(); | ||
| const authService = typeof kernel.getService === 'function' | ||
| ? kernel.getService('auth') | ||
| ? kernel.getService<AuthService>('auth') | ||
| : null; | ||
|
Comment on lines
117
to
120
|
||
|
|
||
| if (authService && typeof authService.handleRequest === 'function') { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,13 @@ export interface NextAdapterOptions { | |
| prefix?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Auth service interface with handleRequest method | ||
| */ | ||
| interface AuthService { | ||
| handleRequest(request: Request): Promise<Response>; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a route handler for Next.js App Router | ||
| * Handles /api/[...objectstack] pattern | ||
|
|
@@ -63,7 +70,7 @@ export function createRouteHandler(options: NextAdapterOptions) { | |
| if (segments[0] === 'auth') { | ||
| // Try AuthPlugin service first (preferred path) | ||
| const authService = typeof options.kernel.getService === 'function' | ||
| ? options.kernel.getService('auth') | ||
| ? options.kernel.getService<AuthService>('auth') | ||
| : null; | ||
|
Comment on lines
71
to
74
|
||
|
|
||
| if (authService && typeof authService.handleRequest === 'function') { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjectKernel.getService()throws when a service is missing. If the auth plugin/service isn鈥檛 registered,getService<AuthService>('auth')will throw and the route will return a 500 from the catch block, never reaching the legacydispatcher.handleAuth(...)fallback. Wrap thegetServicecall in a try/catch and treat the "service not found" case asnullso fallback behavior works.