Trending Vals
182
pwa
@pomdtr
Script
Add a pwa manifest to an http val (to open in as an app in iOS). See https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps for available fields. Usage import handler from "https://esm.town/v/maxm/staticChess";
import { pwa } from "https://esm.town/v/pomdtr/pwa";
export default pwa(handler, {
name: "Static Chess",
display: "standalone",
background_color: "#ffffff",
start_url: "/",
});
183
184
discordBot
@dglazkov
Script
A simple Discord Bot scaffolding, a slight rev on the one in the valtown guide . The discordBot function takes in an object where each key is a Discord command and the value is a function to handle the command. If the function returns a Promise , it will be handled as a deferred interaction with a followup message . Usage:
import { discordBot } from "https://esm.town/v/dglazkov/discordBot";
const echo = async (data) => {
await new Promise((r) => setTimeout(r, 5000));
return {
type: 4,
data: {
content: data.data.options[0].value,
},
};
};
export default discordBot({
ping: () => ({
type: 4,
data: {
content: `Pong! It is ${new Date()}`,
},
})
echo,
});
185
186
187
blobDirList
@neverstew
Script
List things in a blob directory Blobs can be organised using "directories" e.g. /animals
all-animals.txt
/dogs
sausage.txt
/cats
tom.txt is really only three files: /animals/all-animals.txt , /animals/dogs/sausage.txt and /animals/cats/tom.txt because directories don't really exist, we're just making longer filenames. When you want to list things only "in a directory" and none of the child "directories", you can use this val. import { blobDirList } from "https://esm.town/v/neverstew/blobDirList";
console.log(await blobDirList("/animals"));
// returns only "/animals/all-animals.txt"
188
190
blog
@postpostscript
HTTP (deprecated)
@postpostscript 's Val Town Blog Blog Posts: Ideas 2024-03-06 - Auth for Val Town 2024-03-09 - sqliteUniverse: Make SQLite Queries Against Multiple Endpoints in Deno (Val Town) (Part 1) 2024-03-09 - sqliteUniverse: Make SQLite Queries Against Multiple Endpoints in Deno (Val Town) (Part 2) Other Projects: 2024-02-25 - moduleHighlightValueLink: Link to a Val With a Value or Method's Code Highlighted 2024-02-28 - provideBlob: Return Response Quickly and Poll for the Expensive Parts 2024-03-02 - MyFooter: my footer component which shares random vals I've liked! 2024-03-16 - readmeManager: Edit Val Readmes With Persistent Drafts 2024-04-09 - reactiveStateBlob: wrap blob state in a proxy to autosave it on changes 2024-04-24 - lock: lock that releases when it leaves the execution context 2024-04-25 - fetchWorker: communicate with a worker over a fetch-like interface
191
192
194
195
resumeHandler
@iamseeley
HTTP (deprecated)
š hello, resume Creating, customizing, and hosting resumes can get complicated and time-consuming. This project aims to simplify that process and maybe make it a little more enjoyable. Follow the steps in your resumeConfig to get started . Happy job hunting! š¼āØ Thanks to @nbbaier for the great feedback and resumeValidator ! Also, big thanks to Thomas Davis for JSON Resume Standard!
196
197
198
201
html
@postpostscript
Script
html: create sanitized HTML using tagged templates Examples import { html } from "https://esm.town/v/postpostscript/html"
const unsafeInput = "<script>alert(1)</script>"
console.log(html`Value: ${unsafeInput}`)
// Value: <script>alert(1)</script> These can be combined -- HTML marked as safe (instance is RawHTML ) will be directly inserted: const scripts = html`<script>alert(1)</script>`
console.log(html`<head>
${scripts}
</head>`.toString())
// <head>
// <script>alert(1)</script>
// </head> To easily create HTTP Response outputs like @stevekrouse/html, use the htmlResponse utility: import { html, htmlResponse } from "https://esm.town/v/postpostscript/html";
export default function(req: Request) {
return htmlResponse`
Request URL: ${decodeURIComponent(req.url)}
`;
} Tests: @postpostscript/htmlTest
207
208
animatedReadmeSVG
@maxm
HTTP (deprecated)
Fancy animated SVGs in readmes, along with centering and image sizing. <div align="center"><img width=200 src="https://gpanders.com/img/DEC_VT100_terminal.jpg"></div> <p align="center">
<img src="https://maxm-animatedreadmesvg.web.val.run/comet.svg" />
</p> <p align="center">
<img src="https://maxm-animatedreadmesvg.web.val.run/custom text!" />
</p>
209
valshot
@vladimyr
HTTP (deprecated)
Val Shot Generate val source code screenshot using sourcecodeshots.com ā ļø This service is offered for personal use under a reasonable usage policy as stated here: https://sourcecodeshots.com/docs š£ Special thanks to @pomdtr for their help and contributions! Usage https://vladimyr-valshot.web.val.run/v/<author>/<val> Example https://vladimyr-valshot.web.val.run/v/vladimyr/valshot https://vladimyr-valshot.web.val.run/v/pomdtr/readme
210
fileInputUploadExample
@stevekrouse
HTTP (deprecated)
Example of an HTML Form with a File Upload, handled by the server The key step was setting enctype="multipart/form-data" on the <form> element. If you skip that step, you'll only get the file's name on the server. Limitation on files > 1mb Currently (as of 4/14/24) this only works for small files (< 1mb). For larger files you get an error: {"statusCode":413,"error":"Payload Too Large","message":"request entity too large"} . A workaround is to upload to another service client-side, send the URL from that service to your Val Town server, and then fetch the file server-side (helper: @stevekrouse/uploadTo0x0).