Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place

fix self

Changed files
+35 -8
hosting-service
src
src
lib
routes
+1 -1
hosting-service/src/lib/db.ts
··· 17 id: string; 18 domain: string; 19 did: string; 20 - rkey: string; 21 verified: boolean; 22 } 23
··· 17 id: string; 18 domain: string; 19 did: string; 20 + rkey: string | null; 21 verified: boolean; 22 } 23
+18 -3
hosting-service/src/server.ts
··· 296 return 'Custom domain not found or not verified'; 297 } 298 299 - const rkey = customDomain.rkey || 'self'; 300 if (!isValidRkey(rkey)) { 301 set.status = 500; 302 return 'Invalid site configuration'; ··· 321 return 'Subdomain not registered'; 322 } 323 324 - const rkey = domainInfo.rkey || 'self'; 325 if (!isValidRkey(rkey)) { 326 set.status = 500; 327 return 'Invalid site configuration'; ··· 343 return 'Custom domain not found or not verified'; 344 } 345 346 - const rkey = customDomain.rkey || 'self'; 347 if (!isValidRkey(rkey)) { 348 set.status = 500; 349 return 'Invalid site configuration';
··· 296 return 'Custom domain not found or not verified'; 297 } 298 299 + if (!customDomain.rkey) { 300 + set.status = 404; 301 + return 'Domain not mapped to a site'; 302 + } 303 + 304 + const rkey = customDomain.rkey; 305 if (!isValidRkey(rkey)) { 306 set.status = 500; 307 return 'Invalid site configuration'; ··· 326 return 'Subdomain not registered'; 327 } 328 329 + if (!domainInfo.rkey) { 330 + set.status = 404; 331 + return 'Domain not mapped to a site'; 332 + } 333 + 334 + const rkey = domainInfo.rkey; 335 if (!isValidRkey(rkey)) { 336 set.status = 500; 337 return 'Invalid site configuration'; ··· 353 return 'Custom domain not found or not verified'; 354 } 355 356 + if (!customDomain.rkey) { 357 + set.status = 404; 358 + return 'Domain not mapped to a site'; 359 + } 360 + 361 + const rkey = customDomain.rkey; 362 if (!isValidRkey(rkey)) { 363 set.status = 500; 364 return 'Invalid site configuration';
+15 -3
src/lib/db.ts
··· 77 id TEXT PRIMARY KEY, 78 domain TEXT UNIQUE NOT NULL, 79 did TEXT NOT NULL, 80 - rkey TEXT NOT NULL DEFAULT 'self', 81 verified BOOLEAN DEFAULT false, 82 last_verified_at BIGINT, 83 created_at BIGINT DEFAULT EXTRACT(EPOCH FROM NOW()) 84 ) 85 `; 86 87 // Sites table - cache of place.wisp.fs records from PDS 88 await db` ··· 462 return rows[0] ?? null; 463 }; 464 465 - export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string = 'self') => { 466 const domainLower = domain.toLowerCase(); 467 try { 468 await db` ··· 476 } 477 }; 478 479 - export const updateCustomDomainRkey = async (id: string, rkey: string) => { 480 const rows = await db` 481 UPDATE custom_domains 482 SET rkey = ${rkey}
··· 77 id TEXT PRIMARY KEY, 78 domain TEXT UNIQUE NOT NULL, 79 did TEXT NOT NULL, 80 + rkey TEXT, 81 verified BOOLEAN DEFAULT false, 82 last_verified_at BIGINT, 83 created_at BIGINT DEFAULT EXTRACT(EPOCH FROM NOW()) 84 ) 85 `; 86 + 87 + // Migrate existing tables to make rkey nullable and remove default 88 + try { 89 + await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP NOT NULL`; 90 + } catch (err) { 91 + // Column might already be nullable, ignore 92 + } 93 + try { 94 + await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP DEFAULT`; 95 + } catch (err) { 96 + // Default might already be removed, ignore 97 + } 98 99 // Sites table - cache of place.wisp.fs records from PDS 100 await db` ··· 474 return rows[0] ?? null; 475 }; 476 477 + export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string | null = null) => { 478 const domainLower = domain.toLowerCase(); 479 try { 480 await db` ··· 488 } 489 }; 490 491 + export const updateCustomDomainRkey = async (id: string, rkey: string | null) => { 492 const rows = await db` 493 UPDATE custom_domains 494 SET rkey = ${rkey}
+1 -1
src/routes/domain.ts
··· 336 } 337 338 // Update custom domain to point to this site 339 - await updateCustomDomainRkey(id, siteRkey || 'self'); 340 341 return { success: true }; 342 } catch (err) {
··· 336 } 337 338 // Update custom domain to point to this site 339 + await updateCustomDomainRkey(id, siteRkey); 340 341 return { success: true }; 342 } catch (err) {