JokeGeneratormain.tsx2 matches
1import { email } from "https://esm.town/v/std/email?v=9";
23async function fetchRandomJoke() {
4const response = await fetch(
5"https://official-joke-api.appspot.com/random_joke",
8}
910export async function emailRandomJoke() {
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
11];
1213// URL validation function
14function isValidUrl(urlString: string): boolean {
15try {
16// Automatically prepend http:// if no protocol is specified
48}
4950// Simple HTML sanitization function
51function sanitizeHtml(html: string): string {
52// Basic HTML sanitization to prevent XSS
53return html
75}
7677export default async function server(request: Request): Promise<Response> {
78try {
79// Parse and validate URL
93}
9495function validateAndGetUrl(request: Request): string {
96const url = new URL(request.url);
97const targetUrl = url.searchParams.get('url');
115}
116117function renderInputPage(): string {
118const sourceUrl = import.meta.url.replace('esm.town', 'val.town');
119return `# URL to Markdown Converter 🔗📄
151}
152153async function fetchWithTimeout(url: string): Promise<{
154content: string;
155contentType: string;
188}
189190async function processResponse(
191{ content, contentType }: { content: string; contentType: string },
192url: string
214}
215216function createResponse({ content, status, headers = {} }: MarkdownResponse): Response {
217return new Response(content, {
218status,
225}
226227function handleError(error: Error): Response {
228const status = error instanceof FetchError ? error.status || 500 : 500;
229const message = error.message || 'An unexpected error occurred';
237}
238239async function convertHtmlToMarkdown(html: string): Promise<string> {
240// Sanitize HTML first
241const cleanHtml = sanitizeHtml(html);
256257// Process nodes recursively
258function processNode(node: Element): string {
259let result = '';
260307}
308309function convertJsonToMarkdown(json: any, depth: number = 0): string {
310const indent = ' '.repeat(depth);
311
sophisticatedGreenOxmdtort3 matches
5import { createRoot } from "https://esm.sh/react-dom/client";
67function App() {
8const [markdown, setMarkdown] = useState("");
9const [html, setHtml] = useState("");
146}
147148function client() {
149createRoot(document.getElementById("root")).render(<App />);
150}
154}
155156export default async function server(request: Request): Promise<Response> {
157return new Response(
158`
blogrender-markdown.ts1 match
1011// Process markdown content
12export async function processMarkdown(content: string): Promise<string> {
13const result = await unified()
14.use(remarkParse)
4import { ValCard, ValList } from "./components/Card.tsx";
56function App() {
7const [vals, setVals] = React.useState(null);
8const [loading, setLoading] = React.useState(true);
reverseProxymod.ts1 match
1export function newSingleHostReverseProxy(
2target: string,
3): (req: Request) => Promise<Response> {
accurateIvoryElkmain.tsx2 matches
1// Joke Generator Val
23// Async function to fetch joke and simulate sending an email
4async function jokeGeneratorVal() {
5try {
6// 1. Fetch a random joke