feat: add internal endpoint to purge user session

This commit is contained in:
2026-02-19 14:16:12 +07:00
parent 959af8abdc
commit 7a3c46c6c1
4 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,17 @@
import { AppError } from "../../../helpers/error/instances/app";
import { prisma } from "../../../utils/databases/prisma/connection";
export const deleteAllUnusedUserSessionRepository = async () => {
try {
return await prisma.userSession.deleteMany({
where: {
isAuthenticated: false,
deletedAt: {
not: null,
},
},
});
} catch (error) {
throw new AppError(500, "Failed to delete all unused user sessions", error);
}
};