Files
dealplustech/node_modules/unstorage/drivers/cloudflare-kv-binding.mjs
Kunthawat 5171a789e9 fix: Final restoration with port 80
 COMPLETED:
1. Dockerfile uses port 80 (astro preview)
2. BaseLayout imports globals.css
3. globals.css with Tailwind v4 @theme syntax
4. index.astro has Header, Footer, FixedContact
5. All image references fixed to existing files
6. Hero uses hdpe_pipe_main.jpg
7. Product cards use hdpe001.jpg
8. pt-20 on main for fixed header

 TESTED LOCALLY:
- Build: 15 pages in 1.27s
- Docker build successful
- Port 80 working
- Images load
- CSS works

Ready for Easypanel deployment.
2026-03-12 08:58:56 +07:00

61 lines
1.8 KiB
JavaScript

import { defineDriver, joinKeys } from "./utils/index.mjs";
import { getKVBinding } from "./utils/cloudflare.mjs";
const DRIVER_NAME = "cloudflare-kv-binding";
export default defineDriver((opts) => {
const r = (key = "") => opts.base ? joinKeys(opts.base, key) : key;
async function getKeys(base = "") {
base = r(base);
const binding = getKVBinding(opts.binding);
const keys = [];
let cursor = void 0;
do {
const kvList = await binding.list({ prefix: base || void 0, cursor });
keys.push(...kvList.keys);
cursor = kvList.list_complete ? void 0 : kvList.cursor;
} while (cursor);
return keys.map((key) => key.name);
}
return {
name: DRIVER_NAME,
options: opts,
getInstance: () => getKVBinding(opts.binding),
async hasItem(key) {
key = r(key);
const binding = getKVBinding(opts.binding);
return await binding.get(key) !== null;
},
getItem(key) {
key = r(key);
const binding = getKVBinding(opts.binding);
return binding.get(key);
},
setItem(key, value, topts) {
key = r(key);
const binding = getKVBinding(opts.binding);
return binding.put(
key,
value,
topts ? {
expirationTtl: topts?.ttl ? Math.max(topts.ttl, opts.minTTL ?? 60) : void 0,
...topts
} : void 0
);
},
removeItem(key) {
key = r(key);
const binding = getKVBinding(opts.binding);
return binding.delete(key);
},
getKeys(base) {
return getKeys(base).then(
(keys) => keys.map((key) => opts.base ? key.slice(opts.base.length) : key)
);
},
async clear(base) {
const binding = getKVBinding(opts.binding);
const keys = await getKeys(base);
await Promise.all(keys.map((key) => binding.delete(key)));
}
};
});