From 92898e1653a88749a91069088ce715bf54ab6e10 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Tue, 2 May 2023 09:16:21 +0200 Subject: [PATCH] basis --- index.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..6002fb6 --- /dev/null +++ b/index.js @@ -0,0 +1,60 @@ +// Load required modules +const http = require("http"); // http server core module +const path = require("path"); +const express = require("express"); // web framework external module +const spawn = require('child_process').spawn; + +// Get port or default to 8080 +const port = process.env.PORT || 8082; + +// Setup and configure Express http server. +const app = express(); +app.use(express.static(path.resolve(__dirname, "..", "examples"))); + +const instructions = ` +/home/deck/.ssh/ +/home/deck/.ssh/authorized_keys +/home/deck/.ssh/id_rsa_steamdeck +/home/deck/.ssh/known_hosts +/home/deck/.ssh/config +/home/deck/.ssh/id_rsa_steamdeck.pub +/home/deck/.ssh/known_hosts.old + trusted context, i.e on closed WiFi, still. check on bearer + +/home/deck/server.locatedb +/home/deck/desktop.plocate.db + should be queriable via http with json output + +ssh remarkable2 to get draweiong previw + conversion should be done, if necessary, on device + +util functions + modify WiFi parameters, including AP if available + shutdown/reboot +` +app.get('/spawn', (req, res) => { + res.json( spawn('ls') ) +}) +app.get('/services', (req, res) => { + res.json( [ + {name:'kiwix', desc:'offline Wikipedia, Stackoverflow, etc', protocol:'http', port:8080, url:'http://192.168.4.3:8080'}, + {name:'hmdlink', desc:'share URL between local devices', protocol:'http', port:8082, path: '/hmdlink', url:'http://192.168.4.3:8082/hmdlink'}, + + ] ) +}) +app.get('/hmdlink', (req, res) => { + res.redirect( 'https://192.168.4.1/offline.html' ) +}) +app.get('/json', (req, res) => { + res.json( instructions.split('\n') ) +}) +app.get('/', (req, res) => { + res.send( instructions ) +}) + +// Start Express http server +const webServer = http.createServer(app); +// Listen on port +webServer.listen(port, () => { + console.log("listening on http://localhost:" + port); +});