956c71cd7b
Replace ESLint with Biome for ~14x faster linting (~360ms vs ~5s). - Add biome.json with rules matching ESLint parity (Next.js, a11y, TypeScript, unused vars/imports) - Remove eslint, @typescript-eslint/*, eslint-config-next, eslint-plugin-jsx-a11y, @eslint/* from deps - Remove eslint.config.mjs - Update lint script to: tsgo --noEmit && biome check . - Fix 11 real code issues caught by Biome (banned types, explicit any, unsafe finally, unreachable code, shadowed names) - Disable Biome formatter (Prettier stays for Tailwind class sorting) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
727 B
TypeScript
26 lines
727 B
TypeScript
import Cors from 'cors';
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
|
|
// Helper method to wait for a middleware to execute before continuing
|
|
// And to throw an error when an error happens in a middleware
|
|
export const runMiddleware = (
|
|
req: NextApiRequest,
|
|
res: NextApiResponse,
|
|
fn: (req: NextApiRequest, res: NextApiResponse, cb: (result: unknown) => void) => void,
|
|
) => {
|
|
return new Promise((resolve, reject) => {
|
|
fn(req, res, (result: unknown) => {
|
|
if (result instanceof Error) {
|
|
return reject(result);
|
|
}
|
|
|
|
return resolve(result);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const corsAllMethods = Cors({
|
|
methods: ['POST', 'GET', 'PUT', 'DELETE', 'HEAD', 'OPTIONS'],
|
|
maxAge: 86400,
|
|
});
|