mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-07-27 11:58:56 +00:00
Improve domain creation: Allow optional provider ID.
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/752f28c8-2f6f-4065-8649-1fc8dea4498d.jpg
This commit is contained in:
+9
-1
@@ -190,7 +190,15 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
app.post("/api/domains", requireRole(["admin", "manager"]), async (req, res) => {
|
||||
try {
|
||||
const validatedData = insertDomainSchema.parse(req.body);
|
||||
// Create a custom validation schema for the API that makes providerId optional
|
||||
const domainSchema = z.object({
|
||||
name: z.string(),
|
||||
organizationId: z.string().uuid(),
|
||||
providerId: z.string().uuid().optional(),
|
||||
isActive: z.boolean().optional().default(true)
|
||||
});
|
||||
|
||||
const validatedData = domainSchema.parse(req.body);
|
||||
const domain = await storage.createDomain(validatedData);
|
||||
res.status(201).json(domain);
|
||||
} catch (error) {
|
||||
|
||||
+11
-6
@@ -191,12 +191,17 @@ export const insertOrganizationSchema = createInsertSchema(organizations).pick({
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
export const insertDomainSchema = createInsertSchema(domains).pick({
|
||||
name: true,
|
||||
organizationId: true,
|
||||
providerId: true,
|
||||
isActive: true,
|
||||
});
|
||||
export const insertDomainSchema = createInsertSchema(domains)
|
||||
.pick({
|
||||
name: true,
|
||||
organizationId: true,
|
||||
providerId: true,
|
||||
isActive: true,
|
||||
})
|
||||
.extend({
|
||||
// Override providerId to make it optional
|
||||
providerId: z.string().uuid().optional(),
|
||||
});
|
||||
|
||||
export const insertDnsRecordSchema = createInsertSchema(dnsRecords).pick({
|
||||
domainId: true,
|
||||
|
||||
Reference in New Issue
Block a user