serve-static.js 715 B

12345678910111213141516171819202122
  1. // src/adapter/cloudflare-workers/serve-static.ts
  2. import { serveStatic as baseServeStatic } from "../../middleware/serve-static/index.js";
  3. import { getContentFromKVAsset } from "./utils.js";
  4. var serveStatic = (options) => {
  5. return async function serveStatic2(c, next) {
  6. const getContent = async (path) => {
  7. return getContentFromKVAsset(path, {
  8. manifest: options.manifest,
  9. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  10. // @ts-ignore
  11. namespace: options.namespace ? options.namespace : c.env ? c.env.__STATIC_CONTENT : void 0
  12. });
  13. };
  14. return baseServeStatic({
  15. ...options,
  16. getContent
  17. })(c, next);
  18. };
  19. };
  20. export {
  21. serveStatic
  22. };