vectorsroutes.tsx5 matches
6const API_URL = "https://react-router-hono.val.run/api";
78function HTML ({ children }: {
9children: React.ReactNode;
10}) {
21}
2223function Layout () {
24return (
25<HTML>
47}
4849function Home () {
50const [count, setCount] = React.useState(0);
51return (
58}
5960function About () {
61const data = useLoaderData();
62
69}
7071async function catsLoader () {
72const data = await fetch(API_URL)
73.then(res => res.json());
Jobchatappqueries.ts4 matches
2021// Job posting queries
22export async function getAllJobs(): Promise<JobPosting[]> {
23const result = await sqlite.execute(
24`SELECT * FROM ${JOB_POSTINGS_TABLE} ORDER BY created_at DESC`
27}
2829export async function createJob(job: JobPosting): Promise<JobPosting> {
30const now = new Date().toISOString();
31const result = await sqlite.execute(
3940// Chat message queries
41export async function getChatMessages(limit = 50): Promise<ChatMessage[]> {
42const result = await sqlite.execute(
43`SELECT * FROM ${CHAT_MESSAGES_TABLE}
49}
5051export async function createChatMessage(message: ChatMessage): Promise<ChatMessage> {
52const now = new Date().toISOString();
53const result = await sqlite.execute(
Jobchatappmigrations.ts1 match
8* Initialize database tables
9*/
10export async function initDatabase() {
11// Create job postings table
12await sqlite.execute(`
1import { client } from "../hono.ts";
23export async function loader() {
4try {
5console.log("Number loader running");
2122/* ── helper: pull one page synchronously ── */
23async function fetchPage(offset: number) {
24const query = `
25SELECT
5960/* ── main: iterate pages & upsert ── */
61export default async function refreshUsage() {
62let total = 0;
63
untitled-3473todo-list.ts6 matches
56// Initialize with empty todo list if none exists
7async function initializeTodoList() {
8try {
9const existingList = await blob.get(TODO_LIST_KEY);
1920// Get the current todo list
21async function getTodoList(): Promise<string> {
22await initializeTodoList();
23const result = await blob.get(TODO_LIST_KEY);
2627// Add a new task to the todo list
28async function addTask(task: string): Promise<void> {
29if (!task.trim()) return;
30
3536// Toggle a task's completion status
37async function toggleTask(lineIndex: number): Promise<void> {
38const currentList = await getTodoList();
39const lines = currentList.split('\n');
5758// Generate HTML for the todo list
59function generateHtml(todoListMarkdown: string) {
60const lines = todoListMarkdown.split('\n');
61const taskLines = lines.map((line, index) => {
180}
181182export default async function(req: Request): Promise<Response> {
183const url = new URL(req.url);
184const action = url.searchParams.get('action');
untitled-3473README.md1 match
3233- Uses Val Town's blob storage to persist the todo list
34- Single HTTP Val handles all functionality
35- No external dependencies beyond Val Town's standard libraries
36- Responsive design with Twind (Tailwind CSS)
my-first-valqueries.ts14 matches
45// User queries
6export async function createUser(user: Omit<User, 'id' | 'createdAt'>): Promise<User> {
7const createdAt = new Date().toISOString();
8const result = await sqlite.execute(
23}
2425export async function getUserById(id: number): Promise<User | null> {
26const result = await sqlite.execute(
27`SELECT * FROM ${TABLES.USERS} WHERE id = ?`,
46}
4748export async function getUserByUsername(username: string): Promise<User | null> {
49const result = await sqlite.execute(
50`SELECT * FROM ${TABLES.USERS} WHERE username = ?`,
7071// Glucose reading queries
72export async function createGlucoseReading(reading: Omit<GlucoseReading, 'id'>): Promise<GlucoseReading> {
73const result = await sqlite.execute(
74`INSERT INTO ${TABLES.GLUCOSE_READINGS} (
87}
8889export async function getGlucoseReadingsByUserId(userId: number): Promise<GlucoseReading[]> {
90const result = await sqlite.execute(
91`SELECT * FROM ${TABLES.GLUCOSE_READINGS} WHERE user_id = ? ORDER BY timestamp DESC`,
103}
104105export async function getGlucoseReadingsByDateRange(
106userId: number,
107startDate: string,
126127// Meal queries
128export async function createMeal(meal: Omit<Meal, 'id' | 'foods'>, foodItems: Omit<FoodItem, 'id' | 'mealId'>[]): Promise<Meal> {
129// Start a transaction
130await sqlite.execute('BEGIN TRANSACTION');
179}
180181export async function getMealsByUserId(userId: number): Promise<Meal[]> {
182// Get meals
183const mealsResult = await sqlite.execute(
226}
227228export async function getMealsByDateRange(
229userId: number,
230startDate: string,
280281// Recipe queries
282export async function getAllRecipes(): Promise<Recipe[]> {
283const recipesResult = await sqlite.execute(`SELECT * FROM ${TABLES.RECIPES}`);
284const recipes: Recipe[] = [];
325}
326327export async function getRecipeById(id: number): Promise<Recipe | null> {
328const recipeResult = await sqlite.execute(
329`SELECT * FROM ${TABLES.RECIPES} WHERE id = ?`,
374}
375376export async function searchRecipes(query: string): Promise<Recipe[]> {
377const recipesResult = await sqlite.execute(
378`SELECT * FROM ${TABLES.RECIPES}
425426// Herb and spice queries
427export async function getAllHerbsAndSpices(): Promise<HerbSpice[]> {
428const result = await sqlite.execute(`SELECT * FROM ${TABLES.HERBS_SPICES}`);
429
438}
439440export async function getHerbById(id: number): Promise<HerbSpice | null> {
441const result = await sqlite.execute(
442`SELECT * FROM ${TABLES.HERBS_SPICES} WHERE id = ?`,
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
23export default async function(req: Request): Promise<Response> {
4// Serve the HTML file
5const html = await readFile("/index.html", import.meta.url);
my-first-valschema.ts2 matches
1314// Initialize database schema
15export async function initializeDatabase() {
16// Users table
17await sqlite.execute(`
124125// Seed initial data for recipes and herbs/spices
126async function seedInitialData() {
127// Check if we already have herbs and spices data
128const herbsCount = await sqlite.execute(`SELECT COUNT(*) as count FROM ${TABLES.HERBS_SPICES}`);