egorin: LoRa/LAN энергомониторинг — кит в /lora (прошивки+schema+provisioner+UI), бэкенд ingest от шлюза-концентратора + реестр устройств, фронт-раздел (карточки/реле/pending/шлюзы)
This commit is contained in:
@@ -8,11 +8,13 @@ import * as tenants from './tenants.js';
|
||||
import * as metrics from './metrics.js';
|
||||
import * as store from './store.js';
|
||||
import { seedDemo } from './demo.js';
|
||||
import * as lora from './lora.js';
|
||||
import { startMqtt } from './adapters/mqtt.js';
|
||||
import { startTraccar } from './adapters/traccar.js';
|
||||
import { startInflux } from './adapters/influx.js';
|
||||
|
||||
seedDemo();
|
||||
lora.seedLora();
|
||||
const live = { wirenboard: startMqtt(), traccar: startTraccar(), influx: startInflux() };
|
||||
|
||||
const app = express();
|
||||
@@ -121,6 +123,21 @@ app.get('/api/cabinet/links', auth, (req, res) => res.json(tenants.linksOf(req.u
|
||||
app.post('/api/cabinet/links', auth, (req, res) => res.json(tenants.addLink(req.user.id, req.body?.email)));
|
||||
app.delete('/api/cabinet/links/:email', auth, (req, res) => res.json(tenants.removeLink(req.user.id, decodeURIComponent(req.params.email))));
|
||||
|
||||
// --- LoRa/LAN энергомониторинг: приём от шлюза-концентратора + реестр устройств ---
|
||||
// Концентратор (LAN-шлюз) шлёт паспорт/телеметрию узлов сюда (открытый ingress железа).
|
||||
app.post('/api/lora/ingest', (req, res) => {
|
||||
const b = req.body || {};
|
||||
const items = Array.isArray(b) ? b : [b];
|
||||
for (const it of items) (it.t === 'info' ? lora.ingestInfo(it) : lora.ingestData(it));
|
||||
res.json({ ok: true, count: items.length });
|
||||
});
|
||||
app.get('/api/lora/devices', auth, (req, res) => res.json(can(req.user, 'energy', 'view') ? lora.listDevices({ status: req.query.status, project: req.query.project }) : []));
|
||||
app.get('/api/lora/gateways', auth, (req, res) => res.json(lora.listGateways()));
|
||||
app.get('/api/lora/relay-events', auth, (req, res) => res.json(lora.relayEvents()));
|
||||
app.post('/api/lora/devices/:id/approve', auth, (req, res) => res.json(lora.approve(req.params.id, req.body || {}) || { error: 'not found' }));
|
||||
app.post('/api/lora/devices/:id/disable', auth, (req, res) => res.json(lora.disable(req.params.id) || { error: 'not found' }));
|
||||
app.post('/api/lora/devices/:id/cmd', auth, (req, res) => res.json(lora.cmd(req.params.id, req.body || {}, 'ui') || { error: 'not found' }));
|
||||
|
||||
// --- Яндекс ID (OAuth) ---
|
||||
app.get('/api/auth/yandex/start', (_req, res) => {
|
||||
if (!config.yandex) return res.redirect('/?autherror=noyandex');
|
||||
|
||||
Reference in New Issue
Block a user