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
···
id: string;
domain: string;
did: string;
-
rkey: string;
+
rkey: string | null;
verified: boolean;
}
+18 -3
hosting-service/src/server.ts
···
return 'Custom domain not found or not verified';
}
-
const rkey = customDomain.rkey || 'self';
+
if (!customDomain.rkey) {
+
set.status = 404;
+
return 'Domain not mapped to a site';
+
}
+
+
const rkey = customDomain.rkey;
if (!isValidRkey(rkey)) {
set.status = 500;
return 'Invalid site configuration';
···
return 'Subdomain not registered';
}
-
const rkey = domainInfo.rkey || 'self';
+
if (!domainInfo.rkey) {
+
set.status = 404;
+
return 'Domain not mapped to a site';
+
}
+
+
const rkey = domainInfo.rkey;
if (!isValidRkey(rkey)) {
set.status = 500;
return 'Invalid site configuration';
···
return 'Custom domain not found or not verified';
}
-
const rkey = customDomain.rkey || 'self';
+
if (!customDomain.rkey) {
+
set.status = 404;
+
return 'Domain not mapped to a site';
+
}
+
+
const rkey = customDomain.rkey;
if (!isValidRkey(rkey)) {
set.status = 500;
return 'Invalid site configuration';
+15 -3
src/lib/db.ts
···
id TEXT PRIMARY KEY,
domain TEXT UNIQUE NOT NULL,
did TEXT NOT NULL,
-
rkey TEXT NOT NULL DEFAULT 'self',
+
rkey TEXT,
verified BOOLEAN DEFAULT false,
last_verified_at BIGINT,
created_at BIGINT DEFAULT EXTRACT(EPOCH FROM NOW())
)
`;
+
+
// Migrate existing tables to make rkey nullable and remove default
+
try {
+
await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP NOT NULL`;
+
} catch (err) {
+
// Column might already be nullable, ignore
+
}
+
try {
+
await db`ALTER TABLE custom_domains ALTER COLUMN rkey DROP DEFAULT`;
+
} catch (err) {
+
// Default might already be removed, ignore
+
}
// Sites table - cache of place.wisp.fs records from PDS
await db`
···
return rows[0] ?? null;
};
-
export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string = 'self') => {
+
export const claimCustomDomain = async (did: string, domain: string, hash: string, rkey: string | null = null) => {
const domainLower = domain.toLowerCase();
try {
await db`
···
}
};
-
export const updateCustomDomainRkey = async (id: string, rkey: string) => {
+
export const updateCustomDomainRkey = async (id: string, rkey: string | null) => {
const rows = await db`
UPDATE custom_domains
SET rkey = ${rkey}
+1 -1
src/routes/domain.ts
···
}
// Update custom domain to point to this site
-
await updateCustomDomainRkey(id, siteRkey || 'self');
+
await updateCustomDomainRkey(id, siteRkey);
return { success: true };
} catch (err) {