5export const MESSAGES_TABLE = 'chat_messages';
6
7export async function runMigrations() {
8 // Create users table
9 await sqlite.execute(`
1# Real-Time Chat Application
2
3A fully functional real-time chat application built on Val Town.
4
5## Features
16โ โโโ database/
17โ โ โโโ migrations.ts # Schema definitions
18โ โ โโโ queries.ts # DB query functions
19โ โโโ index.ts # Main entry point with WebSocket and HTTP handlers
20โ โโโ README.md
1import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
2
3export default async function(req: Request) {
4 const url = new URL(req.url);
5 const path = url.pathname;
43 });
44
45 function handleSwipe() {
46 const swipeThreshold = 50;
47 if (touchEndX < touchStartX - swipeThreshold) {
54 }
55
56 // Function to navigate between slides
57 function navigateSlide(direction) {
58 // Remove active class from current slide
59 slides[currentSlide].classList.remove('active');
74 }
75
76 // Function to update slide indicator
77 function updateSlideIndicator() {
78 slideIndicator.textContent = `${currentSlide + 1} / ${totalSlides}`;
79 }
80
81 // Function to animate chart bars
82 function animateChartBars() {
83 const bars = document.querySelectorAll('.bar');
84 bars.forEach(bar => {
5 * This runs on a schedule (e.g., every 15 minutes)
6 */
7export default async function() {
8 console.log('Running transaction check at', new Date().toISOString());
9 await checkForNewTransactions();
13 * Post a message to Slack using incoming webhook
14 */
15async function postToSlack(message: any): Promise<void> {
16 if (!SLACK_WEBHOOK_URL) {
17 throw new Error('SLACK_WEBHOOK_URL environment variable is required');
35 * Format a single transaction for Slack notification
36 */
37function formatTransactionNotification(transaction: MercuryTransaction): any {
38 // Use our existing formatting function but modify for in-channel display
39 const formattedMessage = formatTransactions([transaction]);
40
50 * Store the last seen transaction ID for each account
51 */
52async function storeLastTransactionId(accountId: string, transactionId: string): Promise<void> {
53 const key = `mercury_last_tx_${accountId}`;
54 await blob.set(key, transactionId);
58 * Get the last seen transaction ID for an account
59 */
60async function getLastTransactionId(accountId: string): Promise<string | null> {
61 const key = `mercury_last_tx_${accountId}`;
62 try {
72 * This is used for polling approach
73 */
74export async function checkForNewTransactions(): Promise<void> {
75 try {
76 // Get all accounts
128 * This is used if Mercury supports webhooks
129 */
130export async function processWebhook(payload: any): Promise<void> {
131 try {
132 // The exact payload structure will depend on Mercury's webhook format
4 * Format currency amount for display
5 */
6export function formatCurrency(amount: number, currency: string = 'USD'): string {
7 return new Intl.NumberFormat('en-US', {
8 style: 'currency',
14 * Format date for display
15 */
16export function formatDate(dateString: string): string {
17 const date = new Date(dateString);
18 return date.toLocaleDateString('en-US', {
26 * Create a Slack message for account balances
27 */
28export function formatAccountBalances(accounts: MercuryAccount[]): SlackMessage {
29 const blocks: SlackMessageBlock[] = [
30 {
70 * Create a Slack message for transactions
71 */
72export function formatTransactions(
73 transactions: MercuryTransaction[],
74 accountName?: string
123 * Create an error message for Slack
124 */
125export function formatErrorMessage(error: string): SlackMessage {
126 return {
127 blocks: [
141 * Parse a Slack command text into command and arguments
142 */
143export function parseCommand(text: string): { command: string; args: string[] } {
144 const parts = text.trim().split(/\s+/);
145 const command = parts[0]?.toLowerCase() || 'help';
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function ProductPage({ onBuyNow }) {
6 return (
7 <div style={styles.container}>
124}
125
126function CheckoutPage({ onConfirmOrder }) {
127 const [formData, setFormData] = useState({
128 name: "",
225}
226
227function OrderConfirmation({ orderDetails }) {
228 return (
229 <div style={styles.container}>
252}
253
254function App() {
255 const [page, setPage] = useState("product");
256 const [orderDetails, setOrderDetails] = useState(null);
274}
275
276function client() {
277 createRoot(document.getElementById("root")).render(<App />);
278}
279if (typeof document !== "undefined") { client(); }
280
281export default async function server(request: Request): Promise<Response> {
282 return new Response(
283 `
1async function getVideoUrlFromM3U8(m3u8Url) {
2 try {
3 let response = await fetch(m3u8Url);
1# BlogSphere - A Fully Responsive Blog Website
2
3BlogSphere is a fully functional, responsive blog website built with HTML, CSS, and JavaScript. It provides a platform for writers and readers to connect, share ideas, and explore new perspectives.
4
5## Features
8- **Multiple Pages**: Home, Explore, Create Post, Profile, Post View, and Bookmarks
9- **Blog Post Creation**: Rich text editor with formatting options
10- **Social Interactions**: Like, comment, and follow functionality
11- **User Profiles**: View and edit user profiles
12- **Bookmarks**: Save posts to read later
461. Clone the repository
472. Open `index.html` in your browser
483. Explore the features and functionality
49
50## Browser Compatibility
59- User authentication and registration
60- Server-side storage with a backend API
61- Image upload functionality
62- Notifications system
63- Advanced analytics for authors
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.