Skip to content

Conversation

@namick
Copy link

@namick namick commented Dec 28, 2024

What?

  • Added async to the example authenticate function as it uses await.
  • Updated example function to return the user with the collection property so type-checking works.

Why?

Better docs! 😄

TypeScript is expecting the authenticate function to return a User type from the payload package, and this requires the collection property from BaseUser.

@namick namick force-pushed the docs-custom-auth-strategy branch from 62954d3 to 948a3fc Compare January 10, 2025 16:03
Comment on lines +67 to +72
const user: User = {
...usersQuery.docs[0],

// Returned user also needs the collection property
collection: 'users',
}
Copy link
Member

@r1tsuu r1tsuu Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace spread that introduces copying overhead with mutation:

const user = usersQuery.docs[0] as unknown as User | undefined;
// handle null
user.collection = 'users'

The as cast is needed when using strict: true

@github-actions github-actions bot added the stale label Feb 15, 2025
@github-actions github-actions bot removed the stale label Jan 21, 2026
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