Repository: honojs/hono
File: src/hono-base.ts (TypeScript)

Code before:
   */
  router?: Router<[H, RouterRoute]>
  /**
   * `getPath` can handle the host header value.
   * @example
   * ```ts
   * const app = new Hono({
   *  getPath: (req) =>
   *   '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
   * })
   *
   * app.get('/www1.example.com/hello', () => c.text('hello www1'))
   *
   * // A following request will match the route:
   * // new Request('http://www1.example.com/hello', {
   * //  headers: { host: 'www1.example.com' },
   * // })
   * ```
   * @see https://hono.dev/api/routing#routing-with-host-header-value
   */
  getPath?: GetPath<E>
}

class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
  // Theses methods are dynamically initialized in the constructor.
  /**
   * Handler for GET requests.
   */
  get!: HandlerInterface<E, 'get', S, BasePath>

  /**
   * Handler for POST requests.
   *
   * @see https://hono.dev/api/routing#routing
   */
  post!: HandlerInterface<E, 'post', S, BasePath>

  /**
   * Handler for PUT requests.
   *
   * @see https://hono.dev/api/routing#routing
   */
  put!: HandlerInterface<E, 'put', S, BasePath>

  /**
   * Handler for DELETE requests.
   *
   * @see https://hono.dev/api/routing#routing
   */
  delete!: HandlerInterface<E, 'delete', S, BasePath>


Review comment (suggestion):
It seems these docs are not used.

![CleanShot 2024-05-29 at 02 05 40@2x](https://github.com/honojs/hono/assets/10682/510be2bc-382b-4653-806f-72a2bd6bd1e1)

I don't have a good idea to show the docs for the super complex types in the IDE. But, I think these docs for `get!` or `post!` etc. are not necessary.

Code after:
   * @see https://hono.dev/api/hono#router-option
   */
  router?: Router<[H, RouterRoute]>
  /**
   * `getPath` can handle the host header value.
   * @example
   * ```ts
   * const app = new Hono({
   *  getPath: (req) =>
   *   '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
   * })
   *
   * app.get('/www1.example.com/hello', () => c.text('hello www1'))
   *
   * // A following request will match the route:
   * // new Request('http://www1.example.com/hello', {
   * //  headers: { host: 'www1.example.com' },
   * // })
   * ```
   * @see https://hono.dev/api/routing#routing-with-host-header-value
   */
  getPath?: GetPath<E>
}

class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
  get!: HandlerInterface<E, 'get', S, BasePath>
  post!: HandlerInterface<E, 'post', S, BasePath>
  put!: HandlerInterface<E, 'put', S, BasePath>
  delete!: HandlerInterface<E, 'delete', S, BasePath>
  options!: HandlerInterface<E, 'options', S, BasePath>
  patch!: HandlerInterface<E, 'patch', S, BasePath>
  all!: HandlerInterface<E, 'all', S, BasePath>
  on: OnHandlerInterface<E, S, BasePath>
  use: MiddlewareHandlerInterface<E, S, BasePath>

  /*
    This class is like an abstract class and does not have a router.
    To use it, inherit the class and implement router in the constructor.
  */
  router!: Router<[H, RouterRoute]>
  readonly getPath: GetPath<E>
  // Cannot use `#` because it requires visibility at JavaScript runtime.
  private _basePath: string = '/'
  #path: string = '/'

  routes: RouterRoute[] = []

  constructor(options: HonoOptions<E> = {}) {
    // Implementation of app.get(...handlers[]) or app.get(path, ...handlers[])
    const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]
    allMethods.forEach((method) => {