chore: model name needs to be default name (#3538)

I was mistaken a [previous fix](452069aed9), it just moved the error.

This value should be the default model name to match [transformInput](76c90f2e59/packages/better-auth/src/adapters/create-adapter/index.ts (L324)) schema lookup.

The schema looks like this
```
{
   ...
        rateLimit: {
          modelName: 'rateLimits',
          fields: {
            key: [Object],
            count: [Object],
            lastRequest: [Object],
            id: [Object]
          }
        }
      }
```

Matching on the default name returns the correct schema.

This test is now passing locally a different rateLimiter model. 

```
            it ( "should hit rate limit on forth login attempt within 10s", async () => {

                for ( let i = 0; i < 3; i++ ) {

                    const response = await request( testApp )
                        .post( usernameSignInPath )
                        .send( { username: testUsername, password: testPassword } );

                    expect( response.statusCode ).toEqual( 200 );

                }

                const res = await request( testApp )
                    .post( usernameSignInPath )
                    .send( { username: testUsername, password: testPassword } );

                expect( res.statusCode ).toEqual( 429 );
                expect( res.headers ).toHaveProperty( "x-retry-after" );

            } );
```
This commit is contained in:
Danny
2025-07-22 18:09:03 +12:00
committed by GitHub
parent 76c90f2e59
commit 8fbe8f03a5

View File

@@ -35,7 +35,7 @@ function getRetryAfter(lastRequest: number, window: number) {
}
function createDBStorage(ctx: AuthContext) {
const model = ctx.options.rateLimit?.modelName || "rateLimit";
const model = "rateLimit";
const db = ctx.adapter;
return {
get: async (key: string) => {