app.get('/cinemas', (req, res, next) => { repo.getCinemasByCity(req.query.cityId) .then(cinemas => { res.status(status.OK).json(cinemas) }) .catch(next) })
/** * @api {post} /api/v1/gateway/logout * @apiName Logout * @apiGroup Gateway */ async function logout(req, res) { await gladys.gateway.disconnect(); res.json({ success: true, }); }
/** * @api {delete} /api/v1/scene/:scene_selector delete * @apiName delete * @apiGroup Scene * */ async function destroy(req, res) { await gladys.scene.destroy(req.params.scene_selector); res.json({ success: true, }); }
/** * @api {get} /api/v1/system/upgrade/download/status * @apiName getContainers * @apiGroup System */ async function getUpgradeDownloadStatus(req, res) { res.json({ error: gladys.system.downloadUpgradeError, upgrade_finished: gladys.system.downloadUpgradeFinished, last_event: gladys.system.downloadUpgradeLastEvent, }); }
/** * @api {patch} /api/v1/me updateMySelf * @apiName updateMySelf * @apiGroup User * */ async function updateMySelf(req, res, next) { const newUser = await gladys.user.update(req.user.id, req.body); res.json(newUser); }
/** * @api {get} /api/v1/service/philips-hue/light Get lights * @apiName GetLights * @apiGroup PhilipsHue */ async function getLights(req, res) { const lights = await philipsHueLightHandler.getLights(); res.json(lights); }
/** * @api {get} /api/v1/service/mqtt/config Get MQTT configuration. * @apiName getConfiguration * @apiGroup Mqtt */ async function getConfiguration(req, res) { const configuration = await mqttManager.getConfiguration(); if (!configuration.useEmbeddedBroker && configuration.mqttPassword) { configuration.mqttPassword = DEFAULT.HIDDEN_PASSWORD; // Hide password from external broker } res.json(configuration); }
/** * @api {post} /api/v1/session/api_key createApiKey * @apiName createApiKey * @apiGroup Session * */ async function createApiKey(req, res) { const scope = req.body.scope || ['dashboard:write', 'dashboard:read']; const session = await gladys.session.createApiKey(req.user.id, scope); res.status(201).json(session); }
/** * @api {post} /api/v1/system/disk * @apiName getDiskUsage * @apiGroup System */ async function getDiskSpace(req, res) { const diskSpace = await gladys.system.getDiskSpace(); res.json(diskSpace); }
/** * @api {post} /api/v1/reset_password resetPassword * @apiName resetPassword * @apiGroup User * */ async function resetPassword(req, res) { const user = await gladys.user.updatePassword(req.user.id, req.body.password); await gladys.session.revoke(req.user.id, req.session_id); res.json(user); }
/** * @api {get} /api/v1/service/:service_name/device getDevicesByService * @apiName getDevicesByService * @apiGroup Device */ async function getDevicesByService(req, res) { const params = Object.assign({}, req.query, { service: req.params.service_name, }); const devices = await gladys.device.get(params); res.json(devices); }
/** * @api {post} /api/v1/system/shutdown * @apiName shutdownSystem * @apiGroup System */ async function shutdown(req, res) { res.json({ success: true, message: 'System will shutdown soon', }); gladys.system.shutdown(); }
/** * @api {get} /api/v1/message get * @apiName get * @apiGroup Message * */ async function get(req, res) { const messages = await gladys.message.get(req.user.id); res.json(messages); }
/** * @api {get} /api/v1/system/container * @apiName getContainers * @apiGroup System */ async function getContainers(req, res) { const containers = await gladys.system.getContainers(); res.json(containers); }