ecstaticSalmonOrangutanmain.tsx7 matches
4import { marked } from "https://esm.sh/marked@9.0.0";
56function App() {
7const [messages, setMessages] = useState([
8{
9role: 'assistant',
10content: 'š Hello! I\'m an advanced AI assistant. I can help you with various tasks, answer questions, and even assist with code snippets!\n\nFeel free to explore my capabilities:\n\n```javascript\n// Try asking me about coding\nfunction exampleAIHelp() {\n return "AI is here to assist you!";\n}\n```\n\nš What would you like to know today?'
11}
12]);
49const renderMarkdown = (content) => {
50const markedContent = marked.parse(content, {
51highlight: function(code, lang) {
52return `<pre><code class="language-${lang || 'plaintext'}">${escapeHtml(code)}</code></pre>`;
53}
164}
165166function client() {
167createRoot(document.getElementById("root")).render(<App />);
168}
169if (typeof document !== "undefined") { client(); }
170171export default async function server(request: Request): Promise<Response> {
172if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
173const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
199];
200201// Advanced Fallback Generation Function
202function generateFallbackResponse(userInput: string): string {
203const keywords = userInput.toLowerCase().split(/\s+/);
204
3* with a better experience
4*/
5export function getOpenAPISpec() {
6return {
7openapi: "3.0.0",
8* @TODO - Need to implement `end_time` column for this query to work
9*/
10export function findTraces(db: DBType) {
11const REFERENCE QUERY = `
12SELECT trace_id, MAX(end_time) as end_time
loopyLettersmain.tsx5 matches
30};
3132function InstructionsModal({ onClose }) {
33return (
34<div className="modal-overlay">
50}
5152function GameOverModal({ elapsedTime, onPlayAgain }) {
53return (
54<div className="modal-overlay">
62}
6364function App() {
65const [wordlist, setWordlist] = useState([]);
66const [currentWordIndex, setCurrentWordIndex] = useState(0);
358}
359360function client() {
361createRoot(document.getElementById("root")).render(<App />);
362}
366}
367368export default async function server(request: Request): Promise<Response> {
369const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
370
blob_adminmain.tsx8 matches
13}
1415function Tooltip({ children, content }: TooltipProps) {
16const [isVisible, setIsVisible] = useState(false);
17const tooltipRef = useRef<HTMLDivElement>(null);
52}
5354function formatBytes(bytes: number, decimals = 2) {
55if (bytes === 0) return "0 Bytes";
56const k = 1024;
61}
6263function copyToClipboard(text: string) {
64navigator.clipboard.writeText(text).then(() => {
65console.log("Text copied to clipboard");
69}
7071function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72const [isOpen, setIsOpen] = useState(false);
73const menuRef = useRef(null);
7677useEffect(() => {
78function handleClickOutside(event) {
79if (menuRef.current && !menuRef.current.contains(event.target)) {
80event.stopPropagation();
158}
159160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161const [isLoading, setIsLoading] = useState(false);
162const decodedKey = decodeURIComponent(blob.key);
219}
220221function App({ initialEmail, initialProfile }) {
222const encodeKey = (key: string) => encodeURIComponent(key);
223const decodeKey = (key: string) => decodeURIComponent(key);
645}
646647function client() {
648const initialEmail = document.getElementById("root").getAttribute("data-email");
649const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));
redditAlertREADME.md2 matches
42- Value: Your SERP API key.
4344Without this key, the val will not function correctly.
4546---
58- Key: `mentionsDiscord`
59- Value: Your Discord webhook URL.
60Notifications will be sent using this function:
61```
62await discordWebhook({
redditAlertmain.tsx1 match
12const isProd = true;
1314export async function redditAlert({ lastRunAt }: Interval) {
15if (!SERP_API_KEY || !DISCORD_API_KEY) {
16console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
redditAlertREADME.md2 matches
42- Value: Your SERP API key.
4344Without this key, the val will not function correctly.
4546---
58- Key: `mentionsDiscord`
59- Value: Your Discord webhook URL.
60Notifications will be sent using this function:
61```
62await discordWebhook({
redditAlertmain.tsx1 match
12const isProd = true;
1314export async function redditAlert({ lastRunAt }: Interval) {
15if (!SERP_API_KEY || !DISCORD_API_KEY) {
16console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
reactHonoExampleREADME.md2 matches
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
1718However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
1920### `index.html`
26## CRUD API Routes
2728This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
2930## Errors