クイックスタート
CLI を入れ、認証し、Worker を公開します。
1. CLI を入れる
macOS、Linux、WSL に対応しています。インストーラは配置前にチェックサムを確認します。
$ curl -fsSL https://gitflare.net/install.sh | bash $ gitflare version
2. 認証
ダッシュボードで Workers:Edit と Zone:Read のトークンを作り、マシンごとに一度ログインします。
$ export GITFLARE_API_TOKEN=gf_live_... $ gitflare login --token "$GITFLARE_API_TOKEN"
3. 最小の Worker
src/index.js に保存します。KV を読み、短いキャッシュを付けて東京の colo が繰り返す GET を近くで返せるようにします。
export default {
async fetch(request, env) {
const url = new URL(request.url);
const user = await env.USERS.get(url.searchParams.get("id") || "anon");
return new Response(JSON.stringify({ ok: true, user }), {
headers: {
"content-type": "application/json",
"cache-control": "public, max-age=30",
"x-gitflare-colo": request.cf.colo,
},
});
},
};
4. KV を結びつけてデプロイ
$ gitflare kv namespace create USERS $ gitflare deploy --name hello --edge nearest --kv USERS=USERS
最初のリクエストは健全な最寄り拠点へ。日本では多くの場合 NRT-1 か HND-1 です。
5. ホスト名を向ける
$ gitflare hostname add hello.example.com --worker hello $ curl -sS https://hello.example.com/?id=42