1import { sqlite } from "https://esm.town/v/std/sqlite?v=5";
2
3export async function getHits() {
4 const [, , { rows: [[monthHits]] }, { rows: [[todayHits]] }] = await sqlite.batch([
5 "CREATE TABLE IF NOT EXISTS stevekrouse_com_hits (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
19}
20
21function CricketMatchCard() {
22 const [match] = useState<MatchDetails>({
23 tournament: 'SSCG Cricket Championship',
78}
79
80function App() {
81 return <CricketMatchCard />;
82}
83
84function client() {
85 createRoot(document.getElementById("root")).render(<App />);
86}
87if (typeof document !== "undefined") { client(); }
88
89export default async function server(request: Request): Promise<Response> {
90 return new Response(`
91 <html>
4import { MessageInput } from "./MessageInput.tsx";
5
6export function App(
7 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
8) {
41}
42
43function MessageList({ messages }: { messages: Message[] }) {
44 const displayedMessages = messages.slice(0, MESSAGE_LIMIT);
45 return (
50}
51
52function MessageItem({ message }) {
53 const formattedDate = new Date(message.timestamp).toLocaleString();
54
4const chunkSize = 1000;
5
6function parseCountParam(param: string) {
7 const parsedInt = parseInt(param);
8 if (!isNaN(parsedInt)) {
11}
12
13function createChunks(arr: any[]) {
14 let chunks = new Array();
15 for (let i = 0; i < arr.length; i += chunkSize) {
20}
21
22export default async function(req: Request): Promise<Response> {
23 const method = req.method;
24 const searchParams = new URL(req.url).searchParams;
5 */
6
7// Custom function to extract root domain
8function extractRootDomain(hostname: string): string {
9 // Split the hostname by dots
10 const parts = hostname.split(".");
17}
18
19export default async function server(request: Request): Promise<Response> {
20 // Allowed root hostnames configuration
21 const ALLOWED_HOSTNAMES = [
113}).toString().split("\n").slice(1).slice(0, -1).join("\n");
114
115async function getRows() {
116 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME}`);
117 const rows = result.rows.map(r => ({
126type Rows = Awaited<ReturnType<typeof getRows>>;
127
128app.get("/api", async function apiRoute(c) {
129 try {
130 return c.json(await getRows());
160});
161
162export default async function(req: Request): Promise<Response> {
163 await sqlite.execute(`
164 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
113}).toString().split("\n").slice(1).slice(0, -1).join("\n");
114
115async function getRows() {
116 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME}`);
117 const rows = result.rows.map(r => ({
126type Rows = Awaited<ReturnType<typeof getRows>>;
127
128app.get("/api", async function apiRoute(c) {
129 try {
130 return c.json(await getRows());
160});
161
162export default async function(req: Request): Promise<Response> {
163 await sqlite.execute(`
164 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
1export default async function server(request: Request): Promise<Response> {
2 // Check if the request method is GET
3 if (request.method !== "GET") {
2import { generateText } from "npm:ai";
3
4export default async function(req: Request): Promise<Response> {
5 if (req.method !== "POST") {
6 return Response.json({ message: "This val responds to POST requests." }, {
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",