- Auto-convert on image load (0ms) and flag change (400ms debounce) - SizeControl: linked width/height sliders with aspect-ratio lock and 0.5 font correction factor - Full flag exposure for all 4 tools (chafa, jp2a, ascii-image-converter, img2txt) - ChafaOptions: symbols/fill dropdowns, dither controls, work/threshold/font-ratio sliders, format select, toggles - Jp2aOptions: color-depth, RGB weight sliders, edge controls, 8 toggles - ImgTxtOptions: dither select with valid libcaca values, gamma slider - OutputDisplay: ansi-to-html rendering for colored chafa output - ShellBridge: abort-previous pattern, conversion-start/end lifecycle events - Test API (ENABLE_TEST_API=true): /test/health, /test/convert, /test/flags/:tool, /test/imagemagick - buildArgs: space-separated args (not = format); full schemas in SCHEMAS export - runChafa: width/height destructured and combined into --size WxH - Port changed to 3050; Vite on 0.0.0.0 with allowedHosts for production domain - 98 unit tests passing across 12 test files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
914 B
JavaScript
35 lines
914 B
JavaScript
import Fastify from 'fastify'
|
|
import multipart from '@fastify/multipart'
|
|
import cors from '@fastify/cors'
|
|
import { convertRoute } from './routes/convert.js'
|
|
import { testRoutes } from './routes/testApi.js'
|
|
|
|
const fastify = Fastify({ logger: { level: 'warn' } })
|
|
|
|
await fastify.register(cors, {
|
|
origin: [
|
|
'http://localhost:5173',
|
|
'http://localhost:4173',
|
|
'https://asciinator.waynehayesdevelopment.com',
|
|
],
|
|
})
|
|
|
|
await fastify.register(multipart, {
|
|
limits: { fileSize: 20 * 1024 * 1024 },
|
|
})
|
|
|
|
await fastify.register(convertRoute)
|
|
|
|
if (process.env.ENABLE_TEST_API === 'true') {
|
|
await fastify.register(testRoutes, { prefix: '/test' })
|
|
console.log('Test API enabled → /test/{health,convert,flags,imagemagick}')
|
|
}
|
|
|
|
try {
|
|
await fastify.listen({ port: 3050, host: '127.0.0.1' })
|
|
console.log('ASCIInator API → http://127.0.0.1:3050')
|
|
} catch (err) {
|
|
fastify.log.error(err)
|
|
process.exit(1)
|
|
}
|