Skip to content

Commit

Permalink
API monitoredCameras
Browse files Browse the repository at this point in the history
Return list of lat/long of monitored "prod" cameras
  • Loading branch information
kinshuk committed Sep 9, 2022
1 parent 57a5c25 commit 4396b6f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server-src/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,18 @@ function initApis(config, app, db) {
});
});

/**
* Return list of monitored "production" cameras
*/
app.get('/api/monitoredCameras', async (req, res) => {
logger.info('GET monitoredCameras');
const prodTypesCheck = config.prodTypes.split(',').map(x => `type='${x}'`).join(' or ');
const sqlStr = `select latitude, longitude from cameras where locationid in
(select locationid from sources where dormant = 0 and (${prodTypesCheck}))`;
const dbRes = await db.query(sqlStr);
res.status(200).send(dbRes).end();
});

/**
* Get URL for image from given camera at given time.
* This code could work directly from the client, except browser CORS restrictions prevent fetching image archives
Expand Down

0 comments on commit 4396b6f

Please sign in to comment.