0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-28 08:57:34 +01:00
hono/docs/MIGRATION.md

1.7 KiB

Migration Guide

v1.6.4 to v2.0.0

There are many BREAKING CHANGES. Please follow instructions below.

The way to import Middleware on Deno has been changed

DO NOT import middleware from hono/mod.ts.

import { Hono, poweredBy } from 'https://deno.land/x/hono/mod.ts' // <--- NG

hono/mod.ts does not export middleware. To import middleware, use hono/middleware.ts:

import { Hono } from 'https://deno.land/x/hono/mod.ts'
import { poweredBy, basicAuth } from 'https://deno.land/x/hono/middleware.ts'

DO NOT use cookie middleware.

import { cookie } from 'hono/cookie' // <--- Obsolete!

You do not have to use Cookie middleware to parse or set cookies. They become default functions:

// Parse cookie
app.get('/entry/:id', (c) => {
  const value = c.req.cookie('name')
  ...
})
app.get('/', (c) => {
  c.cookie('delicious_cookie', 'choco')
  return c.text('Do you like cookie?')
})

Body parse middleware is obsolete

DO NOT use body-parse middleware.

import { bodyParse } from 'hono/body-parse' // <--- Obsolete!

You do not have to use Body parse middleware to parse request body. Use c.req.parseBody() method instead.

// Parse Request body
 app.post('', (c) => {
   const body = c.req.parseBody()
   ...
 })

GraphQL Server middleware is obsolete

DO NOT use graphql-server middleware.

import { graphqlServer } from 'hono/graphql-server' // <--- Obsolete!

It might be distributed as third-party middleware.

Mustache middleware is obsolete

DO NOT use mustache middleware.

import { mustache } from 'hono/mustache' // <--- Obsolete!

It will no longer be implemented.