Search

Results include substring matches and semantically similar vals. Learn more
augustohp avatar
myApi
@augustohp
An interactive, runnable TypeScript val by augustohp
Script
export function myApi(name) {
return "hi " + name;
erics118 avatar
myApi
@erics118
An interactive, runnable TypeScript val by erics118
Script
export function myApi(name) {
return "hi " + name;
ejfox avatar
codeshowcase
@ejfox
open "https://ejfox-codeshowcase.web.val.run/?code=$(pbpaste | jq -sRr @uri)" to get a screenshottable code snippet
HTTP
* and allows shuffling through random, animated gradients.
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
const language = url.searchParams.get("language") || "javascript";
// Generate title using OpenAI
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
hljs.highlightAll();
function shuffleGradient() {
const t1 = Math.random();
const duration = 10000; // 10 seconds
function animate(timestamp) {
if (!start) start = timestamp;
x2764tech avatar
myApi
@x2764tech
An interactive, runnable TypeScript val by x2764tech
Script
export function myApi(name) {
return "hi " + name;
dhvanil avatar
val_7Pb2YNVSqH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_7Pb2YNVSqH(req) {
try {
// Execute the code directly and capture its result
nanyun avatar
myApi
@nanyun
An interactive, runnable TypeScript val by nanyun
HTTP
export function myApi(name) {
return "hi " + name;
danieledrisian avatar
myApi
@danieledrisian
An interactive, runnable TypeScript val by danieledrisian
Script
export function myApi(name) {
return "hi " + name;
sgq avatar
myApi
@sgq
An interactive, runnable TypeScript val by sgq
Script
export function myApi(name) {
return "hi world" + name;
szamuboy avatar
myApi
@szamuboy
An interactive, runnable TypeScript val by szamuboy
Script
export function myApi(name) {
return "hi " + name;
maxm avatar
valSession
@maxm
Val Session import { ValSession } from "https://esm.town/v/maxm/valSession"; // Generate a token from your valtown api key. const token = await ValSession.newSession(Deno.env.get("valtown")); // Other services can use it to authenticate const user = await ValSession.validate(token); Fork it, provide your own VT_SESSION_PRIVATE_KEY, and update the hardcoded public key. You can generate your own keys like so: import { crypto } from "https://deno.land/std@0.198.0/crypto/mod.ts"; // Generate a key pair for JWT signing and verification const { privateKey, publicKey } = await crypto.subtle.generateKey( { name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256", }, true, ["sign", "verify"], ); function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string { const lines = b64.match(/.{1,64}/g) || []; return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`; } const privateKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPrivateKey))), "PRIVATE KEY", ); const publicKeyPem = formatPEM( btoa(String.fromCharCode(...new Uint8Array(exportPublicKey))), "PUBLIC KEY", ); console.log(privateKeyPem, publicKeyPem);
HTTP
}, true, ["sign", "verify"],
function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
const lines = b64.match(/.{1,64}/g) || [];
-----END PUBLIC KEY-----
async function newSession(valTownToken: string) {
const privateKeyPem = `
throw error;
function validate(token: string) {
const decoded = jwt.verify(token, publicKeyPem, { algorithms: ["RS256"] }) as
mgsers avatar
myApi
@mgsers
An interactive, runnable TypeScript val by mgsers
Script
export function myApi(name) {
return "hi " + name;
patrickroumanoff avatar
status401
@patrickroumanoff
An interactive, runnable TypeScript val by patrickroumanoff
HTTP
export default async function(req: Request): Promise<Response> {
console.log(req.url);
if (req.headers.get("x-fd-healthprobe") == "1") {
treejanitor avatar
myApi
@treejanitor
An interactive, runnable TypeScript val by treejanitor
Script
export function myApi(name) {
return "hi " + name;
bernsno avatar
myApi
@bernsno
An interactive, runnable TypeScript val by bernsno
Script
export function myApi(name) {
return "hi " + name;
maxharper26 avatar
api_v1
@maxharper26
API setup to vercel database
HTTP
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
// Define the HTTP val function
export default async function fetchReturns(request: Request): Promise<Response> {
const databaseUrl = Deno.env.get("db_key_val_format");
if (!databaseUrl) {