133}
134135// Database Admin
136// https://libsqlstudio.com/client/s/valtown?p=d7880ed3-ad63-4258-a939-5a375f2c3ed8
137//
4243// Mock exchange rates to USD for testing.
44// In a real scenario, these would come from an external API or database.
45const mockRatesToUSD: Record<string, number> = {
46USD: 1,
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
getShowcaseValsREADME.md1 match
1Get vals that were created in the last month, augmented with all sorts of AI and screenshots, and shoved in a sqlite database for @stevekrouse/showcase.
159const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
160const KEY = "GameAwards2024PredictionGame";
161const SCHEMA_VERSION = 2; // Increment to reset database
162163await sqlite.execute(`
notionSiteRssmain.tsx22 matches
4// Retrieve Notion API token from environment variable
5const notionToken = Deno.env.get("NOTION_API_TOKEN");
6const databaseId = Deno.env.get("NOTION_DATABASE_ID");
78if (!notionToken || !databaseId) {
9return new Response("Notion API token or database ID not configured", { status: 500 });
10}
111314try {
15// Fetch database metadata
16const databaseMetadata = await notion.databases.retrieve({
17database_id: databaseId,
18});
1920// Fetch pages from the database
21const response = await notion.databases.query({
22database_id: databaseId,
23filter: {
24property: "Published", // Customize based on your database schema
25checkbox: {
26equals: true, // Only fetch published pages
29sorts: [
30{
31timestamp: "last_edited_time", // Customize based on your database schema
32direction: "descending",
33},
39const rssXml = generateRSSFeed(
40response.results,
41databaseMetadata,
42);
4353}
5455function generateRSSFeed(pages: any[], databaseMetadata: any): string {
56// Get database title from database metadata
57const databaseTitle = databaseMetadata.title[0]?.text.content
58|| `RSS Feed from Notion Database ${databaseMetadata.id}`;
5960// Get database description from database metadata
61const databaseDescription = databaseMetadata.description[0]?.text.content
62|| "";
636970const itemsXml = pages.map(page => {
71// Extract page metadata. Customize based on your database
72const title = page.properties.Name?.title[0]?.plain_text || "Untitled";
73const url = page.public_url;
75const lastEditedTime = new Date(page.last_edited_time).toUTCString();
7677// Extract tags, handling different Notion multi-select tag formats. Customize based on your database
78const tags = page.properties.Tags?.multi_select?.map(tag => tag.name) || [];
7993<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
94<channel>
95<title>${escapeXml(databaseTitle)}</title>
96<link>https://baolei.org</link>
97<description>${escapeXml(databaseDescription)}</description>
98<pubDate>${pubDate}</pubDate>
99<atom:link href="${import.meta.url}" rel="self" type="application/rss+xml" />
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
18}
1920async function initializeDatabase() {
21await sqlite.execute(`
22CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
255256export default async function(req: Request): Promise<Response> {
257await initializeDatabase();
258259const url = new URL(req.url);
glifInventorymain.tsx3 matches
8const DEFAULT_IMAGE_URL = "https://res.cloudinary.com/dzkwltgyd/image/upload/v1733165766/image-input-block-production/apjbm5nfc6yoevwnisxh.jpg";
910// Inventory Database Initialization
11async function initializeInventoryDatabase() {
12await sqlite.execute(`
13CREATE TABLE IF NOT EXISTS ${INVENTORY_TABLE} (
225// Main Handler
226export default async function(req: Request): Promise<Response> {
227await initializeInventoryDatabase();
228229const url = new URL(req.url);
notionDbCalendarFeedmain.tsx6 matches
5// Ensure Notion API key is set
6const notionApiKey = Deno.env.get("NOTION_API_TOKEN");
7const databaseId = Deno.env.get("NOTION_EVENTS_DATABASE_ID");
8const datePropertyName = "Date";
9const maxEventAgeInMonths = 18;
1011if (!notionApiKey || !databaseId) {
12return new Response("Missing Notion API credentials", { status: 500 });
13}
19someMonthsAgo.setMonth(someMonthsAgo.getMonth() - maxEventAgeInMonths);
2021// Fetch pages from Notion database
22const response = await notion.databases.query({
23database_id: databaseId,
24filter: {
25and: [
42// Transform Notion pages to iCal format
43const events = response.results.map(page => {
44// Adjust these property names to match your specific Notion database
45const dateProperty = page.properties[datePropertyName];
46