Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@

**Learning:** Using `on:keyup` for search input debouncing triggers unnecessary API calls on navigation keys (arrows, home, end) and misses changes from paste/cut. Svelte's reactive statements `$: debounce(value)` provide a robust, declarative way to trigger debouncing only when the value actually changes.
**Action:** Replace `on:keyup` handlers with reactive statements for input debouncing to improve performance and correctness.

## 2024-10-25 - Static configuration caching

**Learning:** In request handlers like `GET` in SvelteKit `+server.ts` files, deriving values from static configurations (like `metaNamesSdk.config.byoc.map`) on every request causes unnecessary overhead.
**Action:** Move static mapping logic out of the request handler and compute it once at module initialization, preferably storing it in a `Set` for O(1) lookup.
6 changes: 4 additions & 2 deletions src/routes/api/register/[name]/fees/[coin]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import type { BYOCSymbol } from '@metanames/sdk';
import { json } from '@sveltejs/kit';
import type { DomainFeesResponse } from 'src/lib/types';

// Precompute valid coins as a Set for O(1) lookups and avoid redundant map on every request
const validCoins = new Set(metaNamesSdk.config.byoc.map((byoc) => byoc.symbol.toString()));

export async function GET({ params: { name, coin } }) {
return handleError(async () => {
const validCoins = metaNamesSdk.config.byoc.map((byoc) => byoc.symbol.toString());
if (!validCoins.includes(coin)) return apiError('Invalid coin');
if (!validCoins.has(coin)) return apiError('Invalid coin');

const normalizedDomain = metaNamesSdk.domainRepository.domainValidator.normalize(name);
const domainFees = await metaNamesSdk.domainRepository.calculateMintFees(
Expand Down