Giter Site home page Giter Site logo

hono-sample's Introduction

Hono-Sample

Setting

Change directory .devcontainer

cd .devcontainer

Create docker network

docker network create hono-sample

Check docker network

docker network ls
NETWORK ID     NAME                       DRIVER    SCOPE
313607904df7   hono-sample                bridge    local

Check network details

docker network inspect hono-sample
"Containers": {
    "xxxxx": {
        "Name": "postgres",
        "IPv4Address": "xxx.xx.x.x/xx",
    }
}

DB host settings for .env

DB_USER=postgres
DB_PASSWORD=password
DB_HOST=xxx.xx.x.x  // Setting IPv4Address
DB_PORT=5432
DB_NAME=sample

Build and launch docker container

docker compose up -d

hono-sample container

docker exec -i -t hono-sample bash
bun install

Run

bun run dev

Access

http://localhost:3000
http://localhost:3000/picture
http://localhost:3000/users

postgres container

Connect postgres container

docker exec -i -t postgres bash

Connect Database

psql -U postgres -d sample

WebAPI

NASA Open API

VSCode Extensions

Thunder Client

hono-sample's People

Contributors

superneko160 avatar

Watchers

 avatar

hono-sample's Issues

/parse 空白除去の処理を分割

/parseにおいて、読み込んだコンテンツの空白の除去を行っているが、分割して関数化可能である。

// /parse
app.get('/parse', async (c) => {
  // ファイルを読み込む
  let filedata = await readFile('./resources/html/index.html', 'utf8')

  // 以下の処理がなくても動作はするが、countElements関数内で余分な処理が走る
  // 改行、タブを除去
  filedata = filedata.replace(/\r?\n|\r|\t/g, '').trim()
  // タグ内以外の空白を除去
  filedata = filedata.replace(/>\s+</g, '><')

  const root = parse(filedata)
  const data = getElements(root)

  return c.json({ message: "ok", data: data })
})

分割した関数はutilsディレクトリに設置するのが良いと思われる。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.