Commit 16761cd
fix(server): inject ConfigService into ApiTokenGuard via useFactory (#30)
## Summary
Updated the `ApiTokenGuard` provider configuration to use a factory
function that injects the `ConfigService` dependency, allowing the guard
to access configuration at runtime.
## Key Changes
- Added import of `ConfigService` to `app.module.ts`
- Changed `ApiTokenGuard` provider from a simple class provider to a
factory provider
- The factory function receives `ConfigService` as an injected
dependency and passes it to the `ApiTokenGuard` constructor
- This enables `ApiTokenGuard` to access configuration values during
authentication checks
## Implementation Details
The provider configuration was updated from:
```typescript
providers: [{ provide: APP_GUARD, useClass: ApiTokenGuard }]
```
To:
```typescript
providers: [
{
provide: APP_GUARD,
useFactory: (config: ConfigService) => new ApiTokenGuard(config),
inject: [ConfigService],
},
]
```
This change allows `ApiTokenGuard` to be instantiated with configuration
dependencies, making it more flexible for token validation logic that
may depend on runtime configuration.
https://claude.ai/code/session_01TutexsuMCT24musZH7MH72
Co-authored-by: Claude <noreply@anthropic.com>1 parent dd2cadd commit 16761cd
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
0 commit comments