Sem:一种用于代码理解的新型原语——并非 LSP,而是基于 Git 之上的实体。
Sem: New primitive for code understanding – not LSPs, but entities on top of Git
原始链接: https://ataraxy-labs.github.io/sem/
```diff
--- a/src/auth/login.ts
+++ b/src/auth/login.ts
@@ -12,6 +12,18 @@
+export function validateToken(token: string) {
+ const decoded = jwt.verify(token, SECRET);
+ if (!decoded.exp || decoded.exp < Date.now() / 1000) {
+ throw new TokenExpiredError();
+ }
+ return decoded;
+}
+
@@ -24,8 +36,10 @@
export async function authenticateUser(
- const user = await db.findUser(email);
- if (!user) return null;
+ const user = await db.findUser(email);
+ if (!user) throw new UserNotFoundError();
+ await rateLimiter.check(email);
@@ -45,12 +59,0 @@
-export function legacyAuth(user, pass) {
- return db.query('SELECT * FROM users
- WHERE email = ? AND password = ?',
- [user, pass]);
-}
```