feat: implement helloworld API with CRUD operations and test cases

This commit is contained in:
louiscklaw
2025-06-02 19:42:32 +08:00
parent 8b73b583cd
commit fc6ed533e2
6 changed files with 158 additions and 18 deletions

View File

@@ -0,0 +1,44 @@
// src/app/services/helloworld.service.ts
//
// REQ0047/T.B.A.
//
// PURPOSE:
// - helloworld example for handling helloworld Record
//
// RULES:
// - T.B.A.
//
import type { Helloworld } from '@prisma/client';
import prisma from '../lib/prisma';
type CreateHelloworld = {
hello: string;
};
type UpdateHelloworld = {
hello: string;
};
async function listHelloworlds(): Promise<Helloworld[]> {
return prisma.helloworld.findMany();
}
async function getHelloworld(helloworldId: number) {
return prisma.helloworld.findFirst({ where: { id: helloworldId } });
}
async function createNewHelloworld(createForm: CreateHelloworld) {
return prisma.helloworld.create({ data: createForm });
}
async function updateHelloworld(helloworldId: number, updateForm: UpdateHelloworld) {
return prisma.helloworld.update({ where: { id: helloworldId }, data: updateForm });
}
async function deleteHelloworld(helloworldId: number) {
return prisma.helloworld.delete({ where: { id: helloworldId } });
}
export { getHelloworld, listHelloworlds, updateHelloworld, deleteHelloworld, createNewHelloworld };