16const lastRunAt = new Date(lastRun?.date);
17const content = lastRun?.content;
18const fetchURL = [
19"https://" + subdomain + ".val.run",
20lastRun?.path,
42// (note the x-blob-key header)
43if (content != "default" && diffInMinutes > .5) {
44const response = await fetch(fetchURL, {
45method: "POST",
46headers: {
Glancerhelpers.ts3 matches
28const origin = parsedUrl.origin;
2930// Fetch the HTML from the URL
31const response = await fetch(url);
32const html = await response.text();
336263// Verify the favicon exists
64const faviconResponse = await fetch(faviconUrl, { method: "HEAD" });
6566if (!faviconResponse.ok) {
practicalAquaWaspmain.tsx2 matches
1/** @jsxImportSource https://esm.sh/react */
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
34const exampleJSX = <p>Hello, World!</p>;
56console.log(
7await fetchText("https://esm.town/v/moe/HonoReactTailwindStarter@48-deptest/frontend/index.tsx", {
8headers: {
9"User-Agent": "", // can't include Deno, which on Val Town it would by default
practicalAquaWaspREADME.md1 match
5It doesn't do as much as other transpilers (such as esm.sh, such as rewriting `npm:` imports, etc). We may add that capability in the future. For now, if you want your npm imports to run in the browser, use `https://esm.sh/package` instead of `npm:package`.
67The below script demonstrates this transiplation behavior by fetching its own source code (`import.meta.url`) with the user agent of a browser. You can uncoment the line setting the browser agent if you want to see the difference in the output. Or you could just load this val's module URL in your browser to see the untranspiled TS.
89As of July 23, 2024, this is the code that determines when esm.town transpiles or not:
filterValsmain.tsx2 matches
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
23export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4const token = Deno.env.get("valtown");
5const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6headers: { Authorization: `Bearer ${token}` },
7});
filterValsmain.tsx2 matches
1import { fetchPaginatedData } from "https://esm.town/v/nbbaier/fetchPaginatedData";
2console.log('hi')
3export async function filterVals(id: string, filter: (value: any, index: number, array: any[]) => unknown) {
4const token = Deno.env.get("valtown");
5const res = await fetchPaginatedData(`https://api.val.town/v1/users/${id}/vals`, {
6headers: { Authorization: `Bearer ${token}` },
7});
valreadmegeneratormain.tsx1 match
4243try {
44const response = await fetch(`/generate-readme/${user}/${val}`);
4546if (!response.ok) {
valreadmegeneratorREADME.md2 matches
29302. **Generate:**
31- Click on 'Generate README' and watch as the application swiftly fetches and processes the Val code to create a Markdown README.
32333. **Copy and Share:**
42- **TailwindCSS:** For styling the application.
43- **Deno:** The server-side environment.
44- **ValTown SDK:** Integrated to fetch Val details.
45- **OpenAI GPT-4:** To generate natural language README content.
46- **JavaScript Modules (ESM):** For seamless module imports.
blob_adminmain.tsx1 match
195});
196197export default lastlogin((request: Request) => app.fetch(request));
blob_adminapp.tsx22 matches
231const [isDragging, setIsDragging] = useState(false);
232233const fetchBlobs = useCallback(async () => {
234setLoading(true);
235try {
236const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237const data = await response.json();
238setBlobs(data);
239} catch (error) {
240console.error("Error fetching blobs:", error);
241} finally {
242setLoading(false);
245246useEffect(() => {
247fetchBlobs();
248}, [fetchBlobs]);
249250const handleSearch = (e) => {
261setBlobContentLoading(true);
262try {
263const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264const content = await response.text();
265setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
266setEditContent(content);
267} catch (error) {
268console.error("Error fetching blob content:", error);
269} finally {
270setBlobContentLoading(false);
275const handleSave = async () => {
276try {
277await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278method: "PUT",
279body: editContent,
287const handleDelete = async (key) => {
288try {
289await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290setBlobs(blobs.filter(b => b.key !== key));
291if (selectedBlob && selectedBlob.key === key) {
304const key = `${searchPrefix}${file.name}`;
305formData.append("key", encodeKey(key));
306await fetch("/api/blob", { method: "POST", body: formData });
307const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308setBlobs([newBlob, ...blobs]);
312}
313}
314fetchBlobs();
315};
316326try {
327const fullKey = `${searchPrefix}${key}`;
328await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329method: "PUT",
330body: "",
341const handleDownload = async (key) => {
342try {
343const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344const blob = await response.blob();
345const url = window.URL.createObjectURL(blob);
360if (newKey && newKey !== oldKey) {
361try {
362const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363const content = await response.blob();
364await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365method: "PUT",
366body: content,
367});
368await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370if (selectedBlob && selectedBlob.key === oldKey) {
380const newKey = `__public/${key}`;
381try {
382const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383const content = await response.blob();
384await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385method: "PUT",
386body: content,
387});
388await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390if (selectedBlob && selectedBlob.key === key) {
399const newKey = key.slice(9); // Remove "__public/" prefix
400try {
401const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402const content = await response.blob();
403await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404method: "PUT",
405body: content,
406});
407await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409if (selectedBlob && selectedBlob.key === key) {