0.0.5 • Published 7 months ago

d1-json v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

d1-json

JSON CRUD + Search Functions for Cloudflare D1

npm i d1-json
import { DB } from 'd1-json'

export default {
  fetch: (req, env, ctx) => {
    const db = DB(env)
    const timestamp = Date.now()
    const { hostname, pathname, search } = new URL(url)
    const { colo, city, country, postalCode } = req.cf
    const headers = JSON.fromEntries(req.headers)
    const ip = headers['cf-ip']
    const event = { timestamp, url, method, ip, headers, colo, city, country, postalCode }
    ctx.waitUntil(db.logs.insert(event))
    return Response.json(event)
  }
}
0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago