This commit is contained in:
Nicolas Cantu 2026-01-13 17:23:28 +01:00
parent 2116ee4ffc
commit 6e649df0af
15 changed files with 41 additions and 56 deletions

View File

@ -27,7 +27,7 @@ Refactor purement structurel (sans changement fonctionnel) :
- `components/authorPage/SeriesList.tsx`
- `components/authorPage/useAuthorData.ts`
- `components/authorPage/resolveAuthorHashIdOrPubkey.ts`
- `pages/api/nip95-upload.ts` (shim de compatibilité pour la validation Next/TypeScript)
- `pages/api/nip95-upload.ts` (route API NIP-95 upload; impl déplacée vers `lib/api/nip95-upload/*` pour éviter des routes Next involontaires)
- `lib/metadataExtractor/reviewTip.ts` (validation stricte des champs requis)
- `lib/paymentNotes/sponsoring.ts` (exactOptionalPropertyTypes)
- `components/relayManager/RelayCard.tsx` (typage lastSyncDate)

View File

@ -34,4 +34,3 @@ export async function nip95UploadHandler(req: NextApiRequest, res: NextApiRespon
function readProxyQueryParams(req: NextApiRequest): ProxyQueryParams {
return { targetEndpoint: (req.query.endpoint as string) ?? 'https://void.cat/upload', authToken: req.query.auth as string | undefined }
}

View File

@ -0,0 +1 @@
export { nip95UploadHandler } from './handler'

View File

@ -40,4 +40,3 @@ export function safeUnlink(filepath: string): void {
console.error('Error deleting temp file:', unlinkError)
}
}

View File

@ -141,4 +141,3 @@ async function readIncomingMessageBody(message: http.IncomingMessage): Promise<s
message.on('error', reject)
})
}

View File

@ -15,4 +15,3 @@ export function handleProxyRequestError(params: { error: unknown; targetEndpoint
}
return params.error instanceof Error ? params.error : new Error(errorMessage)
}

View File

@ -30,4 +30,3 @@ export function handleProxyError(params: {
params.res.status(500).json({ error: `Failed to connect to upload endpoint: ${errorMessage}` })
}

View File

@ -130,4 +130,3 @@ function buildHtmlErrorSuggestion(params: { is404: boolean; is403: boolean; is50
}
return 'The endpoint returned HTML instead of JSON; verify URL and required headers'
}

View File

@ -5,4 +5,3 @@ export function getErrnoCode(error: unknown): string | undefined {
const rec = error as Record<string, unknown>
return typeof rec.code === 'string' ? rec.code : undefined
}

View File

@ -23,4 +23,3 @@ export interface ProxyQueryParams {
}
export type UploadedFile = FormidableFile

View File

@ -36,4 +36,3 @@ export function getRedirectLocation(headers: unknown): string | undefined {
}
return undefined
}

View File

@ -55,7 +55,7 @@ function processLine(line: string, index: number, state: RenderState, elements:
renderParagraphOrBreak(line, index, state, elements)
}
function renderHeading(line: string, index: number, state: RenderState, elements: React.ReactElement[]): boolean {
function renderHeading(line: string, _index: number, state: RenderState, elements: React.ReactElement[]): boolean {
if (line.startsWith('# ')) {
elements.push(<h1 key={nextElementKey(state, 'h1', line)} className="text-3xl font-bold mt-8 mb-4 text-neon-cyan font-mono">{line.substring(2)}</h1>)
return true
@ -75,7 +75,7 @@ function renderHeading(line: string, index: number, state: RenderState, elements
return false
}
function renderListLine(line: string, index: number, state: RenderState): boolean {
function renderListLine(line: string, _index: number, state: RenderState): boolean {
if (line.startsWith('- ') || line.startsWith('* ')) {
state.currentList.push({ key: nextElementKey(state, 'li', line), line })
return true
@ -83,23 +83,23 @@ function renderListLine(line: string, index: number, state: RenderState): boolea
return false
}
function renderLinkLine(line: string, index: number, state: RenderState, elements: React.ReactElement[]): boolean {
function renderLinkLine(line: string, _index: number, state: RenderState, elements: React.ReactElement[]): boolean {
if (line.includes('[') && line.includes('](')) {
renderLink(line, index, state, elements)
renderLink(line, state, elements)
return true
}
return false
}
function renderBoldAndCodeLine(line: string, index: number, state: RenderState, elements: React.ReactElement[]): boolean {
function renderBoldAndCodeLine(line: string, _index: number, state: RenderState, elements: React.ReactElement[]): boolean {
if (line.includes('**') || line.includes('`')) {
renderBoldAndCode(line, index, state, elements)
renderBoldAndCode(line, state, elements)
return true
}
return false
}
function renderParagraphOrBreak(line: string, index: number, state: RenderState, elements: React.ReactElement[]): void {
function renderParagraphOrBreak(line: string, _index: number, state: RenderState, elements: React.ReactElement[]): void {
if (line.trim() !== '') {
elements.push(<p key={nextElementKey(state, 'p', line)} className="mb-4 text-cyber-accent">{line}</p>)
return
@ -114,7 +114,7 @@ function renderParagraphOrBreak(line: string, index: number, state: RenderState,
function handleCodeBlock(
_line: string,
index: number,
_index: number,
state: RenderState,
elements: React.ReactElement[]
): void {
@ -173,7 +173,7 @@ function createLinkElement(
)
}
function renderLink(line: string, index: number, state: RenderState, elements: React.ReactElement[]): void {
function renderLink(line: string, state: RenderState, elements: React.ReactElement[]): void {
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g
let lastIndex = 0
const parts: (string | React.ReactElement)[] = []
@ -187,7 +187,7 @@ function renderLink(line: string, index: number, state: RenderState, elements: R
const href = match[2]
const isExternal = href.startsWith('http')
if (match[1]) {
parts.push(createLinkElement(match[1], href, `link-${index}-${match.index}`, isExternal))
parts.push(createLinkElement(match[1], href, `link-${match.index}-${href}`, isExternal))
}
lastIndex = match.index + match[0].length
}
@ -200,7 +200,7 @@ function renderLink(line: string, index: number, state: RenderState, elements: R
elements.push(<p key={nextElementKey(state, 'p', line)} className="mb-4">{parts}</p>)
}
function renderBoldAndCode(line: string, index: number, state: RenderState, elements: React.ReactElement[]): void {
function renderBoldAndCode(line: string, state: RenderState, elements: React.ReactElement[]): void {
const parts: (string | React.ReactElement)[] = []
const codeRegex = /`([^`]+)`/g
let codeMatch

View File

@ -1 +1,10 @@
export { config, default } from './nip95-upload/index'
import type { NextApiRequest, NextApiResponse } from 'next'
import { nip95UploadHandler } from '@/lib/api/nip95-upload'
export const config = {
api: { bodyParser: false },
}
export default async function handler(req: NextApiRequest, res: NextApiResponse): Promise<void> {
return nip95UploadHandler(req, res)
}

View File

@ -1,11 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { nip95UploadHandler } from './handler'
export const config = {
api: { bodyParser: false },
}
export default async function handler(req: NextApiRequest, res: NextApiResponse): Promise<void> {
return nip95UploadHandler(req, res)
}

View File

@ -9,33 +9,28 @@ const { execSync } = require('child_process')
const projectRoot = process.cwd()
try {
// Change to project root and run next lint
function runEslint() {
execSync('npx eslint . --ext .ts,.tsx --ignore-pattern next-env.d.ts', {
stdio: 'inherit',
cwd: projectRoot,
})
}
function runNextLint() {
process.chdir(projectRoot)
execSync('npx next lint', {
stdio: 'inherit',
cwd: projectRoot,
env: { ...process.env, PWD: projectRoot },
})
} catch {
// If next lint fails, try eslint directly with flat config
console.log('Falling back to eslint directly...')
}
try {
// Try auto-fix first
try {
execSync('npx eslint . --ext .ts,.tsx --fix', {
stdio: 'inherit',
cwd: projectRoot,
})
} catch {
// If auto-fix fails, run without fix to show remaining errors
execSync('npx eslint . --ext .ts,.tsx', {
stdio: 'inherit',
cwd: projectRoot,
})
if (process.env.USE_NEXT_LINT === '1') {
runNextLint()
} else {
runEslint()
}
} catch {
console.error('Both next lint and eslint failed')
process.exit(1)
}
}