2026-04-28 15:47:57 -04:00
|
|
|
import Fastify from 'fastify'
|
|
|
|
|
import multipart from '@fastify/multipart'
|
|
|
|
|
import cors from '@fastify/cors'
|
|
|
|
|
import { convertRoute } from './routes/convert.js'
|
feat: full GUI, test API, auto-convert, aspect-ratio sliders
- 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>
2026-04-29 06:29:45 -04:00
|
|
|
import { testRoutes } from './routes/testApi.js'
|
2026-04-28 15:47:57 -04:00
|
|
|
|
|
|
|
|
const fastify = Fastify({ logger: { level: 'warn' } })
|
|
|
|
|
|
feat: full GUI, test API, auto-convert, aspect-ratio sliders
- 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>
2026-04-29 06:29:45 -04:00
|
|
|
await fastify.register(cors, {
|
|
|
|
|
origin: [
|
|
|
|
|
'http://localhost:5173',
|
|
|
|
|
'http://localhost:4173',
|
|
|
|
|
'https://asciinator.waynehayesdevelopment.com',
|
|
|
|
|
],
|
|
|
|
|
})
|
2026-04-28 15:47:57 -04:00
|
|
|
|
|
|
|
|
await fastify.register(multipart, {
|
|
|
|
|
limits: { fileSize: 20 * 1024 * 1024 },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
await fastify.register(convertRoute)
|
|
|
|
|
|
feat: full GUI, test API, auto-convert, aspect-ratio sliders
- 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>
2026-04-29 06:29:45 -04:00
|
|
|
if (process.env.ENABLE_TEST_API === 'true') {
|
|
|
|
|
await fastify.register(testRoutes, { prefix: '/test' })
|
|
|
|
|
console.log('Test API enabled → /test/{health,convert,flags,imagemagick}')
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-28 15:47:57 -04:00
|
|
|
try {
|
2026-04-29 07:26:18 -04:00
|
|
|
await fastify.listen({ port: 3050, host: '0.0.0.0' })
|
|
|
|
|
console.log('ASCIInator API → http://0.0.0.0:3050')
|
2026-04-28 15:47:57 -04:00
|
|
|
} catch (err) {
|
|
|
|
|
fastify.log.error(err)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|