Files
IPAM/src/modules/ports/ports.service.ts
Mathieu BOURBON fbb6138c28 first commit
2026-04-18 16:24:44 +02:00

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 } }),
};