2
3// https://github.com/web-push-libs/web-push/blob/v3.4.4/README.md#using-vapid-key-for-applicationserverkey
4function urlBase64ToUint8Array(b64) {
5 const padding = "=".repeat((4 - (b64.length % 4)) % 4);
6 const base64 = (b64 + padding)
19
20// https://stackoverflow.com/a/56848917/9068081
21function getPrivKeyJWK({ pubKey, privKey }: { pubKey: string; privKey: string }) {
22 const pubKeyArray = urlBase64ToUint8Array(pubKey);
23 const privKeyArray = urlBase64ToUint8Array(privKey);
49};
50
51async function importVapidKeys(
52 exportedKeys: { pubKey: string; privKey: string },
53 { crypto = globalThis.crypto.subtle, extractable = false }: {
1import { OpenAI } from "https://esm.town/v/std/openai";
2export default async function(req: Request): Promise<Response> {
3 const openai = new OpenAI();
4 const stream = await openai.chat.completions.create({
15 `);
16
17export default async function(req: Request): Promise<Response> {
18 await db.query(`
19 UPDATE test
6);
7
8export async function uptimeCheck(url: string) {
9 let ok = true;
10 let reason: string;
31};
32
33async function main() {
34 try {
35 const jsonData = {
46}
47
48async function pinFileToIPFS() {
49 try {
50 const jsonData = {
2import { parseAuthorizationHeader } from "https://esm.town/v/pomdtr/parseAuthorizationHeader";
3
4export default async function(req: Request) {
5 const url = new URL(req.url);
6 const parts = url.pathname.slice(1).split("/");
1/**
2 * This application creates a CSV viewer using a Hono app that serves a client-side application.
3 * It allows users to upload a CSV file, view its contents in a table format, and provides basic sorting functionality.
4 *
5 * The approach:
6 * 1. Create a server-side Hono app to handle file uploads and serve the HTML, CSS, and JavaScript.
7 * 2. Implement client-side JavaScript to handle file reading, parsing CSV, and displaying the data in a table.
8 * 3. Add sorting functionality to allow users to sort the table by clicking on column headers.
9 *
10 * Libraries used:
16import { Hono } from 'npm:hono';
17
18function html() {
19 /*
20<!DOCTYPE html>
38}
39
40function css() {
41 /*
42body {
99}
100
101function js() {
102 /*
103import Papa from 'https://esm.sh/papaparse@5.4.1';
111fileInput.addEventListener('change', handleFileUpload);
112
113function handleFileUpload(event) {
114 const file = event.target.files[0];
115 if (file) {
116 Papa.parse(file, {
117 complete: function(results) {
118 currentData = results.data;
119 currentHeaders = currentData[0];
124}
125
126function displayTable(data) {
127 if (data.length === 0) return;
128
152}
153
154function sortTable(column) {
155 const columnIndex = currentHeaders.indexOf(column);
156 if (columnIndex === -1) return;
2import { Hono } from 'npm:hono';
3
4function html() {
5 /*
6<!DOCTYPE html>
20}
21
22function css() {
23 /*
24body {
34}
35
36function js() {
37 /*
38import df from 'https://esm.sh/dateformat';
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",
13 abi,
14 address,
15 functionName: "information",
16});
17
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.