This commit is contained in:
parent
360e01ffb8
commit
2f9b72a041
14
apps/app.js
14
apps/app.js
|
@ -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 });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user