Files
forgery/src/api/asset.ts
T
google-labs-jules[bot] ed54192f4a refactor: Convert service methods from static to instance methods
- Refactored `AssetService`, `CategoryService`, `CharacterService`, `EquipmentService`, `FileService`, `ExtractionService`, `GenerationService` to use instance methods.
- Exported singleton instances for each service.
- Updated all API routes to use the exported service instances.
- Updated all tests to use and mock service instances.
- Updated `AGENTS.md` to reflect the new service layer pattern.
- Verified changes with lint, format, typecheck, and test.
2026-02-08 04:13:21 +00:00

29 lines
684 B
TypeScript

import { Hono } from 'hono'
import { zValidator } from '@hono/zod-validator'
import { z } from 'zod'
import { assetService } from '../service/asset'
const app = new Hono()
const uploadSchema = z.object({
file: z.instanceof(File),
name: z.string().min(1),
})
const route = app.post('/upload', zValidator('form', uploadSchema), async (c) => {
const { file, name } = c.req.valid('form')
try {
const result = await assetService.createAsset(file as File, {
name,
type: (file as File).type,
})
return c.json(result, 201)
} catch (error) {
console.error(error)
return c.json({ error: 'Internal Server Error' }, 500)
}
})
export default route