From 4343a86e20d290cba29333e5b492aada98842bfe Mon Sep 17 00:00:00 2001 From: daneeskripter Date: Fri, 1 Nov 2024 16:08:40 +0100 Subject: [PATCH] /api/plans --- routes/api.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 routes/api.js diff --git a/routes/api.js b/routes/api.js new file mode 100644 index 0000000..550d4c6 --- /dev/null +++ b/routes/api.js @@ -0,0 +1,23 @@ +const express = require('express'); +const router = express.Router(); +const { Op } = require('sequelize'); +const Plan = require('../models/Plan'); + +router.get('/plans', async (req, res) => { + const { egg, node } = req.query; + + const plans = await Plan.findAll({ + where: { + eggs: { + [Op.like]: `%${egg}%` + }, + nodes: { + [Op.like]: `%${node}%` + } + } + }); + res.json(plans); + +}) + +module.exports = router; \ No newline at end of file