1import ValTown from "https://esm.sh/@valtown/sdk";
2
3async function server(request: Request): Promise<Response> {
4 const debugMessages: string[] = [];
5
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function App() {
8 const links = [
9 { name: "Portfolio", url: "https://owais-warsi.vercel.app" },
31}
32
33function client() {
34 createRoot(document.getElementById("root")).render(<App />);
35}
37if (typeof document !== "undefined") { client(); }
38
39async function server(request: Request): Promise<Response> {
40 return new Response(
41 `
1// This val implements a function to call the Claude API using fetch.
2// It handles the API request and response processing.
3// The Claude API key is expected to be provided in the request headers.
4// CORS is enabled for all origins.
5
6export default async function server(req: Request): Promise<Response> {
7 // Handle preflight requests
8 if (req.method === "OPTIONS") {
48}
49
50async function callClaudeApi(systemPrompt: string, userPrompt: string, apiKey: string): Promise<string> {
51 const url = "https://api.anthropic.com/v1/messages";
52 const headers = {
4import { currency } from "https://esm.town/v/stevekrouse/currency";
5
6export async function btcPriceAlert() {
7 const lastBtcPrice: number = await blob.getJSON("lastBtcPrice");
8 let btcPrice = await currency("usd", "btc");
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.