CommitCraft·AI3 free · BYOK unlimited

Commit messages in seconds

Paste a git diff or describe your changes. AI generates a perfect commit message following conventional commits, Angular, or simple format.

See it in action

Git diff → perfect commit message

Paste a diff or describe your changes and get a great commit message in seconds.

git diff HEAD
diff --git a/src/auth/session.ts b/src/auth/session.ts
index 4a2d9b1..8f3e7c2 100644
--- a/src/auth/session.ts
+++ b/src/auth/session.ts
@@ -12,6 +12,18 @@ export function createSession(userId: string): Session {
   };
 }

+export function refreshSession(session: Session): Session {
+  if (Date.now() > session.expiresAt) {
+    throw new Error("Session expired");
+  }
+  return {
+    ...session,
+    expiresAt: Date.now() + SESSION_TTL_MS,
+    lastRefreshedAt: Date.now(),
+  };
+}
+
 export function invalidateSession(sessionId: string): void {
   sessions.delete(sessionId);
 }
diff --git a/src/auth/middleware.ts b/src/auth/middleware.ts
index 1bc34a2..9d2e5c1 100644
--- a/src/auth/middleware.ts
+++ b/src/auth/middleware.ts
@@ -8,6 +8,9 @@ export async function authMiddleware(req, res, next) {
   const session = getSession(token);
   if (!session) return res.status(401).json({ error: "Unauthorized" });

+  // Automatically refresh session on activity
+  refreshSession(session);
+
   req.user = session.user;
   next();
 }
commit messageAI generated
feat(auth): add session refresh with automatic middleware integration

Implement session refresh functionality to extend active sessions and
integrate automatic refresh into the auth middleware.

- Add `refreshSession()` that extends TTL and sets `lastRefreshedAt`
- Throw on expired sessions instead of silently returning stale data
- Auto-refresh sessions on every authenticated request in middleware

3 free generations remaining