25 lines
688 B
TypeScript
25 lines
688 B
TypeScript
import { prisma } from '@/lib/db/prisma';
|
|
import {
|
|
createPortSchema,
|
|
updatePortSchema,
|
|
type CreatePortInput,
|
|
type UpdatePortInput,
|
|
} from './ports.schema';
|
|
|
|
export const portsService = {
|
|
listByHost: (hostId: string) =>
|
|
prisma.port.findMany({
|
|
where: { hostId },
|
|
include: { application: true },
|
|
orderBy: [{ protocol: 'asc' }, { number: 'asc' }],
|
|
}),
|
|
|
|
create: (input: CreatePortInput) =>
|
|
prisma.port.create({ data: createPortSchema.parse(input) }),
|
|
|
|
update: (id: string, input: UpdatePortInput) =>
|
|
prisma.port.update({ where: { id }, data: updatePortSchema.parse(input) }),
|
|
|
|
delete: (id: string) => prisma.port.delete({ where: { id } }),
|
|
};
|