[] version 의 queryParam 추가
All checks were successful
JJ_Back/pipeline/head This commit looks good

This commit is contained in:
김선규 2024-08-29 09:27:07 +09:00
parent 360e01ffb8
commit 2f9b72a041
2 changed files with 14 additions and 2 deletions

View File

@ -9,10 +9,22 @@ const router = express.Router();
router.get('/push', HandlePush); router.get('/push', HandlePush);
router.get('/version', async (req, res) => { router.get('/version', async (req, res) => {
const {os_type} = res.query;
try { try {
const connection = await createDatabaseConnection(dbConfig); 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(); await connection.end();
res.json(rows); res.json(rows);
} catch (err) { } catch (err) {
res.status(500).json({ error: err.message }); res.status(500).json({ error: err.message });

View File

@ -58,7 +58,7 @@ app.use((req, res, next) => {
}); });
app.use('/JJ', routes); app.use('/', routes);
app.listen(serverPort, () => { app.listen(serverPort, () => {
console.log(`Server running`); console.log(`Server running`);