Skip to content

Commit

Permalink
[Patch] - Server auth optimizations (#314)
Browse files Browse the repository at this point in the history
* perf: remove extra fetch when pagination not required

* chore: change refresh-store route from get to post
  • Loading branch information
gowthamsundaresan authored Dec 19, 2024
1 parent 95d7474 commit 2be4d91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/routes/auth/authController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export async function registerUser(req: Request, res: Response) {
}

/**
* Protected route, refreshes the server's entire auth store. Called by Supabase edge fn signal-refresh.
* Protected route, refreshes the server's entire auth store. Called by Supabase edge fn signal-refresh
* This function will fail if the caller does not use admin-level auth token
*
* @param req
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/routes/auth/authRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const router = express.Router()

// API routes for /auth

router.get('/refresh-store', routeCache.cacheSeconds(5), signalRefreshAuthStore)
router.post('/refresh-store', signalRefreshAuthStore)
router.get('/users/:address/check-status', routeCache.cacheSeconds(30), checkUserStatus)
router.get('/users/:address/nonce', routeCache.cacheSeconds(10), generateNonce)
router.post('/users/:address/register', routeCache.cacheSeconds(10), registerUser)
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/utils/authMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ export async function refreshAuthStore() {
)
}
}

if (users.length < take) break

skip += take
}

Expand Down

0 comments on commit 2be4d91

Please sign in to comment.