Skip to content

Commit

Permalink
deploy/unstable-cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
imcotton committed Nov 22, 2024
1 parent 151c421 commit dc3ce07
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dev": "deno serve --port 3000 -N=esm.sh:443 -R=./db -W=./db --watch dev.ts"
},
"exports": {
"./deploy/unstable-cloudflare": "./deploy/unstable-cloudflare.ts",
"./deploy/deno": "./deploy/deno.ts",
"./helper": "./helper.ts",
"./app": "./app.tsx",
Expand Down
57 changes: 57 additions & 0 deletions deploy/unstable-cloudflare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { MiddlewareHandler } from 'hono/types';
import { contextStorage } from 'hono/context-storage';

import { create_app } from '../app.tsx';
import { gen_cloudflare_kv } from '../adapter/cloudflare-kv.ts';
import { gen_fnv1a_hash } from '../encoder/npm-pure.ts';





export function make ({

auth, kv_path, cache_name, ttl_in_ms, hash_seed, hash_enlarge,
signing_nav, signing_site,

}: {

auth?: MiddlewareHandler,
kv_path: string,
cache_name?: string,
ttl_in_ms?: number,
hash_seed?: string,
hash_enlarge?: boolean,
signing_nav?: boolean,
signing_site?: string,

}): Promise<Deno.ServeDefaultExport> {

const hash = gen_fnv1a_hash({
key: hash_seed,
large: hash_enlarge,
});

const storage = gen_cloudflare_kv(kv_path);

const init = contextStorage();

return create_app(hash, storage, {
init,
auth,
cache_name,
ttl_in_ms,
signing_nav,
signing_site,
});

}





const app: Deno.ServeDefaultExport = await make({ kv_path: 'MY_KV' });

export default app;

0 comments on commit dc3ce07

Please sign in to comment.