Refactor database schema and storage to support customer management and improved security.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/71d83b03-af3d-433a-a517-e76255668e93.jpg
This commit is contained in:
alphaeusmote
2025-04-11 19:25:41 +00:00
parent 17c31c8183
commit fbea387dea
6 changed files with 1188 additions and 265 deletions
+12 -7
View File
@@ -11,14 +11,17 @@ import {
insertDnsRecordSchema,
insertProviderSchema,
insertApiTokenSchema,
insertOrganizationSchema,
insertCustomerSchema,
insertWebhookSchema,
insertDnsMetricSchema,
insertCustomRoleSchema,
insertCustomerUserAssignmentSchema,
insertDomainCredentialsSchema,
insertApiTokenCustomerAccessSchema,
recordTypes,
providerTypes,
customRoles,
memberTypes
systemRoles
} from "@shared/schema";
import { randomBytes } from "crypto";
import { getProviderForDomain } from './providers';
@@ -119,8 +122,8 @@ async function triggerDnsWebhooks(
const domain = await storage.getDomain(domainId);
if (!domain) return;
// Get webhooks for this organization
const webhooks = await storage.getWebhooksByOrganization(domain.organizationId);
// Get webhooks for this customer
const webhooks = await storage.getWebhooksByCustomer(domain.customerId);
// Filter webhooks that have subscribed to DNS events
const dnsWebhooks = webhooks.filter(webhook =>
@@ -153,9 +156,9 @@ async function triggerDnsWebhooks(
}
export async function registerRoutes(app: Express): Promise<Server> {
// Setup authentication routes
setupAuth(app);
// Create HTTP server
const httpServer = createServer(app);
// Add public IP endpoint for the frontend
app.get('/api/public-ip', async (req, res) => {
try {
@@ -174,6 +177,8 @@ export async function registerRoutes(app: Express): Promise<Server> {
res.status(500).json({ error: 'Failed to get public IP address' });
}
});
return httpServer;
// DNS Records routes
app.get("/api/dns-records", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {