UNPKG

elysia

Version:

Ergonomic Framework for Human

41 lines (40 loc) 1.94 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var handler_native_exports = {}; __export(handler_native_exports, { createNativeStaticHandler: () => createNativeStaticHandler }); module.exports = __toCommonJS(handler_native_exports); var import_index = require('./index.js'), import_handler = require('./handler.js'); const createNativeStaticHandler = (handle, hooks, set) => { if (typeof handle == "function" || handle instanceof Blob) return; if ((0, import_index.isHTMLBundle)(handle)) return () => handle; const response = (0, import_handler.mapResponse)( handle, set ?? { headers: {} } ); if (!hooks.parse?.length && !hooks.transform?.length && !hooks.beforeHandle?.length && !hooks.afterHandle?.length) return response instanceof Promise ? response.then((response2) => { if (response2) return response2.headers.has("content-type") || response2.headers.append("content-type", "text/plain"), response2.clone(); }) : (response.headers.has("content-type") || response.headers.append("content-type", "text/plain"), () => response.clone()); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createNativeStaticHandler });