Search

Results include substring matches and semantically similar vals. Learn more
maxm avatar
honoJSXExample
@maxm
@jsxImportSource npm:hono@3/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono@3/jsx */
export const honoExample = () => {
const jsx = <div>Test {1 + 1}</div>;
return new Response(jsx.toString(), {
headers: {
"Content-Type": "text/html",
stevekrouse avatar
testWebsite
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
export const testWebsite = (request: Request) => {
// convert to Response
return new Response(renderToString(
<html>
<head>
<title>Page Title</title>
</head>
<body>
<span style={{ color: "red" }}>H</span> <span style={{ color: "blue" }}>e</span>{" "}
stevekrouse avatar
upstashEx
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { Redis } from "npm:@upstash/redis";
const redis = new Redis({
url: Deno.env.get("upstashURL"),
token: Deno.env.get("upstashToken"),
const start = performance.now();
console.log(await redis.set("foo", new Date()));
console.log("set time: " + (performance.now() - start));
const start2 = performance.now();
console.log(await redis.get("foo"));
console.log("get time: " + (performance.now() - start2));
cool avatar
tanBoa
@cool
An interactive, runnable TypeScript val by cool
Script
import { createFetch } from "npm:ofetch";
const ofetch = createFetch({ fetch });
const ip = await ofetch("https://httpbun.com/ip.json");
console.log(ip);
console.log();
const ofetch = createFetch({ fetch: fetch_ });
const ip = await ofetch("https://httpbun.com/ip.json");
console.log(ip);
const wip = await ofetch("https://httpbun.com/ip.json");
console.log(wip);
janpaul123 avatar
valle_tmp_92279164241240222981465199368394
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP (deprecated)
const app = new Hono();
app.get("/", (c) => {
return c.html(`<!DOCTYPE html>
<html>
<head>
<title>Wordle Game</title>
<style>
body {
font-family: 'Comic Sans MS', cursive, sans-serif;
background: linear-gradient(45deg, #ff6ec4, #7873f5);
easrng avatar
valToModule
@easrng
An interactive, runnable TypeScript val by easrng
Express
export async function valToModule(req: express.Request, res: express.Response) {
try {
const { transpileVal } = await import(
"https://val2module.glitch.me/script.js?13"
const baseUrl = "https://" + req.get("host") + "/module/";
const [userHandle, valName] = req.path.split("/").slice(1).map((e) =>
decodeURIComponent(e)
).slice(-2);
res.type("js").send(
await transpileVal({
willthereader avatar
Bringing_My_OCD_Online
@willthereader
@jsxImportSource https://esm.sh/hono@latest/jsx
HTTP
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
export const Bringing_My_OCD_Online = (c: Context) => {
return c.html(
<html>
<head>
<title>Bringing My OCD Online</title>
<style
dangerouslySetInnerHTML={{
__html:
`:root{--slate1: hsl(200, 7%, 8.8%);--slate2: hsl(195, 7.1%, 11%);--slate3: hsl(197, 6.8%, 13.6%);--slate4: hsl
yawnxyz avatar
stringCodeRunner
@yawnxyz
Val.town somehow doesn't run multi-line code. Does work with "3+3" but not more complex stuff.
HTTP (deprecated)
Val.town somehow doesn't run multi-line code. Does work with "3+3" but not more complex stuff.
/** @jsx jsx */
const app = new Hono();
app.post("/eval", async (c) => {
const payload = await c.req.json();
console.log('evaling using:', Deno.env.get('valtown'))
const response = await fetchJSON('https://api.val.town/v1/eval', {
method: 'POST',
body: JSON.stringify(payload),
headers: {
maxm avatar
codemirrorTsBrowser
@maxm
codemirror-ts You can import this a val like this in browser to run codemirror-ts. Bundling done with esm.sh. Working demo: preview / source Run an editor like so: /** @jsxImportSource https://esm.sh/react */ import { renderToString } from "npm:react-dom/server"; export default async function(req: Request): Promise<Response> { return new Response( renderToString( <> <script type="module" src="https://esm.town/v/maxm/codemirrorTsBrowser" /> <form> <textarea id="editorSource" className="for-codemirror" name="editorSource"> {`let hasAnError: string = 10; function increment(num: number) { return num + 1; } increment('not a number');`} </textarea> <button id="submit" type="submit">Submit</button> </form> </>, ), { headers: { "content-type": "text/html" } }, ); }
Script
# codemirror-ts
You can import this a val like this in browser to run codemirror-ts. Bundling done with esm.sh.
Working demo: [preview](https://maxm-whitenewt.web.val.run/) / [source](https://www.val.town/v/maxm/whiteNewt)
Run an editor like so:
```tsx
/** @jsxImportSource https://esm.sh/react */
const ret = await build({
dependencies: {
"@codemirror/view": "^6",
"@codemirror/autocomplete": "^6",
stevekrouse avatar
someDom
@stevekrouse
@jsxImportSource https://esm.sh/preact
Script
/** @jsxImportSource https://esm.sh/preact */
import { render } from "npm:preact-render-to-string";
const x = 1;
export const someDom = render(<div>Test {x}</div>);
stevekrouse avatar
currency
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetch } from "https://esm.town/v/std/fetch";
function fetchJSON(url) {
return fetch(url).then(res => res.json());
export let currency = async (desired, base = "usd", amount = 1) => {
let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
else {
let { rates } = await fetchJSON("https://api.coingecko.com/api/v3/exchange_rates");
return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
cool avatar
rabbitstream
@cool
// Full .ts implimentation of rabbitstream.net
HTTP
// Full .ts implimentation of rabbitstream.net
// Author : cool-dev-guy@github.com (cool-dev-guy)
// About : A one-file easy-deploy .ts code(specifically made for deno). for quick deployments.
// Thanks to :
// - ciarands@github.com (ciarands) [for payload script to extract variables]
// - drbgln@github.com (drbgln) [for reference script fordecryption]
const app = new Hono();
app.get("/:provider/:id", async (c) => {
try {
const { provider, id } = c.req.param();
stevekrouse avatar
valleGetValsContextWindow
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function getValsContextWindow(model: any) {
const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
const API_URL = "https://api.val.town";
const sections = [
name: "Imports",
templates: [
name: "Import from NPM",
prompt: "Write a val that imports lodash and generates a range of numbers",
code: `import _ from "npm:lodash-es";
let numbers = _.range(10);
godot avatar
checkResy
@godot
An interactive, runnable TypeScript val by godot
Script
export let checkResy = (async () => {
const axios = await import("npm:axios");
const apiUrl = "https://staging-api.resy.com/3/auth/password";
const api_key = "VbWk7s3L4KiK5fzlO7JD3Q5EYolJI7n5";
const email = process.env.resyEmail;
const password = process.env.resyPassword;
const config = {
headers: {
Authorization: `ResyAPI api_key="${api_key}"`,
"Content-Type": "multipart/form-data",
simply_say_m avatar
fetchGiphy
@simply_say_m
An interactive, runnable TypeScript val by simply_say_m
Script
import process from "node:process";
export const fetchGiphy = (async (searchTerm) => {
const { GiphyFetch } = await import("npm:@giphy/js-fetch-api");
const gf = new GiphyFetch(process.env.giphyApiKey);
const { data: gifs } = await gf.search(searchTerm, { limit: 10 });
return gifs;