Skip to content
Myr

docs: update readme

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by Yusuke Wada · parent 04460a6 · Browse files · 3 files+119 added−35 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+119 added−35 removed

  • other:+119 added−35 removed

3 files+119 added−35 removed

modified:docs/README.ja.md+58 added-5 removed
18 unmodified lines
19[![npm type definitions](https://img.shields.io/npm/types/hono)](https://www.npmjs.com/package/hono)20[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/yusukebe/hono)](https://github.com/yusukebe/hono/pulse)21[![GitHub last commit](https://img.shields.io/github/last-commit/yusukebe/hono)](https://github.com/yusukebe/hono/commits/master)2223Hono - _日本語の\[炎\]に由来 🔥_ - はCloudflare WorkersやFastly Compute@Edge向けの小さくて、シンプルで、めちゃくちゃ速いWebフレームワークです。23Hono - _日本語の\[炎\]に由来 🔥_ - はCloudflare WorkersやFastly Compute@Edgeなど、Service Workerベースのサーバーレス向けの小さくて、シンプルで、めちゃくちゃ速いWebフレームワークです。2425```js26import { Hono } from 'hono'27const app = new Hono()
29 unmodified lines
57Honoを使って、Cloudflare Workersのアプリケーションを作っている様子です。5859![Demo](https://user-images.githubusercontent.com/10682/151973526-342644f9-71c5-4fee-81f4-64a7558bb192.gif)6061名前付きパラメーターにも型がつきます。61## 速いだけじゃない6263Honoは速いけど、速いだけではありません。6465### Write Less, do more6667ビルトイン・ミドルウェアが「**_Write Less, do more_**」を実現します。68たくさんのミドルウェアを1からコードを書くことなく、使えます。69例えば、以下のミドルウェアがあります。7071- [Basic認証](https://github.com/yusukebe/hono/tree/master/src/middleware/basic-auth/)72- [Cookieパース/シリアライゼーション](https://github.com/yusukebe/hono/tree/master/src/middleware/cookie/)73- [CORS](https://github.com/yusukebe/hono/tree/master/src/middleware/cors/)74- [ETag](https://github.com/yusukebe/hono/tree/master/src/middleware/etag/)75- [GraphQLサーバー](https://github.com/yusukebe/hono/tree/master/src/middleware/graphql-server/)76- [ロガー](https://github.com/yusukebe/hono/tree/master/src/middleware/logger/)77- [Mustacheを使ったテンプレート](https://github.com/yusukebe/hono/tree/master/src/middleware/mustache/) (Cloudflare Workersのみ)78- [JSON pretty](https://github.com/yusukebe/hono/tree/master/src/middleware/pretty-json/)79- [静的ファイルのサーブ](https://github.com/yusukebe/hono/tree/master/src/middleware/serve-static/) (Cloudflare Workersのみ)8081たったこれだけのコードでロガーとCORSミドルウェアを使うことができます。8283```js84import { Hono } from 'hono'85import { cors } from 'hono/cors'86import { logger } from 'hono/logger'8788const app = new Hono()89app.use('*', cors()).use(logger())90```9192### Developer Experience9394そして、Honoは優れた「**_Developer Experience_**」を提供します。`Context` オブジェクトのおかげで、Request/Responseへのアクセスが簡単です。なにより、HonoはTypeScriptで書かれています。そう、Honoは「**_型_**」を持っているのです!9596例えば、名前付きパラメーターにもリテラル型がつきます。9798![Demo](https://user-images.githubusercontent.com/10682/154179671-9e491597-6778-44ac-a8e6-4483d7ad5393.png)99100## インストール101
12 unmodified lines
114## メソッド115116`Hono`のインスタンスには以下のメソッドがあります。11783- app.**HTTP_METHOD**(path, handler)84- app.**all**(path, handler)118- app.**HTTP_METHOD**(\[path,\] handler)119- app.**all**(\[path,\] handler)120- app.**route**(path)86- app.**use**(path, middleware)121- app.**use**(\[path,\] middleware)122- app.**notFound**(handler)123- app.**onError**(err, handler)124- app.**fire**()125- app.**fetch**(request, env, event)
35 unmodified lines
161 ...162})163```164165### チェインされたルート166167```js168app169 .get('/endpoint', (c) => {170 return c.text('GET /endpoint')171 })172 .post((c) => {173 return c.text('POST /endpoint')174 })175 .delete((c) => {176 return c.text('DELETE /endpoint')177 })178```179180### ネストされたルート181182```js183const book = app.route('/book')
40 unmodified lines
224const app = new Hono()225226app.use('*', poweredBy())227app.use('*', logger())228// もしくはこのようにも書けます。229// app.use('*', poweredBy()).use(logger())230231app.use(232 '/auth/*',233 basicAuth({234 username: 'hono',
356 unmodified lines
modified:src/middleware/cors/README.md+19 added-20 removed
modified:README.md+42 added-10 removed
18 unmodified lines
19[![npm type definitions](https://img.shields.io/npm/types/hono)](https://www.npmjs.com/package/hono)20[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/yusukebe/hono)](https://github.com/yusukebe/hono/pulse)21[![GitHub last commit](https://img.shields.io/github/last-commit/yusukebe/hono)](https://github.com/yusukebe/hono/commits/master)2223Hono - _**[炎] means flame🔥 in Japanese**_ - is small, simple, and ultrafast web framework for Cloudflare Workers and Fastly Compute@Edge.23Hono - _**[炎] means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework for Cloudflare Workers and Service Worker based serverless such as Fastly Compute@Edge.2425```js26import { Hono } from 'hono'27const app = new Hono()
8 unmodified lines
36- **Ultrafast** - the router does not use linear loops.37- **Zero-dependencies** - using only Service Worker and Web standard API.38- **Middleware** - built-in middleware and ability to extend with your own middleware.39- **TypeScript** - first-class TypeScript support.40- **Optimized** - for Cloudflare Workers.40- **Optimized** - for Cloudflare Workers and Fastly Compute@Edge.4142## Benchmark4344**Hono is fastest**, compared to other routers for Cloudflare Workers.
12 unmodified lines
57A demonstration to create an application for Cloudflare Workers with Hono.5859![Demo](https://user-images.githubusercontent.com/10682/151973526-342644f9-71c5-4fee-81f4-64a7558bb192.gif)6061Now, the named path parameter has types.61## Not only fast6263Hono is fast. But not only fast.6465### Write Less, do more6667Built-in middleware make _"**Write Less, do more**"_ in reality. You can use a lot of middleware without writing code from scratch. Below are examples.6869- [Basic Authentication](https://github.com/yusukebe/hono/tree/master/src/middleware/basic-auth/)70- [Cookie parsing / serializing](https://github.com/yusukebe/hono/tree/master/src/middleware/cookie/)71- [CORS](https://github.com/yusukebe/hono/tree/master/src/middleware/cors/)72- [ETag](https://github.com/yusukebe/hono/tree/master/src/middleware/etag/)73- [GraphQL Server](https://github.com/yusukebe/hono/tree/master/src/middleware/graphql-server/)74- [Logger](https://github.com/yusukebe/hono/tree/master/src/middleware/logger/)75- [Mustache template engine](https://github.com/yusukebe/hono/tree/master/src/middleware/mustache/) (Only for Cloudflare Workers)76- [JSON pretty printing](https://github.com/yusukebe/hono/tree/master/src/middleware/pretty-json/)77- [Serving static files](https://github.com/yusukebe/hono/tree/master/src/middleware/serve-static/) (Only for Cloudflare Workers)7879You can enable logger and CORS middleware with just this code.8081```js82import { Hono } from 'hono'83import { cors } from 'hono/cors'84import { logger } from 'hono/logger'8586const app = new Hono()87app.use('*', cors()).use(logger())88```8990### Developer Experience9192And Hono provides fine _"**Developer Experience**"_. Easy access to Request/Response thanks to the `Context` object.93Above all, Hono is written in TypeScript. So, Hono has _"**Types**"_!9495For example, the named path parameters will be literal types.9697![Demo](https://user-images.githubusercontent.com/10682/154179671-9e491597-6778-44ac-a8e6-4483d7ad5393.png)9899## Install100
12 unmodified lines
113## Methods114115An instance of `Hono` has these methods.11683- app.**HTTP_METHOD**(path, handler)84- app.**all**(path, handler)117- app.**HTTP_METHOD**(\[path,\] handler)118- app.**all**(\[path,\] handler)119- app.**route**(path)86- app.**use**(path, middleware)120- app.**use**(\[path,\] middleware)121- app.**notFound**(handler)122- app.**onError**(err, handler)123- app.**fire**()124- app.**fetch**(request, env, event)
415 unmodified lines
540```541542## Starter template543510You can start making your Cloudflare Workers application with [the starter template](https://github.com/yusukebe/hono-minimal). It is really minimal using TypeScript, esbuild, and Miniflare.544You can start making your Cloudflare Workers application with [the starter template](https://github.com/yusukebe/hono-minimal). It is really minimal using TypeScript, esbuild, Miniflare, and Jest.545546To generate a project skelton, run this command.547548```sh
13 unmodified lines
562- Router::Boom <https://github.com/tokuhirom/Router-Boom>563564## Contributing565532Contributions Welcome! You can contribute by the following way.566Contributions Welcome! You can contribute in the following ways.567568- Write or fix documents569- Write code of middleware570- Fix bugs571- Refactor the code572- etc.573540Let's make Hono together!541574## Contributors575576Thanks to [all contributors](https://github.com/yusukebe/hono/graphs/contributors)!577
7 unmodified lines