From 2f9b72a0416d7d7dccbdd08fcf5a13fdbd99ac36 Mon Sep 17 00:00:00 2001 From: "seonkyu.kim" Date: Thu, 29 Aug 2024 09:27:07 +0900 Subject: [PATCH] =?UTF-8?q?[=E2=9C=A8]=20version=20=EC=9D=98=20queryParam?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app.js | 14 +++++++++++++- index.js | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/app.js b/apps/app.js index 959ee01..d1f4da4 100644 --- a/apps/app.js +++ b/apps/app.js @@ -9,10 +9,22 @@ const router = express.Router(); router.get('/push', HandlePush); router.get('/version', async (req, res) => { + const {os_type} = res.query; + try { const connection = await createDatabaseConnection(dbConfig); - const [rows] = await connection.query('SELECT * FROM version'); + + let query = 'SELECT * FROM version'; + const queryParams = []; + + if (os_type) { + query += 'WHERE os_type = ?'; + queryParams.push(os_type); + } + // const [rows] = await connection.query('SELECT * FROM version'); + const [rows] = await connection.query(query, queryParams); await connection.end(); + res.json(rows); } catch (err) { res.status(500).json({ error: err.message }); diff --git a/index.js b/index.js index ed90498..070a4a9 100755 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ app.use((req, res, next) => { }); -app.use('/JJ', routes); +app.use('/', routes); app.listen(serverPort, () => { console.log(`Server running`);