feat: liberacao de 10min para pagamento, status de acesso e SSID configuravel
build-image / build-push (push) Failing after 41s

This commit is contained in:
jfeng committed 2026-10-22 08:56:40 -03:00
1 parent 53cca4ecc8
commit de5c483dca
4 files changed
+58 -7

No files matched your search

+13 -1
View File
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
import config from './config.js';
import { initDb, getDb, saveDb, genCode } from './db.js';
import { initMp, createPixPayment, getPaymentStatus, cancelOrder, validCpf } from './mp.js';
import { createHotspotUser, allowPaymentAccess, revokePaymentAccess } from './ros.js';
import { createHotspotUser, allowPaymentAccess, revokePaymentAccess, paymentAccessStatus } from './ros.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const app = express();
@@ -71,6 +71,14 @@ app.post('/api/access/start', async (req, res) => {
}
});
app.get('/api/access/status/:mac', async (req, res) => {
try {
res.json(await paymentAccessStatus(req.params.mac));
} catch (e) {
res.status(500).json({ error: e.message });
}
});
// ===== Reconciliacao manual (caso o webhook falhe) =====
app.post('/api/reconcile', async (req, res) => {
const { orderId } = req.body || {};
@@ -81,6 +89,10 @@ app.post('/api/reconcile', async (req, res) => {
res.json({ status: payment.status, voucher: payment.voucher, orderId: payment.mpId });
});
app.get('/api/config', (req, res) => {
res.json({ ssid: config.ssidName, freeSeconds: config.freeAccessSeconds });
});
app.get('/api/plans', (req, res) => {
res.json(getDb().plans.filter((p) => p.active));
});