"feat: add EventItem, EventReview models with seed data and mock files, update User and Event schemas"
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# GUIDELINE
|
||||
|
||||
this is a helloworld api endpoint
|
||||
this is a demo to handle helloworld record
|
||||
- this is a helloworld api endpoint
|
||||
- this is a demo to handle helloworld record
|
||||
- use single file for single db table/collection only
|
||||
|
||||
## `route.ts`
|
||||
|
||||
|
39
03_source/cms_backend/src/app/api/helloworld/detail/route.ts
Normal file
39
03_source/cms_backend/src/app/api/helloworld/detail/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// src/app/api/helloworld/detail/route.ts
|
||||
//
|
||||
// PURPOSE:
|
||||
// Get single helloworld record detail
|
||||
//
|
||||
// RULES:
|
||||
// - For helloworld requests, return simple response
|
||||
//
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
import { STATUS, response, handleError } from 'src/utils/response';
|
||||
|
||||
import prisma from '../../../lib/prisma';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
**************************************
|
||||
* GET - Handle both helloworld and user details
|
||||
**************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest) {
|
||||
// Original user details functionality
|
||||
try {
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
// RULES: helloworldId must exist
|
||||
const helloworldId = searchParams.get('helloworldId');
|
||||
if (!helloworldId) return response({ message: 'helloworldId is required!' }, STATUS.BAD_REQUEST);
|
||||
|
||||
const helloworld = await prisma.userItem.findFirst({ where: { id: helloworldId } });
|
||||
|
||||
if (!helloworld) return response({ message: 'User not found!' }, STATUS.NOT_FOUND);
|
||||
|
||||
return response({ helloworld }, STATUS.OK);
|
||||
} catch (error) {
|
||||
return handleError('Product - Get details', error);
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
###
|
||||
|
||||
GET http://localhost:7272/api/helloworld/details?helloworldId=1165ce3a-29b8-4e1a-9148-1ae08d7e8e01
|
||||
|
@@ -6,6 +6,11 @@ import { listHelloworlds, deleteHelloworld, updateHelloworld, createNewHelloworl
|
||||
|
||||
// import prisma from '../../lib/prisma';
|
||||
|
||||
/**
|
||||
***************************************
|
||||
* GET - list all Helloworlds
|
||||
***************************************
|
||||
*/
|
||||
export async function GET(req: NextRequest, res: NextResponse) {
|
||||
try {
|
||||
const result = await listHelloworlds();
|
||||
|
Reference in New Issue
Block a user