honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
16.92k stars 470 forks source link

`outputFormat` supports Response #3023

Open nakasyou opened 2 weeks ago

nakasyou commented 2 weeks ago

What is the feature you are proposing?

I want outputFormat to support Response.

Currently, outputFormat supports only Handler:

import { Hono } from 'hono'
import { customHandler } from './xxx' // CustomHandler has `outputFormat` type in Input

const app = new Hono()
app.get('/', customHandler)

I want make helper, it makes response.

import { Hono } from 'hono'
import { customHelper } from './xxx'

const app = new Hono()
app.get('/', () => {
  return customHelper() // I want Response to have `outputFormat`
})

Because I want to make helper and client for helper.

NamesMT commented 2 weeks ago

Hi @nakasyou, do you have a PoC of the helper you're creating?, If the customHelper() returns a Response I think currently we could do:

const customHelper = (): Response & TypedResponse => {}

And it would fully support our current type interface.