Search
![augustohp avatar](https://images.clerk.dev/oauth_github/img_2QtRpfj1EuiCLW6RVqTWCSxqBGc.png)
myApi
@augustohp
An interactive, runnable TypeScript val by augustohp
Script
export function myApi(name) {
return "hi " + name;
myApi
@erics118
An interactive, runnable TypeScript val by erics118
Script
export function myApi(name) {
return "hi " + name;
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](https://images.clerk.dev/oauth_github/img_2RSubletUXqE9B1nCpfL42S5ECa.png)
myApi
@x2764tech
An interactive, runnable TypeScript val by x2764tech
Script
export function myApi(name) {
return "hi " + name;
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
myApi
@nanyun
An interactive, runnable TypeScript val by nanyun
HTTP
export function myApi(name) {
return "hi " + name;
myApi
@danieledrisian
An interactive, runnable TypeScript val by danieledrisian
Script
export function myApi(name) {
return "hi " + name;
![sgq avatar](https://images.clerk.dev/oauth_github/img_2Rm4n46dd2wNLSRfsr8uNw38i31.png)
myApi
@sgq
An interactive, runnable TypeScript val by sgq
Script
export function myApi(name) {
return "hi world" + name;
![szamuboy avatar](https://images.clerk.dev/oauth_github/img_2QumMBc4QzalO95L2Z7xuK8z0ke.jpeg)
myApi
@szamuboy
An interactive, runnable TypeScript val by szamuboy
Script
export function myApi(name) {
return "hi " + name;
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](https://images.clerk.dev/oauth_github/img_2QwzMWyyHhYwcgxgL3VG67kfFWW.png)
myApi
@mgsers
An interactive, runnable TypeScript val by mgsers
Script
export function myApi(name) {
return "hi " + name;
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](https://secure.gravatar.com/avatar/8964e5a4f1ca2a1e49ec3515a9787ae8.jpg?s=200&d=identicon)
myApi
@treejanitor
An interactive, runnable TypeScript val by treejanitor
Script
export function myApi(name) {
return "hi " + name;
![bernsno avatar](https://images.clerk.dev/oauth_github/img_2RQri71jB15KURmNCMMC8g178Yc.jpeg)
myApi
@bernsno
An interactive, runnable TypeScript val by bernsno
Script
export function myApi(name) {
return "hi " + name;
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) {