This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
sdi/ChatGPT-CodeReview/middleware.ts
2025-04-17 12:00:31 +09:00

30 lines
657 B
TypeScript

import { next, rewrite } from '@vercel/edge';
export const config = {
matcher: '/api/github/webhooks',
};
export default async function middleware(request: any) {
let json;
try {
console.log('enter');
json = await request?.json?.();
} catch {
return rewrite(new URL('https://github.com/apps/cr-gpt'));
}
if (!json) {
console.log('received is not a json');
return rewrite(new URL('https://github.com/apps/cr-gpt'));
}
if (!json.before || !json.after || !json.commits) {
console.log('invalid event');
return rewrite(new URL('https://github.com/apps/cr-gpt'));
}
console.log('GO next');
return next();
}