readmeValsmain.tsx1 match
2const data = await blob.getJSON("readme-vals.json");
34export default async function(req: Request): Promise<Response> {
5return Response.json(data, {
6headers: { "Content-Type": "application/json" },
prodigiousTanTurtlemain.tsx21 matches
3637// Main App component
38function App() {
39const [user, setUser] = useState(null);
408687// Home component
88function Home({ user }) {
89if (!user) {
90return <h2>Welcome! Please login or register to use the system.</h2>;
104105// Login component
106function Login({ setUser }) {
107const [email, setEmail] = useState('');
108const [password, setPassword] = useState('');
138139// Register component
140function Register() {
141const [email, setEmail] = useState('');
142const [password, setPassword] = useState('');
175176// Profile component
177function Profile({ user }) {
178const [name, setName] = useState(user.name || '');
179const [phone, setPhone] = useState(user.phone || '');
207208// Logout component
209function Logout({ setUser }) {
210const navigate = useNavigate();
211220221// Driver Dashboard component
222function DriverDashboard({ user }) {
223const [vehicles, setVehicles] = useState([]);
224const [transactions, setTransactions] = useState([]);
271272// Operator Dashboard component
273function OperatorDashboard({ user }) {
274const [tollBooths, setTollBooths] = useState([]);
275307308// Admin Dashboard component
309function AdminDashboard({ user }) {
310const [revenueReport, setRevenueReport] = useState(null);
311const [trafficAnalytics, setTrafficAnalytics] = useState(null);
355356// Client-side rendering
357function client() {
358createRoot(document.getElementById("root")).render(<App />);
359}
361362// Server-side code
363export default async function server(request: Request): Promise<Response> {
364const { pathname } = new URL(request.url);
365
391}
392393async function handleApiRequest(request: Request): Promise<Response> {
394const { pathname } = new URL(request.url);
395const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
467}
468469async function handleRegister(request: Request, sqlite, KEY, SCHEMA_VERSION) {
470if (request.method !== 'POST') {
471return new Response('Method Not Allowed', { status: 405 });
492}
493494async function handleLogin(request: Request, sqlite, KEY, SCHEMA_VERSION) {
495if (request.method !== 'POST') {
496return new Response('Method Not Allowed', { status: 405 });
520}
521522function generateJWT(user) {
523// This is a simplified JWT generation.
524// In a real application, use a proper JWT library and keep the secret secure.
529}
530531async function handleProfile(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
532if (request.method !== 'PUT') {
533return new Response('Method Not Allowed', { status: 405 });
564}
565566async function handleVehicles(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
567const token = request.headers.get('Authorization')?.split(' ')[1];
568if (!token) {
586}
587588async function handleTransactions(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
589const token = request.headers.get('Authorization')?.split(' ')[1];
590if (!token) {
610}
611612async function handleTollBooths(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
613const token = request.headers.get('Authorization')?.split(' ')[1];
614if (!token) {
637}
638639async function handleRevenueReport(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
640const token = request.headers.get('Authorization')?.split(' ')[1];
641if (!token) {
666}
667668async function handleTrafficAnalytics(request: Request, sqlite, KEY, SCHEMA_VERSION, jwtDecode) {
669const token = request.headers.get('Authorization')?.split(' ')[1];
670if (!token) {
usageAlertmain.tsx1 match
2import { email } from "https://esm.town/v/std/email?v=13";
34export function usageAlert(handler: (req: Request) => Promise<Response>) {
5const requestCounts: number[] = [];
6const LIMIT = 1000;
usageAlertREADME.md1 match
9import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert"
1011async function sampleHandler(req: Request): Promise<Response> {
12return new Response("Hello, World!");
13}
fastCoffeeLizardmain.tsx2 matches
4const secret = "cfbd87a697526bf25127f998fe6388684b80524be46062a1a79d6dd26b5a6b90";
56async function verifySignature(bodyText, receivedSignature) {
7const encoder = new TextEncoder();
8const keyData = encoder.encode(secret);
126127<script>
128async function fetchData() {
129try {
130const response = await fetch(window.location.href, { headers: { 'accept': 'application/json' } });
sqliteExplorerAppREADME.md1 match
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37
whoIsHiringmain.tsx3 matches
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
89function App() {
10const tabs = { "/": "Home", "/about": "About" };
11const [activeTab, setActiveTab] = useState("/");
362}
363364function ServerApp() {
365return (
366<html>
385}
386387export default async function(req: Request): Promise<Response> {
388const url = new URL(req.url);
389if (url.pathname === "/api/stories") {
diligentSapphireOrcamain.tsx5 matches
1export default async function(req: Request): Response {
2const url = new URL(req.url);
3
136const connectionStatus = document.querySelector("#connection-status");
137
138// Dropdown menu functionality
139const menuButton = document.getElementById('menuButton');
140const menuDropdown = document.getElementById('menuDropdown');
209});
210211function parseResponse(text) {
212const parts = [];
213let currentText = "";
256});
257
258document.getElementById("input").addEventListener("submit", async function(event) {
259event.preventDefault();
260const userMessage = event.target.message.value;
359
360document.querySelectorAll(".suggestion-button").forEach((button)=>{
361button.addEventListener("click", function() {
362const input = document.querySelector("input[name=\\"message\\"]");
363input.value = this.textContent;
wittyTurquoiseDovemain.tsx12 matches
12}
1314function QuickCommand({ label, onClick }: { label: string; onClick: () => void }) {
15return (
16<button className="quick-command" onClick={onClick}>
20}
2122function App() {
23const [prompt, setPrompt] = useState("hello llamapalooza");
24const [code, setCode] = useState("");
104label: "Mobile-First Layout",
105prompt:
106"Design a Mobile-First Layout that prioritizes mobile device usability and performance, ensuring that the design scales up effectively for larger screens while maintaining functionality and aesthetics on smaller devices.",
107},
108{
208}, []);
209210async function fetchSavedSnippets() {
211const response = await fetch("/snippets");
212const snippets = await response.json();
214}
215216async function handleSave() {
217if (!code) return;
218const response = await fetch("/snippets", {
226}
227228async function handleDelete(id: number) {
229const response = await fetch(`/snippets/${id}`, { method: "DELETE" });
230if (response.ok) {
233}
234235async function handleSubmit(e: React.FormEvent) {
236e.preventDefault();
237setLoading(true);
257}
258259function handleBack() {
260if (currentIndex > 0) {
261setCurrentIndex(currentIndex - 1);
264}
265266function handleForward() {
267if (currentIndex < history.length - 1) {
268setCurrentIndex(currentIndex + 1);
391}
392393function client() {
394createRoot(document.getElementById("root")!).render(<App />);
395}
399}
400401function extractCodeFromFence(text: string): string {
402const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
403return htmlMatch ? htmlMatch[1].trim() : text;
404}
405406export default async function server(req: Request): Response {
407const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
408const KEY = "wittyTurquoiseDove";
zwiftPortalScheduleREADME.md1 match
47import { email } from "https://esm.town/v/std/email";
4849export default async function sendZwiftPortalSchedule(interval: Interval) {
50console.log("Parsing Zwift portal road schedule...");
51