Add request-scoped context for session.getUser()
Use AsyncLocalStorage to provide request context so services can access the current user without needing Call passed through every function. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// services.ts
|
||||
|
||||
import { AuthService } from "../auth";
|
||||
import { getCurrentUser } from "../context";
|
||||
import { db, migrate, migrationStatus, PostgresAuthStore } from "../database";
|
||||
import { getLogs, log } from "../logging";
|
||||
import { anonymousUser, type User } from "../user";
|
||||
import type { MaybeUser } from "../user";
|
||||
|
||||
const database = {
|
||||
db,
|
||||
@@ -29,8 +30,8 @@ const misc = {
|
||||
};
|
||||
|
||||
const session = {
|
||||
getUser: (): User => {
|
||||
return anonymousUser;
|
||||
getUser: (): MaybeUser => {
|
||||
return getCurrentUser();
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user