const path = require('path'); const express = require('express'); const protobufjs = require("protobufjs"); // create prisma db client const { PrismaClient } = require("@prisma/client"); const prisma = new PrismaClient(); // return big ints as string when using JSON.stringify BigInt.prototype.toJSON = function() { return this.toString(); } // load protobufs const root = new protobufjs.Root(); root.resolvePath = (origin, target) => path.join(__dirname, "protos", target); root.loadSync('meshtastic/mqtt.proto'); const HardwareModel = root.lookupEnum("HardwareModel"); const Role = root.lookupEnum("Config.DeviceConfig.Role"); const app = express(); // serve files inside the public folder from / app.use('/', express.static(path.join(__dirname, 'public'))); app.get('/', async (req, res) => { res.sendFile(path.join(__dirname, 'public/index.html')); }); app.get('/api', async (req, res) => { const links = [ { "path": "/api", "description": "This page", }, { "path": "/api/v1/nodes", "description": "Meshtastic nodes in JSON format.", }, ]; const html = links.map((link) => { return `