Skip to content

Conversation

@Sgulli
Copy link
Contributor

@Sgulli Sgulli commented Oct 6, 2025

What

Improved hooks validation, expanded test coverage, and enhanced code quality for NestJS Better Auth integration

Changes

  • Improved hooks flexibility: Allow undefined hooks when no @hook providers exist (no workarounds needed)
  • Enhanced test coverage: Added 17+ new tests across REST, GraphQL, and hooks validation
  • Added test utilities: generateTestUser() and signUpTestUser() helpers
  • Refactored forRoot() logic: Simplified with isNewFormat variable and addGuardProvider() helper
  • Improved CORS handling: Better variable names and cleaner conditional logic
  • Enhanced type safety: Added RequestWithSession type for better session typing
  • Updated dependencies: Apollo Server@5, Biome@2.2.5, @nestjs/apollo@13.2.1, @nestjs/graphql@13.2.0,
  • added @as-integrations/express5 as requested by the error stack
  • Fixed test controllers: Use @Session decorator consistently across REST and GraphQL

Testing

[x] Added comprehensive hooks validation tests (6 scenarios)
[x] Expanded REST auth tests with invalid token cases
[x] Expanded GraphQL auth tests with edge cases
[x] Added test helper utilities for cleaner code
[x] Extracted helper methods following DRY principle
[x] Updated dependencies for GraphQL compatibility
[x] Verified all tests pass with improved coverage

Build

Does it build? Yes

bun run build                        
$ unbuild
ℹ Automatically detected entries: src/index [esm] [cjs] [dts]                          23:44:49
ℹ Building nestjs-better-auth                                                          23:44:49
ℹ Cleaning dist directory: ./dist                                                      23:44:49
✔ Build succeeded for nestjs-better-auth                                               23:44:51

Output

File Size Chunk Exports
dist/index.cjs 11.1 kB 11.1 kB AFTER_HOOK_KEY, AUTH_MODULE_OPTIONS_KEY, AfterHook, AllowAnonymous, AuthGuard, AuthModule, AuthService, BEFORE_HOOK_KEY, BeforeHook, HOOK_KEY, Hook, Optional, OptionalAuth, Public, Session
dist/index.mjs 10.6 kB 10.6 kB AFTER_HOOK_KEY, AUTH_MODULE_OPTIONS_KEY, AfterHook, AllowAnonymous, AuthGuard, AuthModule, AuthService, BEFORE_HOOK_KEY, BeforeHook, HOOK_KEY, Hook, Optional, OptionalAuth, Public, Session

Σ Total dist size (byte size): 40.5 kB

Sgulli added 5 commits October 6, 2025 23:08
- Fix null hooks validation bug
- Allow undefined hooks without workarounds
- Add 17+ new auth tests with helpers
- Extract addGuardProvider() helper
- Update Apollo and NestJS dependencies
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 6, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ThallesP/nestjs-better-auth/@thallesp/nestjs-better-auth@46

commit: d21f556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants