0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 03:40:50 +01:00
hono/examples/blog
Yusuke Wada 2b570641a2
chore: update examples (#137)
* chore(example): update blog test

* `deploy` instead `publish`
2022-03-14 21:25:22 +09:00
..
src chore: update examples (#137) 2022-03-14 21:25:22 +09:00
.gitignore refactor: refactor something (#65) 2022-01-26 22:11:11 +09:00
jest.config.js chore: fix hono-example-blog (#100) 2022-02-10 09:59:02 +09:00
package.json chore: update examples (#137) 2022-03-14 21:25:22 +09:00
README.md chore: update examples (#137) 2022-03-14 21:25:22 +09:00
wrangler.example.toml chore: fix hono-example-blog (#100) 2022-02-10 09:59:02 +09:00

hono-example-blog

CRUD web API for Blog.

Features

  • Cloudflare Workers
  • KV
  • TypeScript
  • esbuild for build
  • miniflare for development
  • wrangler@beta for deploy
  • Test with Jest miniflare environment

Endpoints

  • GET /posts
  • POST /posts
  • GET /posts/:id
  • PUT /posts/:id
  • DELETE /posts/:id

Usage

Install dependencies:

$ yarn run install

Rename wrangler.example.toml to wrangler.toml:

$ mv wrangler.example.toml wrangler.toml

Setup KV:

$ wrangler kv:namespace create BLOG_EXAMPLE --preview

🌀 Creating namespace with title "hono-example-blog-BLOG_EXAMPLE_preview"
✨ Success!
Add the following to your configuration file in your kv_namespaces array:
{ binding = "BLOG_EXAMPLE", preview_id = "xxxxxxxxxx" }
$ wrangler kv:namespace create BLOG_EXAMPLE

🌀 Creating namespace with title "hono-example-blog-BLOG_EXAMPLE"
✨ Success!
Add the following to your configuration file in your kv_namespaces array:
{ binding = "BLOG_EXAMPLE", id = "yyyyyyyyyy" }

Copy KV id:

kv_namespaces = [
  { binding = "BLOG_EXAMPLE", preview_id = "xxxxxxxxxx", id = "yyyyyyyyy" }
]

Run a development server:

$ yarn dev

Publish:

$ yarn deploy