UNPKG

@npio/internals

Version:

A free visual website editor, powered with your own SolidJS components.

32 lines (25 loc) 721 B
import { demoEnabled } from "../.."; export const throwOnDemo = function () { if (!demoEnabled()) { return; } throw new Error("Unauthorized"); }; export const createGlobal = <T>(name: string) => { const memory = ((globalThis as any).globalConfigs = (globalThis as any).globalConfigs || {}); const getter = () => memory[name] as T; const setter = (v: () => T) => { if (memory[name] == null) { memory[name] = v(); } return memory[name]; }; return [getter, setter] as const; }; export const createXmlResponse = (content: string, type = "text/xml") => new Response('<?xml version="1.0" encoding="UTF-8"?>' + content, { headers: { "Content-Type": type, }, });