render targets in table, update targets

This commit is contained in:
Milo Schwartz 2024-11-12 23:59:47 -05:00
parent 93ea7e4620
commit cf3cf4d827
No known key found for this signature in database
16 changed files with 744 additions and 472 deletions

View file

@ -1,7 +1,7 @@
import { Request, Response, NextFunction } from "express";
import { z } from "zod";
import { db } from "@server/db";
import { resources, sites, targets } from "@server/db/schema";
import { resources, sites, Target, targets } from "@server/db/schema";
import response from "@server/utils/response";
import HttpCode from "@server/types/HttpCode";
import createHttpError from "http-errors";
@ -23,6 +23,8 @@ const createTargetSchema = z.object({
enabled: z.boolean().default(true),
});
export type CreateTargetResponse = Target;
export async function createTarget(
req: Request,
res: Response,
@ -126,7 +128,7 @@ export async function createTarget(
allowedIps: targetIps.flat(),
});
return response(res, {
return response<CreateTargetResponse>(res, {
data: newTarget[0],
success: true,
error: false,