Convert Hugo articles to Embendding for Cloudflare Vectorize Store
The single.json
is a example to add JSON outptu for your theme.
Setup a new config ai.toml
to extend output
Name | Layer | Type | Description |
---|---|---|---|
app/models/visitor_pass.rb | Domain | Aggregate | Pass-related domain |
app/services/tracker_service.rb | Domain | Domain Service | Logic between door and visitor interaction |
app/controllers/passes_controller.rb | Application | Use Case | The user flow of "pass" a door |
import 'vendor/tinygo' | |
const go = new Go(); | |
go.importObject.env['main.defineClass'] = function(namePtr, nameLen, cPtr, cGcPtr, pPtr/*, pGcPtr*/) { | |
const mem = new DataView(go._inst.exports.memory.buffer) | |
const decoder = new TextDecoder("utf-8"); | |
const name = decoder.decode(new DataView(go._inst.exports.memory.buffer, namePtr, nameLen)); | |
const constructorID = mem.getUint32(cPtr, true) |
paginator = InfinitePaginator.new( | |
'https://jsonplaceholder.typicode.com/users/%<page>d' | |
) | |
pp paginator.take(12) | |
# => | |
# [{"id"=>1, "name"=>"Leanne Graham"}, | |
# {"id"=>2, "name"=>"Ervin Howell"}, | |
# {"id"=>3, "name"=>"Clementine Bauch"}, | |
# {"id"=>4, "name"=>"Patricia Lebsack"}, |
Under Domain-Driven Design, we are trying to "Model" the real world to the virtual world. However, it cannot clearly describe the context/interaction with the domain.
The raw data is a "number" or "string" and cannot explain the meaning in specifying the domain. Therefore we have to create a "value object" to assign the domain meaning and use "entity" to compose mapping a real-world object.
require 'dry-contaienr' | |
require 'dry-auto_inject' | |
# Singleton style container | |
class Container | |
extend Dry::Container::Mixin | |
namespace :repositories do | |
register(:games) { GameRepository.new } | |
register(:players) { PlayerRepository.new } |
# frozen_string_literal: true | |
require "singleton" | |
class Settings | |
include Singleton | |
class << self | |
delegate_missing_to :instance | |
end |
# API | |
class FakeResponse < Struct.new(:status, :code) | |
def success? | |
code == 200 | |
end | |
end | |
class FakeAPI | |
def call | |
FakeResponse.new('Success', 200) |
# frozen_string_literal: true | |
require 'delegate' | |
require 'json' | |
class Middleware < SimpleDelegator | |
end | |
class CacheMiddleware < Middleware | |
def initialize(object) |
In most case, the CloudFlare SLA is greater than our server. So, we can use it as a simple uptime checker.
index.js
to your CloudFlare Workers, and bind KV which you save the status.updater.rb
to your server, and setup cron job to run ithttps://your-worker.workers.dev/?node[]=name
to fetch node status