16}
17
18// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20 const url = `https://registry.npmjs.org/${packageName}`;
21 const response = await fetch(url);
22 if (!response.ok) {
23 throw new Error(`Failed to fetch package info for ${packageName}`);
24 }
25 return response.json();
70async function checkPackageLicenses(packageJsonUrl: string): Promise<{ licenses: PackageLicense[]; repoName: string }> {
71 try {
72 const response = await fetch(packageJsonUrl);
73 if (!response.ok) {
74 throw new Error(`Failed to fetch package.json from ${packageJsonUrl}`);
75 }
76 const packageJson: PackageJson = await response.json();
83 for (const [name, version] of Object.entries(dependencies)) {
84 try {
85 const packageInfo = await fetchPackageInfo(name);
86 const license = extractLicenseInfo(packageInfo);
87 const repoUrl = extractGitHubRepoUrl(packageInfo);
165});
166
167export default app.fetch;
16}
17
18// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20 const url = `https://registry.npmjs.org/${packageName}`;
21 const response = await fetch(url);
22 if (!response.ok) {
23 throw new Error(`Failed to fetch package info for ${packageName}`);
24 }
25 return response.json();
45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
49 throw new Error(`Failed to fetch releases from ${repo}`);
50 }
51 return response.json();
76async function checkNpmUpdates(packageJsonUrl: string): Promise<string> {
77 try {
78 const response = await fetch(packageJsonUrl);
79 if (!response.ok) {
80 throw new Error(`Failed to fetch package.json from ${packageJsonUrl}`);
81 }
82 const packageJson: PackageJson = await response.json();
89 for (const [name, version] of Object.entries(dependencies)) {
90 try {
91 const packageInfo = await fetchPackageInfo(name);
92 const repoUrl = extractGitHubRepoUrl(packageInfo);
93 if (!repoUrl) {
114 for (const [name, version] of Object.entries(devDependencies)) {
115 try {
116 const packageInfo = await fetchPackageInfo(name);
117 const repoUrl = extractGitHubRepoUrl(packageInfo);
118 if (!repoUrl) {
178});
179
180export default app.fetch;
90 prompt = document.getElementById("svgInput").value;
91 }
92 let resp = await fetch("/remix/" + id, { method: "POST", body: JSON.stringify({ prompt }) });
93 const reader = resp.body.getReader();
94 const decoder = new TextDecoder();
139 const buttonContainer = button.closest(".heart-button-container");
140 const buttonRect = button.getBoundingClientRect();
141 fetch(`/${button.attributes["data-id"].value}/heart`, { method: "POST" });
142 for (let i = 0; i < 10; i++) {
143 const heart = document.createElement("div");
516 return c.text("OK");
517});
518export default app.fetch;
1import { verify_discord_signature } from "https://esm.town/v/mattx/verify_discord_signature?v=8";
2import { fetch } from "https://esm.town/v/std/fetch";
3
4export type Snowflake = string;
95 (async () => {
96 const data = await response;
97 const update = await fetch(
98 `https://discord.com/api/v10/webhooks/${body.application_id}/${body.token}/messages/@original`,
99 {
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
4import { Context, Hono } from "npm:hono";
346app.get("/", homepage);
347
348export default modifyFetchHandler(async (req: Request): Promise<Response> => {
349 return app.fetch(req);
350}, {
351 val: { handle: "willthereader", name: "jumpchain_website" },
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=45";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;
37
38/**
39 * @param handler Fetch handler
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
52}
53
54export default modifyFetchHandler;
11Here are 2 different ways to add the "Code on Val Town" ribbon:
12
13### 1. Wrap your fetch handler (recommended)
14
15```ts
16import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=45";
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export default modifyFetchHandler(async (req: Request): Promise<Response> => {
20 return html(`<h2>Hello world!</h2>`);
21});
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
54- `modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }})`
55
58You can set the style parameter to a css string to customize the ribbon. Check out [github-fork-ribbon-css](https://github.com/simonwhitaker/github-fork-ribbon-css?tab=readme-ov-file#styling) to learn more about how to style the element.
59
60- `modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"})`
61- `modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"})`
62
64
65```ts
66modifyFetchHandler(handler, {style: `@media (max-width: 768px) {
67 .github-fork-ribbon {
68 display: none !important;