Skip to content

Latest commit

 

History

History
768 lines (567 loc) · 15.2 KB

slides.md

File metadata and controls

768 lines (567 loc) · 15.2 KB
theme title class highlighter drawings transition mdc
bricks
Hono with database on browser playground
text-center
shiki
persist
slide-left
true

The Hacks in the Hanabi.REST playground.

How to develop a Workers Like execution environment in the browser.

Press Space for next page

layout: items cols: 3

Members

::items::

yutakobayasi

inaridiy

moons14

Yuta Kobayashi

Inaridiy

Moons14

yutakobayashidev

inaridiy

moons14

15yo, I like programming, languages, music and space.

18yo, engineer playing at LLM SFC24, seccmp23 inaridiy.eth

fake full-stack engineer seccamp 23


About Hanabi.rest

Build a REST API from prompt and screenshots with LLM.

  • 🏗️ Prompt to REST - Build a REST API from prompt and screenshots with LLM.
  • 🧪 Browser Playground - Test and Develop APIs in the browser.
  • 🚀 One Click Deploy - Deploy APIs to Cloudflare Workers with a one click.
  • 🎨 Local Build - Clone API in your PC by CLI.
Hanabi.rest

Tech Stack Overview

graph TD
    subgraph "Vercel"
        subgraph "フロントエンド"
            A[NextJS AppRouter]
            B[Jotai]
            C[Shadcn/UI]
        end
    end

    subgraph "Cloudflare"
        subgraph "バックエンド"
            subgraph "メインバックエンド"
                E[HonoJS]
                G[Cloudflare Workers]
                F[Drizzle ORM]
            end

            subgraph "生成用Durable Object"
                J[Durable Object]
                O[API生成ロジック]
            end

            subgraph "ストレージ"
                H[D1 SQLiteデータベース]
                I[R2 オブジェクトストレージ]
            end
        end
    end

    subgraph "外部サービス"
        N[Claude Haiku LLM]
        K[Clerk]
    end

    subgraph "開発・デプロイ"
        L[pnpm workspace]
        M[Github Actions]
    end

    A --> B
    A --> C
    G -->|ホスト| E
    E -->|ORM| F
    F -->|接続| H
    G -->|API生成時に呼び出し| J
    J -->|実行| O
    G -->|データ保存| I
    G -->|LLM呼び出し| N
    J -->|LLM呼び出し| N
    K --> A
    K --> E
    L --> A
    L --> E
    M --> Vercel
    M --> Cloudflare

    classDef environment fill:#f0f0f0,stroke:#333,stroke-width:4px;
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef durable fill:#ffb,stroke:#333,stroke-width:2px;
    classDef storage fill:#bff,stroke:#333,stroke-width:2px;
    classDef external fill:#fdb,stroke:#333,stroke-width:2px;
    classDef devops fill:#fbb,stroke:#333,stroke-width:2px;

    class Vercel,Cloudflare environment;
    class A,B,C frontend;
    class E,F,G backend;
    class J,O durable;
    class H,I storage;
    class N,K external;
    class L,M devops;
Loading

Genereated by Claude3.5


layout: cover

Demo

Hanabi.rest

layout: section

Today's Topic

::right::

Hanabi's Playground

Hanabi.rest


layout: section

Today's Topic

::right::

Execute Hono with D1 in the browser

How to run Hono with D1 in your browser

Build with external packages

Use esbuild to bundle with external packages into a single file

Typescript Editor

Bundle the npm package type definitions into a single file and insert it into the editor


Hono is Just a Function


Binding the database to Hono in the browser

Binding sqlite-wasm adjusted for D1 to Hono.

import { atom } from "jotai";
import { Hono } from "hono";

export const runtimeAtom = atom<null | Hono>(null);

export const fetchRuntimeAtom = atom(
  null,
  async (get, set, request: Request) => {
    const [app, db] = [get(runtimeAtom), get(dbAtom)];

    if (!(app && db)) throw new Error("No runtime found");

    const response = await app.fetch(request, {
      DB: new D1Wrapper(db),
    });

    set(runtimeResponseAtom, response);
    set(databaseVersionAtom, (v) => v + 1);

    return response;
  }
);

Get a list of endpoints as an array

You can get endpoints from the runtime using inspectRoutes used in the showRoutes() function from hono/dev

import { inspectRoutes } from "hono/dev";

const requestEndpointEffect = messaging.onMessageJotai(
  "requestEndpoint",
  async (get, _set, { data }) => {
    const runtime = get(runtimeAtom);
    if (!runtime) return;
    messaging.sendEvent("updateEndpointEvent", {
      endpoints: JSON.stringify(inspectRoutes(runtime as any)),
    });
  }
);

layout: image-right image: https://cover.sli.dev


Code

Use code snippets and get the highlighting directly, and even types hover!1

// TwoSlash enables TypeScript hover information
// and errors in markdown code blocks
// More at https://shiki.style/packages/twoslash

import { computed, ref } from "vue";

const count = ref(0);
const doubled = computed(() => count.value * 2);

doubled.value = 2;

<<< @/snippets/external.ts#snippet

<style> .footnotes-sep { @apply mt-5 opacity-10; } .footnotes { @apply text-sm opacity-75; } .footnote-backref { display: none; } </style>

level: 2

Shiki Magic Move

Powered by shiki-magic-move, Slidev supports animations across multiple code snippets.

Add multiple code blocks and wrap them with ````md magic-move (four backticks) to enable the magic move. For example:

```ts {*|2|*}
// step 1
const author = reactive({
  name: "John Doe",
  books: [
    "Vue 2 - Advanced Guide",
    "Vue 3 - Basic Guide",
    "Vue 4 - The Mystery",
  ],
});
```

```ts {*|1-2|3-4|3-4,8}
// step 2
export default {
  data() {
    return {
      author: {
        name: "John Doe",
        books: [
          "Vue 2 - Advanced Guide",
          "Vue 3 - Basic Guide",
          "Vue 4 - The Mystery",
        ],
      },
    };
  },
};
```

```ts
// step 3
export default {
  data: () => ({
    author: {
      name: "John Doe",
      books: [
        "Vue 2 - Advanced Guide",
        "Vue 3 - Basic Guide",
        "Vue 4 - The Mystery",
      ],
    },
  }),
};
```

Non-code blocks are ignored.

```vue
<!-- step 4 -->
<script setup>
const author = {
  name: "John Doe",
  books: [
    "Vue 2 - Advanced Guide",
    "Vue 3 - Basic Guide",
    "Vue 4 - The Mystery",
  ],
};
</script>
```

Components

You can use Vue components directly inside your slides.

We have provided a few built-in components like <Tweet/> and <Youtube/> that you can use directly. And adding your custom components is also super easy.

<Counter :count="10" />

Check out the guides for more.

<Tweet id="1390115482657726468" />

class: px-20

Themes

Slidev comes with powerful theming support. Themes can provide styles, layouts, components, or even configurations for tools. Switching between themes by just one edit in your frontmatter:

---
theme: default
---
---
theme: seriph
---

Read more about How to use a theme and check out the Awesome Themes Gallery.


Clicks Animations

You can add v-click to elements to add a click animation.

This shows up when you click the slide:

<div v-click>This shows up when you click the slide.</div>

The v-mark directive also allows you to add inline marks , powered by Rough Notation:

<span v-mark.underline.orange>inline markers</span>

Motions

Motion animations are powered by @vueuse/motion, triggered by v-motion directive.

<div
  v-motion
  :initial="{ x: -80 }"
  :enter="{ x: 0 }"
  :click-3="{ x: 80 }"
  :leave="{ x: 1000 }"
>
  Slidev
</div>
Slidev
<script setup lang="ts"> const final = { x: 0, y: 0, rotate: 0, scale: 1, transition: { type: 'spring', damping: 10, stiffness: 20, mass: 2 } } </script>

LaTeX

LaTeX is supported out-of-box powered by KaTeX.


Inline $\sqrt{3x-1}+(1+x)^2$

Block

$$ {1|3|all} \begin{array}{c}

\nabla \times \vec{\mathbf{B}} -, \frac1c, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \

\nabla \times \vec{\mathbf{E}}, +, \frac1c, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \

\nabla \cdot \vec{\mathbf{B}} & = 0

\end{array} $$


Learn more


Diagrams

You can create diagrams / graphs from textual descriptions, directly in your Markdown.

sequenceDiagram
    Alice->John: Hello John, how are you?
    Note over Alice,John: A typical interaction
Loading
graph TD
B[Text] --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
Loading
mindmap
  root((mindmap))
    Origins
      Long history
      ::icon(fa fa-book)
      Popularisation
        British popular psychology author Tony Buzan
    Research
      On effectiveness<br/>and features
      On Automatic creation
        Uses
            Creative techniques
            Strategic planning
            Argument mapping
    Tools
      Pen and paper
      Mermaid
Loading
@startuml

package "Some Group" {
  HTTP - [First Component]
  [Another Component]
}

node "Other Groups" {
  FTP - [Second Component]
  [First Component] --> FTP
}

cloud {
  [Example 1]
}

database "MySql" {
  folder "This is my folder" {
    [Folder 3]
  }
  frame "Foo" {
    [Frame 4]
  }
}

[Another Component] --> [Example 1]
[Example 1] --> [Folder 3]
[Folder 3] --> [Frame 4]

@enduml

Learn More


foo: bar dragPos: square: 691,33,167,_,-16


Draggable Elements

Double-click on the draggable elements to edit their positions.


Directive Usage
<img v-drag="'square'" src="https://sli.dev/logo.png">

Component Usage
<v-drag text-3xl>
  <carbon:arrow-up />
  Use the `v-drag` component to have a draggable container!
</v-drag>
Double-click me!


src: ./pages/multiple-entries.md hide: false



Monaco Editor

Slidev provides built-in Monaco Editor support.

Add {monaco} to the code block to turn it into an editor:

import { ref } from "vue";
import { emptyArray } from "./external";

const arr = ref(emptyArray(10));

Use {monaco-run} to create an editor that can execute the code directly in the slide:

import { version } from "vue";
import { emptyArray, sayHello } from "./external";

sayHello();
console.log(`vue ${version}`);
console.log(
  emptyArray<number>(10).reduce(
    (fib) => [...fib, fib.at(-1)! + fib.at(-2)!],
    [1, 1]
  )
);

layout: center class: text-center


Learn More

Documentations · GitHub · Showcases

Footnotes

  1. Learn More