From 59fded5cabac514c99a6a502b087725b556a44fc Mon Sep 17 00:00:00 2001 From: cracklesparkle Date: Fri, 20 Dec 2024 10:15:56 +0900 Subject: [PATCH] Temporary disable nodes (prisma) --- ems/src/api/nodes/index.ts | 106 ++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/ems/src/api/nodes/index.ts b/ems/src/api/nodes/index.ts index 73f796c..8cd5f67 100644 --- a/ems/src/api/nodes/index.ts +++ b/ems/src/api/nodes/index.ts @@ -3,70 +3,70 @@ import { query, validationResult } from 'express-validator'; import { PrismaClient } from '@prisma/client'; const router = express.Router() -const prisma = new PrismaClient() +//const prisma = new PrismaClient() -router.get('/all', async (req: Request, res: Response) => { - try { - const nodes = await prisma.nodes.findMany() +// router.get('/all', async (req: Request, res: Response) => { +// try { +// const nodes = await prisma.nodes.findMany() - res.json(nodes) - } catch (error) { - console.error('Error getting node:', error); - res.status(500).json({ error: 'Failed to get node' }); - } -}) +// res.json(nodes) +// } catch (error) { +// console.error('Error getting node:', error); +// res.status(500).json({ error: 'Failed to get node' }); +// } +// }) -router.get('/', query('id').isString().isUUID(), async (req: Request, res: Response) => { - try { - const result = validationResult(req) - if (!result.isEmpty()) { - return res.send({ errors: result.array() }) - } +// router.get('/', query('id').isString().isUUID(), async (req: Request, res: Response) => { +// try { +// const result = validationResult(req) +// if (!result.isEmpty()) { +// return res.send({ errors: result.array() }) +// } - const { id } = req.params +// const { id } = req.params - const node = await prisma.nodes.findFirst({ - where: { - id: id - } - }) +// const node = await prisma.nodes.findFirst({ +// where: { +// id: id +// } +// }) - res.json(node) +// res.json(node) - } catch (error) { - console.error('Error getting node:', error); - res.status(500).json({ error: 'Failed to get node' }); - } -}) +// } catch (error) { +// console.error('Error getting node:', error); +// res.status(500).json({ error: 'Failed to get node' }); +// } +// }) -router.post('/', async (req: Request, res: Response) => { - try { - const { coordinates, object_id, type } = req.body; +// router.post('/', async (req: Request, res: Response) => { +// try { +// const { coordinates, object_id, type } = req.body; - // Convert the incoming array of coordinates into the shape structure - const shape = coordinates.map((point: number[]) => ({ - object_id: object_id || null, - x: point[0], - y: point[1] - })); +// // Convert the incoming array of coordinates into the shape structure +// const shape = coordinates.map((point: number[]) => ({ +// object_id: object_id || null, +// x: point[0], +// y: point[1] +// })); - console.log(shape) +// console.log(shape) - // Create a new node in the database - const node = await prisma.nodes.create({ - data: { - object_id: object_id || null, // Nullable if object_id is not provided - shape_type: type, // You can adjust this dynamically - shape: shape, // Store the shape array as Json[] - label: 'Default' - } - }); +// // Create a new node in the database +// const node = await prisma.nodes.create({ +// data: { +// object_id: object_id || null, // Nullable if object_id is not provided +// shape_type: type, // You can adjust this dynamically +// shape: shape, // Store the shape array as Json[] +// label: 'Default' +// } +// }); - res.status(201).json(node); - } catch (error) { - console.error('Error creating node:', error); - res.status(500).json({ error: 'Failed to create node' }); - } -}) +// res.status(201).json(node); +// } catch (error) { +// console.error('Error creating node:', error); +// res.status(500).json({ error: 'Failed to create node' }); +// } +// }) export default router \ No newline at end of file