Skip to content

Commit

Permalink
refactor(session): remove unnecessary async for clear (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
remonke authored Apr 17, 2024
1 parent 458cfac commit 9bd4aef
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/utils/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export async function useSession<T extends SessionDataT = SessionDataT>(
await updateSession<T>(event, config, update);
return sessionManager;
},
clear: async () => {
await clearSession(event, config);
return sessionManager;
clear: () => {
clearSession(event, config);
return Promise.resolve(sessionManager);
},
};
return sessionManager;
Expand Down Expand Up @@ -234,16 +234,17 @@ export async function unsealSession(
/**
* Clear the session data for the current request.
*/
export async function clearSession(
export function clearSession(
event: H3Event,
config: Partial<SessionConfig>,
) {
): Promise<void> {
const sessionName = config.name || DEFAULT_NAME;
if (event.context.sessions?.[sessionName]) {
delete event.context.sessions![sessionName];
}
await setCookie(event, sessionName, "", {
setCookie(event, sessionName, "", {
...DEFAULT_COOKIE,
...config.cookie,
});
return Promise.resolve();
}

0 comments on commit 9bd4aef

Please sign in to comment.