chore: import upstream snapshot with attribution
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:38:58 +08:00
commit bb5c75ce05
8824 changed files with 1946442 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { verifyToken } from '@clerk/backend';
/**
* Extract and verify Clerk JWT from Authorization header.
* Returns the userId on success, or sends an error response and returns null.
*/
export async function authenticateRequest(req, res) {
const authHeader = req.headers.authorization;
if (!authHeader?.startsWith('Bearer ')) {
res.status(401).json({ error: 'Missing or invalid Authorization header' });
return null;
}
const token = authHeader.slice(7);
try {
const payload = await verifyToken(token, {
secretKey: process.env.CLERK_SECRET_KEY,
});
return payload.sub;
} catch (err) {
console.error('Clerk token verification failed:', err.message);
res.status(401).json({ error: 'Invalid or expired token' });
return null;
}
}
+9
View File
@@ -0,0 +1,9 @@
import { neon } from '@neondatabase/serverless';
export function getNeonClient() {
const connectionString = process.env.NEON_DATABASE_URL;
if (!connectionString) {
throw new Error('NEON_DATABASE_URL not configured');
}
return neon(connectionString);
}