first commit
This commit is contained in:
24
src/modules/ports/ports.service.ts
Normal file
24
src/modules/ports/ports.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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 } }),
|
||||
};
|
||||
Reference in New Issue
Block a user