Search

Results include substring matches and semantically similar vals. Learn more
postpostscript avatar
sqliteBuilder
@postpostscript
sqliteBuilder: Opinionated safe(r) query builder using tagged templates import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder"; const unsafeId = "1234 or TRUE" console.log(Statement` SELECT * FROM table WHERE id = ${unsafeId} ${Statement`AND otherCondition`} `) // StatementInstance { // sql: "\nSELECT *\nFROM table\nWHERE id = ?\nAND otherCondition\n", // args: [ "1234 or TRUE" ], // log: false // } const results = await Statement`SELECT ...`.execute() // [ { key: "value", anotherKey: "anotherValue" }, ... ] Or you can pass it directly to @std/sqlite.execute : import { sqlite } from "https://esm.town/v/std/sqlite" await sqlite.execute(Statement`Select ...`) You can combine multiple statements using Statement.prototype.combineWith : Statement`...`.combineWith(Statement`...`, " AND ") [ Statement`fieldA`, Statement`fieldB`, Statement`fieldC`, ].reduce((a, b) => a.combineWith(b, ", "))
Script
console.debug(Table.print(result));
return result;
export function Statement(
strings: TemplateStringsArray,
...replacements: (InValue | StatementInstance)[]
archer1121 avatar
goldTyrannosaurus
@archer1121
// Fetches a random joke.
Script
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
aazad avatar
linkinbio_25_2_5
@aazad
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function LinkInBio() {
// Brutalist design profile data
</div>
function client() {
createRoot(document.getElementById("root")).render(<LinkInBio />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
chrisputnam9 avatar
dailyThoughtPrompt
@chrisputnam9
Uses OpenAI to generate a thought-provoking statement and emails it to you at whatever interval you set. Clone/fork this, set the interval you want (eg. every 1 days) and hit run to test it. The email will send to your val town account email.
Cron
Uses OpenAI to generate a thought-provoking statement and emails it to you at whatever interval you set.
Clone/fork this, set the interval you want (eg. every 1 days) and hit run to test it.
// OpenAI provided by val town
import { OpenAI } from "https://esm.town/v/std/openai";
// Email provided by val town
import { email } from "https://esm.town/v/std/email";
export default async function(interval: Interval) {
const TOPICS = [
// Now ask the AI to invent something
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
dhvanil avatar
val_FDMJUyWsAy
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_FDMJUyWsAy(req) {
try {
// Execute the code directly and capture its result
iamseeley avatar
resumeHandler
@iamseeley
📄 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!
HTTP
import { helloResume } from 'https://esm.town/v/iamseeley/helloResume';
import { resumeConfig } from 'https://esm.town/v/iamseeley/resumeConfig';
export default async function resumeHandler(req: Request): Promise<Response> {
if (req.method === 'GET') {
try {
vladimyr avatar
sqlitePublic
@vladimyr
An interactive, runnable TypeScript val by vladimyr
HTTP
execute,
batch,
async function execute(statement: InStatement): Promise<ResultSet> {
return ky.post("execute", {
json: { statement },
prefixUrl: ENDPOINT,
}).json();
async function batch(statements: InStatement[]): Promise<ResultSet[]> {
return ky.post("batch", {
json: { statements },
jmelis avatar
myApi
@jmelis
An interactive, runnable TypeScript val by jmelis
Script
export function myApi(name) {
return "hi " + name;
frankysnow avatar
myApi
@frankysnow
An interactive, runnable TypeScript val by frankysnow
Script
export function myApi(name: Interval) {
console.email("hi " + name);
mojombo avatar
myApi
@mojombo
An interactive, runnable TypeScript val by mojombo
Script
export function myApi(name) {
return "hi " + name;
sean avatar
alphaVantageSymbolQuery
@sean
An interactive, runnable TypeScript val by sean
Script
...options
apikey: string,
function:
| "TIME_SERIES_INTRADAY"
| "TIME_SERIES_INTRADAY_EXTENDED"
dhvanil avatar
val_nh90QOYGHt
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_nh90QOYGHt(req) {
try {
// Execute the code directly and capture its result
ddpopbb3 avatar
myApi
@ddpopbb3
An interactive, runnable TypeScript val by ddpopbb3
HTTP
export function myApi(name) {
return "hi " + name;
hernquist avatar
myApi
@hernquist
An interactive, runnable TypeScript val by hernquist
Script
export function myApi(name) {
return "hi " + name;
pomdtr avatar
run
@pomdtr
Augmented run api This val is a wrapper on top of the val.town run api, improving it with additional features: basic auth content-type header in response based on url file extension Usage Custom Content-Type The content-type will be inferred from the filename using the mime-types library. If you use a .html extension, the response will be interpreted as text/html ~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html' HTTP/1.1 200 OK ... Content-Type: text/html; charset=utf-8 ... Hello, World! If you switch the extension to .txt , the content-type header switch to text/raw . ~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.txt' HTTP/1.1 200 OK ... Content-Type: text/plain; charset=utf-8 ... Hello, World! Passing arguments The request is proxyed to the run api, so you can pass args to your vals via query params or body. See the run api docs for more details. ~ $ curl -X POST -d '{"args": ["pomdtr"]}' 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html' ... < content-type: text/html; charset=utf-8 ... Hello, pomdtr! Basic Authentication Just add your val town token as the username: curl 'https://<val-token>@pomdtr-run.web.val.run/pomdtr/privateVal.txt'
HTTP
import { fetch } from "https://esm.town/v/std/fetch";
import { parseAuthorizationHeader } from "https://esm.town/v/pomdtr/parseAuthorizationHeader";
export async function run(req: Request) {
const url = new URL(req.url);
const [owner, filename] = url.pathname.slice(1).split("/");