### Initialize an Express Application Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3_littlefire/NodeServer/node_modules/express/Readme.md Commands to install the generator, create a new project, install dependencies, and start the server. ```console $ npm install -g express-generator@4 ``` ```console $ express /tmp/foo && cd /tmp/foo ``` ```console $ npm install ``` ```console $ npm start ``` -------------------------------- ### Install on-finished Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/on-finished/README.md Install the package via npm. ```sh $ npm install on-finished ``` -------------------------------- ### Install ee-first Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ee-first/README.md Use npm to install the package in your project. ```sh $ npm install ee-first ``` -------------------------------- ### Generate and Start an Express App Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Commands to create a new application directory, install required dependencies, and launch the server. ```console $ express /tmp/foo && cd /tmp/foo ``` ```console $ npm install ``` ```console $ npm start ``` -------------------------------- ### Install serve-static Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/serve-static/README.md Use npm to install the package locally in your project. ```sh $ npm install serve-static ``` -------------------------------- ### Install utf-8-validate Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/utf-8-validate/README.md Command to install the package as an optional dependency. ```bash npm install utf-8-validate --save-optional ``` -------------------------------- ### Install gotrue-js Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/gotrue-js/README.md Install the library using npm. ```bash npm install --save @supabase/gotrue-js ``` -------------------------------- ### Install media-typer Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/media-typer/README.md Use npm to install the package in your project. ```sh $ npm install media-typer ``` -------------------------------- ### Install and Test Commands Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime/README.md Commands for installing the package and running tests. ```bash npm install mime ``` ```bash npm run test ``` -------------------------------- ### Install function-bind Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO/NodeServer/node_modules/function-bind/README.md Command to install the package via npm. ```bash npm install function-bind ``` -------------------------------- ### Install the methods package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/methods/README.md Use npm to install the package as a dependency in your project. ```bash $ npm install methods ``` -------------------------------- ### Install Negotiator Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/negotiator/README.md Use npm to install the package in your project. ```sh $ npm install negotiator ``` -------------------------------- ### Install content-type Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/content-type/README.md Use npm to install the package in your project. ```sh $ npm install content-type ``` -------------------------------- ### Clone and Run Express Examples Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Steps to download the official repository and execute specific example applications. ```console $ git clone git://github.com/expressjs/express.git --depth 1 $ cd express $ npm install ``` ```console $ node examples/content-negotiation ``` -------------------------------- ### Install proxy-addr Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/proxy-addr/README.md Install the module via npm. ```sh $ npm install proxy-addr ``` -------------------------------- ### Install node-gyp-build Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/node-gyp-build/README.md Install the package via npm. ```bash npm install node-gyp-build ``` -------------------------------- ### Install ext package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ext/README.md Use npm to install the library as a dependency in your project. ```bash npm install ext ``` -------------------------------- ### Install WebSocket library Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/websocket/README.md Use npm to install the package in your project root. ```bash $ npm install websocket ``` -------------------------------- ### Install storage-js Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Install the package via npm. ```bash npm install @supabase/storage-js ``` -------------------------------- ### Install Realtime JS Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/realtime-js/README.md Use npm to install the package in your project. ```bash npm install @supabase/realtime-js ``` -------------------------------- ### Install utils-merge Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/utils-merge/README.md Install the package via npm. ```bash $ npm install utils-merge ``` -------------------------------- ### Install cross-fetch Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/cross-fetch/README.md Install the package using npm. ```sh npm install --save cross-fetch ``` -------------------------------- ### Install the type library Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ext/node_modules/type/README.md Command to install the package via npm. ```bash npm install type ``` -------------------------------- ### Install the d package Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO/NodeServer/node_modules/d/README.md Command to install the package via npm. ```bash $ npm install d ``` -------------------------------- ### Install type-is Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/type-is/README.md Command to install the package via npm. ```sh $ npm install type-is ``` -------------------------------- ### Installation via NPM Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/object-inspect/readme.markdown Command to install the package using npm. ```bash npm install object-inspect ``` -------------------------------- ### Install depd Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/depd/Readme.md Install the module using npm. ```sh $ npm install depd ``` -------------------------------- ### Install has library Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/has/README.md Use npm to install the package as a dependency. ```sh npm install --save has ``` -------------------------------- ### Serve files using Express Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/serve-static/README.md Examples demonstrating basic Express integration, multiple directory roots, and path-specific settings. ```js var express = require('express') var serveStatic = require('serve-static') var app = express() app.use(serveStatic('public/ftp', { index: ['default.html', 'default.htm'] })) app.listen(3000) ``` ```js var express = require('express') var path = require('path') var serveStatic = require('serve-static') var app = express() app.use(serveStatic(path.join(__dirname, 'public-optimized'))) app.use(serveStatic(path.join(__dirname, 'public'))) app.listen(3000) ``` ```js var express = require('express') var path = require('path') var serveStatic = require('serve-static') var app = express() app.use(serveStatic(path.join(__dirname, 'public'), { maxAge: '1d', setHeaders: setCustomCacheControl })) app.listen(3000) function setCustomCacheControl (res, path) { if (serveStatic.mime.lookup(path) === 'text/html') { // Custom Cache-Control for HTML files res.setHeader('Cache-Control', 'public, max-age=0') } } ``` -------------------------------- ### Install the IP library Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ip/README.md Commands to install the library via npm or clone the repository from GitHub. ```shell npm install ip ``` ```shell git clone https://github.com/indutny/node-ip.git ``` -------------------------------- ### Install array-flatten Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/array-flatten/README.md Use npm to install the package as a dependency. ```bash npm install array-flatten --save ``` -------------------------------- ### Install statuses package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/statuses/README.md Use npm to install the module locally. ```sh $ npm install statuses ``` -------------------------------- ### Install postgrest-js Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/postgrest-js/README.md Use npm to install the package in your project. ```bash npm install @supabase/postgrest-js ``` -------------------------------- ### Install typedarray-to-buffer Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/typedarray-to-buffer/README.md Use npm to install the package in your project. ```bash npm install typedarray-to-buffer ``` -------------------------------- ### Command Line Usage Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime/README.md Example of using the mime command line tool. ```bash mime [path_string] ``` ```bash > mime scripts/jquery.js application/javascript ``` -------------------------------- ### Install yaeti Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/yaeti/README.md Use npm to install the package as a dependency. ```bash $ npm install yaeti --save ``` -------------------------------- ### Install safe-buffer Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/safe-buffer/README.md Command to install the package via npm. ```bash npm install safe-buffer ``` -------------------------------- ### Install ws library Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-CommandStream-Server/node_modules/ws/README.md Command to install the ws package via npm. ```bash npm install ws ``` -------------------------------- ### Install Send via NPM Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/send/README.md Use this command to install the library in your Node.js project. ```bash $ npm install send ``` -------------------------------- ### Install es5-ext via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/es5-ext/README.md Use this command to install the package in your project. ```bash npm install es5-ext ``` -------------------------------- ### Install finalhandler Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/finalhandler/README.md Use npm to install the package locally. ```sh $ npm install finalhandler ``` -------------------------------- ### Create a basic Express server Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Initializes an Express application and starts a server listening on port 3000. ```js const express = require('express') const app = express() app.get('/', function (req, res) { res.send('Hello World') }) app.listen(3000) ``` -------------------------------- ### Install dotenv Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/dotenv/README.md Install the package locally using npm. ```bash # install locally (recommended) npm install dotenv --save ``` -------------------------------- ### Install content-disposition Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/content-disposition/README.md Command to install the package via npm. ```sh $ npm install content-disposition ``` -------------------------------- ### Run iconv-lite tests and performance benchmarks Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/iconv-lite/README.md Commands to clone the repository, install dependencies, run tests, check performance, and generate coverage reports. ```bash $ git clone git@github.com:ashtuchkin/iconv-lite.git $ cd iconv-lite $ npm install $ npm test $ # To view performance: $ node test/performance.js $ # To view test coverage: $ npm run coverage $ open coverage/lcov-report/index.html ``` -------------------------------- ### Configure WebSocket server compression Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-CommandStream-Server/node_modules/ws/README.md Example of initializing a WebSocketServer with custom permessage-deflate settings. ```javascript import WebSocket, { WebSocketServer } from 'ws'; const wss = new WebSocketServer({ port: 8080, perMessageDeflate: { zlibDeflateOptions: { // See zlib defaults. chunkSize: 1024, memLevel: 7, level: 3 }, zlibInflateOptions: { chunkSize: 10 * 1024 }, // Other options settable: clientNoContextTakeover: true, // Defaults to negotiated value. serverNoContextTakeover: true, // Defaults to negotiated value. serverMaxWindowBits: 10, // Defaults to negotiated value. // Below options specified as default values. concurrencyLimit: 10, // Limits zlib concurrency for perf. threshold: 1024 // Size (in bytes) below which messages // should not be compressed if context takeover is disabled. } }); ``` -------------------------------- ### Install accepts via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/accepts/README.md Use the npm command to install the accepts package in your project. ```sh $ npm install accepts ``` -------------------------------- ### Install Supabase JS Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/supabase-js/README.md Use npm to install the library in your project. ```sh npm install @supabase/supabase-js ``` -------------------------------- ### Install optional performance modules Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-CommandStream-Server/node_modules/ws/README.md Commands to install optional binary addons for improved performance in masking and UTF-8 validation. ```bash npm install --save-optional bufferutil ``` ```bash npm install --save-optional utf-8-validate ``` -------------------------------- ### Using es5-ext Shims Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/es5-ext/README.md Examples of how to implement ES6 features globally or import them as standalone modules. ```APIDOC ## Implementing ES6 Features Globally ### Description Forces an ES6 feature to be implemented on the native object if it does not already exist. ### Usage ```javascript require("es5-ext/array/from/implement"); Array.from("foo"); // ['f', 'o', 'o'] ``` ## Importing Standalone Shims ### Description Accesses the shim directly without modifying native objects. This will use the native implementation if available, falling back to the shim otherwise. ### Usage ```javascript var aFrom = require("es5-ext/array/from"); aFrom("foo"); // ['f', 'o', 'o'] ``` ## Forcing Shim Usage ### Description Uses the shim implementation unconditionally, even if a native implementation exists. ### Usage ```javascript var aFrom = require("es5-ext/array/from/shim"); aFrom("foo"); // ['f', 'o', 'o'] ``` ``` -------------------------------- ### Install bufferutil Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/bufferutil/README.md Install the package as an optional dependency using npm. ```bash npm install bufferutil --save-optional ``` -------------------------------- ### Configure package.json install script Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/node-gyp-build/README.md Add node-gyp-build to the install script in your package.json file. ```json { ... "scripts": { "install": "node-gyp-build" } } ``` -------------------------------- ### Install parseurl Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/parseurl/README.md Use npm to install the package in your Node.js project. ```sh $ npm install parseurl ``` -------------------------------- ### Install WebSocket type definitions Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3_littlefire/NodeServer/node_modules/@types/websocket/README.md Use this command to add the type definitions to your project dependencies. ```bash npm install --save @types/websocket ``` -------------------------------- ### Install range-parser Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/range-parser/README.md Use npm to install the package in your Node.js project. ```sh $ npm install range-parser ``` -------------------------------- ### Install toidentifier via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/toidentifier/README.md Use the npm command to install the package in your project. ```bash $ npm install toidentifier ``` -------------------------------- ### Install body-parser Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/body-parser/README.md Use npm to install the body-parser package in your project. ```sh $ npm install body-parser ``` -------------------------------- ### Always 404 Example Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/finalhandler/README.md Create a server that returns a 404 response for every request. ```js var finalhandler = require('finalhandler') var http = require('http') var server = http.createServer(function (req, res) { var done = finalhandler(req, res) done() }) server.listen(3000) ``` -------------------------------- ### Install IP library via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3_littlefire/NodeServer/node_modules/ip/README.md Use this command to install the package in your project. ```shell npm install ip ``` -------------------------------- ### Install etag package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/etag/README.md Use npm to install the etag module into your project. ```sh $ npm install etag ``` -------------------------------- ### Install forwarded module Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/forwarded/README.md Use npm to install the package locally in your project. ```sh $ npm install forwarded ``` -------------------------------- ### Install es6-iterator via npm Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO/NodeServer/node_modules/es6-iterator/README.md Command to install the package using npm. ```bash $ npm install es6-iterator ``` -------------------------------- ### Install TypeScript definitions Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/raw-body/README.md Install the required Node.js type definitions for TypeScript support. ```sh $ npm install @types/node ``` -------------------------------- ### Install Punycode via package managers Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/punycode/README.md Commands to install the library using various package managers. ```bash npm install punycode ``` ```bash bower install punycode ``` ```bash component install bestiejs/punycode.js ``` -------------------------------- ### Example output Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3_littlefire/NodeServer/node_modules/object-inspect/readme.markdown The expected output format for the DOM element inspection example. ```text [
...
, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [ ... ] ] ] ] } ] ``` -------------------------------- ### Install vary package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/vary/README.md Command to install the vary module via npm. ```sh $ npm install vary ``` -------------------------------- ### Install node-fetch via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/node-fetch/README.md Use this command to install the current stable 2.x release of node-fetch in your project. ```sh $ npm install node-fetch ``` -------------------------------- ### Install raw-body package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/raw-body/README.md Use npm to install the raw-body module in your Node.js project. ```sh $ npm install raw-body ``` -------------------------------- ### Install fresh via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/fresh/README.md Use this command to add the fresh module to your Node.js project. ```bash $ npm install fresh ``` -------------------------------- ### Install Express via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Installs the Express package into the current project directory. ```console $ npm install express ``` -------------------------------- ### Initialize StorageClient Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Connect to the storage backend using the project URL and a service role key. ```js import { StorageClient } from '@supabase/storage-js' const STORAGE_URL = 'https://.supabase.co/storage/v1' const SERVICE_KEY = '' //! service key, not anon key const storageClient = new StorageClient(STORAGE_URL, { apikey: SERVICE_KEY, Authorization: `Bearer ${SERVICE_KEY}`, }) ``` -------------------------------- ### Create Content-Disposition header Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/content-disposition/README.md Example of setting the header in a Node.js response. ```js res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) ``` -------------------------------- ### Install Node Polyfill Plugin Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/dotenv/README.md Install the necessary dependency to resolve missing node modules in front-end environments. ```bash npm install node-polyfill-webpack-plugin ``` -------------------------------- ### Install bytes package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/bytes/Readme.md Use npm to install the bytes module into your project. ```bash $ npm install bytes ``` -------------------------------- ### Perform Simple Action Example Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/finalhandler/README.md Use finalhandler to handle errors when reading a file. ```js var finalhandler = require('finalhandler') var fs = require('fs') var http = require('http') var server = http.createServer(function (req, res) { var done = finalhandler(req, res) fs.readFile('index.html', function (err, buf) { if (err) return done(err) res.setHeader('Content-Type', 'text/html') res.end(buf) }) }) server.listen(3000) ``` -------------------------------- ### typeis(request, types) Examples Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/type-is/README.md Illustrations of how typeis matches request content types against various input patterns. ```js // req.headers.content-type = 'application/json' typeis(req, ['json']) // => 'json' typeis(req, ['html', 'json']) // => 'json' typeis(req, ['application/*']) // => 'application/json' typeis(req, ['application/json']) // => 'application/json' typeis(req, ['html']) // => false ``` -------------------------------- ### Install mime-types via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime-types/README.md Use this command to install the package in your Node.js project. ```sh $ npm install mime-types ``` -------------------------------- ### Install http-errors via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/http-errors/README.md Use this command to install the package in your Node.js project. ```console $ npm install http-errors ``` -------------------------------- ### Install cookie package Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/cookie/README.md Use npm to install the cookie library in a Node.js project. ```sh $ npm install cookie ``` -------------------------------- ### Install Express Generator Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Install the global command-line tool used to scaffold new Express applications. ```console $ npm install -g express-generator@4 ``` -------------------------------- ### Install encodeurl via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/encodeurl/README.md Use this command to install the package in a Node.js project. ```sh $ npm install encodeurl ``` -------------------------------- ### Manage processes with PM2 Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3/README.md Commands for starting, monitoring, and persisting server processes using PM2. ```bash sudo pm2 startup sudo pm2 status sudo pm2 list sudo pm2 start server.js --name "ballybot-server" sudo pm2 start heartbeat.js --name "supabase-heartbeat" --cron "0 0 * * *" --no-autorestart sudo pm2 startup sudo pm2 save sudo pm2 list ``` -------------------------------- ### Install util via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/util/README.md Use this command to add the util module to your project dependencies. ```shell npm install util ``` -------------------------------- ### Install setprototypeof via NPM Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/setprototypeof/README.md Command to add the package to your project dependencies. ```bash $ npm install --save setprototypeof ``` -------------------------------- ### Use IP address utilities Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ip/README.md Examples of common IP address operations including validation, conversion, subnetting, and buffer manipulation. ```javascript var ip = require('ip'); ip.address() // my ip address ip.isEqual('::1', '::0:1'); // true ip.toBuffer('127.0.0.1') // Buffer([127, 0, 0, 1]) ip.toString(new Buffer([127, 0, 0, 1])) // 127.0.0.1 ip.fromPrefixLen(24) // 255.255.255.0 ip.mask('192.168.1.134', '255.255.255.0') // 192.168.1.0 ip.cidr('192.168.1.134/26') // 192.168.1.128 ip.not('255.255.255.0') // 0.0.0.255 ip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255 ip.isPrivate('127.0.0.1') // true ip.isV4Format('127.0.0.1'); // true ip.isV6Format('::ffff:127.0.0.1'); // true // operate on buffers in-place var buf = new Buffer(128); var offset = 64; ip.toBuffer('127.0.0.1', buf, offset); // [127, 0, 0, 1] at offset 64 ip.toString(buf, offset, 4); // '127.0.0.1' // subnet information ip.subnet('192.168.1.134', '255.255.255.192') // { networkAddress: '192.168.1.128', // firstAddress: '192.168.1.129', // lastAddress: '192.168.1.190', // broadcastAddress: '192.168.1.191', // subnetMask: '255.255.255.192', // subnetMaskLength: 26, // numHosts: 62, // length: 64, // contains: function(addr){...} } ip.cidrSubnet('192.168.1.134/26') // Same as previous. // range checking ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true // ipv4 long conversion ip.toLong('127.0.0.1'); // 2130706433 ip.fromLong(2130706433); // '127.0.0.1' ``` -------------------------------- ### Initialize Supabase Client Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/supabase-js/README.md Import the createClient function and initialize the connection using your project URL and public key. ```js import { createClient } from '@supabase/supabase-js' // Create a single supabase client for interacting with your database const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') ``` -------------------------------- ### Run Express Test Suite Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/express/Readme.md Commands to install project dependencies and execute the built-in test suite. ```console $ npm install $ npm test ``` -------------------------------- ### Install Phoenix Type Definitions Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@types/phoenix/README.md Use npm to add the Phoenix type definitions to your project dependencies. ```bash npm install --save @types/phoenix ``` -------------------------------- ### typeis.is(mediaType, types) Examples Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/type-is/README.md Illustrations of how typeis.is matches a raw media type string against various input patterns. ```js var mediaType = 'application/json' typeis.is(mediaType, ['json']) // => 'json' typeis.is(mediaType, ['html', 'json']) // => 'json' typeis.is(mediaType, ['application/*']) // => 'application/json' typeis.is(mediaType, ['application/json']) // => 'application/json' typeis.is(mediaType, ['html']) // => false ``` -------------------------------- ### Run server locally Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3/README.md Command to initiate the server for local development after updating environment variables. ```bash node server 0.0.0.0 ``` -------------------------------- ### Retrieve Bucket Details Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Get details of an existing storage bucket. ```js const { data, error } = await storageClient.getBucket('test_bucket') ``` -------------------------------- ### Run tests for functions-js Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/functions-js/README.md Commands to install dependencies and execute the test suite. Requires Node 18+ and a running Docker daemon. ```sh npm i npm run test ``` -------------------------------- ### Initialize via ESM Module Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/supabase-js/README.md Import the client directly in browser modules using the ESM build. ```html ``` -------------------------------- ### Import Negotiator Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/negotiator/README.md Require the module to start using the Negotiator constructor. ```js var Negotiator = require('negotiator') ``` -------------------------------- ### Install mime-db via NPM Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime-db/README.md Use this command to add the mime-db package to your project dependencies. ```bash npm install mime-db ``` -------------------------------- ### Install unpipe via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/unpipe/README.md Use this command to add the unpipe package to your project dependencies. ```sh $ npm install unpipe ``` -------------------------------- ### Initialize WebSocket Client and Handle Events Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-Site-Server/demo.html Sets up the WebSocket connection, handles incoming image data, and manages connection lifecycle events. ```javascript body { text-align: center; min-width: 500px; } // log function log = function(data){ $("div#terminal").prepend("
" +data); console.log(data); }; var ws; var wsinterval; function sendInputData() { var inputs = joy.GetX()+","+joy.GetY(); console.log(inputs); ws.send(inputs); } $(document).ready(function () { $("div#message_details").hide() $("#open").click(function(evt) { evt.preventDefault(); let uri = $("#domain").val(); let ws = new Websocket(`${uri}`) const img = document.querySelector('img'); let urlObject; // Handle incoming websocket message callback ws.onmessage = async function(evt) { // log("Message Received: " + evt.data) // $("#slider").val() = evt.data; const arrayBuffer = evt.data; //console.log(evt); a = await arrayBuffer.arrayBuffer() //console.log(arrayBuffer); if(urlObject){ URL.revokeObjectURL(urlObject); } urlObject = URL.createObjectURL(arrayBuffer); img.src = urlObject; }; // Close Websocket callback ws.onclose = function(evt) { log("**Connection Closed**"); alert("Connection close"); $("#uri").css("background", "#ff0000"); clearInterval(wsinterval); }; // Open Websocket callback ws.onopen = function(evt) { $("#uri").css("background", "#00ff00"); $("div#message_details").show(); log("**Connection Opened**"); wsinterval = setInterval(function(){ sendInputData(); }, 50); }; }); // Send websocket message function // $("#send").click(function(evt) { // log("Sending Message: "+$("#message").val()); // ws.send($("#message").val()); // }); // $("#slider").on('input' ,function(evt) { // log("Sending Message: "+$("#slider").val()); // //console.log("test"); // ws.send($("#slider").val()); // }); }); ``` -------------------------------- ### Create a simple WebSocket server Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-CommandStream-Server/node_modules/ws/README.md Initializes a standalone WebSocket server on a specified port. ```js import { WebSocketServer } from 'ws'; const wss = new WebSocketServer({ port: 8080 }); wss.on('connection', function connection(ws) { ws.on('message', function message(data) { console.log('received: %s', data); }); ws.send('something'); }); ``` -------------------------------- ### Define environment variables Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/dotenv/README.md Create a .env file in the project root to store configuration keys. ```dosini S3_BUCKET="YOURS3BUCKET" SECRET_KEY="YOURSECRETKEYGOESHERE" ``` -------------------------------- ### Import WebSocket modules Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/websocket/README.md Require the necessary classes from the websocket package to start building your client or server. ```javascript var WebSocketServer = require('websocket').server; var WebSocketClient = require('websocket').client; var WebSocketFrame = require('websocket').frame; var WebSocketRouter = require('websocket').router; var W3CWebSocket = require('websocket').w3cwebsocket; ``` -------------------------------- ### Serve static files using Express Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3/NodeServer/node_modules/serve-static/README.md Demonstrates basic integration with the Express framework. ```js var express = require('express') var serveStatic = require('serve-static') var app = express() app.use(serveStatic('public/ftp', { index: ['default.html', 'default.htm'] })) app.listen(3000) ``` -------------------------------- ### Create a WebSocket Server Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/websocket/README.md Sets up a basic HTTP server and attaches a WebSocket server to it, with origin validation and message handling. ```javascript #!/usr/bin/env node var WebSocketServer = require('websocket').server; var http = require('http'); var server = http.createServer(function(request, response) { console.log((new Date()) + ' Received request for ' + request.url); response.writeHead(404); response.end(); }); server.listen(8080, function() { console.log((new Date()) + ' Server is listening on port 8080'); }); wsServer = new WebSocketServer({ httpServer: server, // You should not use autoAcceptConnections for production // applications, as it defeats all standard cross-origin protection // facilities built into the protocol and the browser. You should // *always* verify the connection's origin and decide whether or not // to accept it. autoAcceptConnections: false }); function originIsAllowed(origin) { // put logic here to detect whether the specified origin is allowed. return true; } wsServer.on('request', function(request) { if (!originIsAllowed(request.origin)) { // Make sure we only accept requests from an allowed origin request.reject(); console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.'); return; } var connection = request.accept('echo-protocol', request.origin); console.log((new Date()) + ' Connection accepted.'); connection.on('message', function(message) { if (message.type === 'utf8') { console.log('Received Message: ' + message.utf8Data); connection.sendUTF(message.utf8Data); } else if (message.type === 'binary') { console.log('Received Binary Message of ' + message.binaryData.length + ' bytes'); connection.sendBytes(message.binaryData); } }); connection.on('close', function(reasonCode, description) { console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.'); }); }); ``` -------------------------------- ### Allocate and overwrite buffer Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/safe-buffer/README.md Example of manually allocating a buffer and overwriting its contents, which is a common pattern for handling uninitialized memory. ```javascript var buf = new Buffer(16) // Immediately overwrite the uninitialized buffer with data from another buffer for (var i = 0; i < buf.length; i++) { buf[i] = otherBuf[i] } ``` -------------------------------- ### Create and Subscribe to a Channel Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/realtime-js/README.md Initialize the RealtimeClient and subscribe to a channel to handle connection status updates. ```js import { RealtimeClient } from '@supabase/realtime-js' const client = new RealtimeClient(REALTIME_URL, { params: { apikey: API_KEY, eventsPerSecond: 10, }, }) const channel = client.channel('test-channel', {}) channel.subscribe((status, err) => { if (status === 'SUBSCRIBED') { console.log('Connected!') } if (status === 'CHANNEL_ERROR') { console.log(`There was an error subscribing to channel: ${err.message}`) } if (status === 'TIMED_OUT') { console.log('Realtime server did not respond in time.') } if (status === 'CLOSED') { console.log('Realtime channel was unexpectedly closed.') } }) ``` -------------------------------- ### RealtimeClient Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/realtime-js/README.md Initializes a new Realtime client instance to connect to the server. ```APIDOC ## RealtimeClient(url, options) ### Description Creates a new instance of the Realtime client. ### Parameters - **url** (string) - Required - The WebSocket URL of the Realtime server. - **options** (object) - Required - Configuration object containing `params` (e.g., `apikey`, `eventsPerSecond`). ``` -------------------------------- ### Initialize via UMD Global Variable Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/supabase-js/README.md Access the client through the global supabase variable after loading the UMD script. ```html ``` -------------------------------- ### Initialize Robot Control Interface Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot1.5/esp32demo.html Sets up the joystick and arrow key event listeners and manages UI visibility for the control modes. ```javascript var joy; var controlType = "keys"; // document.addEventListener('DOMContentLoaded', function () { // fix mainpage height: // mainPage.style.height = `calc(100% - ${navBar.offsetHeight}px)` keyDiv.style.fontSize = `${keyDiv.offsetWidth/15}px`; keyDiv.style.display = "none" console.log(joyDiv.style.display) joyDiv.style.width = `${joyDiv.offsetHeight}px` joy = new JoyStick('joyDiv'); joyDiv.style.margin = "auto"; joyDiv.style.display = "none" keyDiv.style.display = ""; }); // Create JoyStick object into the DIV 'joyDiv' var controls = document.getElementById('controls') var joyDiv = document.getElementById('joyDiv') var keyDiv = document.getElementById('keysDiv') const arrowKeysButton = document.getElementById('arrowKeysButton'); const joystickButton = document.getElementById('joystickButton'); const arrowKeys = document.getElementById('arrowKeys'); const joystick = document.getElementById('joystick'); arrowKeysButton.addEventListener('click', function () { controlType = "keys"; arrowKeysButton.classList.add('active'); joystickButton.classList.remove('active'); joyDiv.style.display = "none" keyDiv.style.display = "" }); joystickButton.addEventListener('click', function () { controlType = "joystick"; arrowKeysButton.classList.remove('active'); joystickButton.classList.add('active'); joyDiv.style.display = "" keyDiv.style.display = "none" }); ``` -------------------------------- ### Initialize PostgrestClient Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/postgrest-js/README.md Create a new client instance by providing the REST API URL. ```js import { PostgrestClient } from '@supabase/postgrest-js' const REST_URL = 'http://localhost:3000' const postgrest = new PostgrestClient(REST_URL) ``` -------------------------------- ### Initialize Robot Controls Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot1.5/Pages/controls.html Sets up the joystick object and event listeners for switching between control modes. ```javascript var joy; var controlType = "keys"; // document.addEventListener('DOMContentLoaded', function () { // fix mainpage height: // mainPage.style.height = `calc(100% - ${navBar.offsetHeight}px)` // keyDiv.style.fontSize = `${keyDiv.offsetWidth/15}px`; keyDiv.style.display = "none" console.log(joyDiv.style.display) joyDiv.style.width = `${joyDiv.offsetHeight}px` joy = new JoyStick('joyDiv'); joyDiv.style.margin = "auto"; joyDiv.style.display = "none" keyDiv.style.display = ""; }); // Create JoyStick object into the DIV 'joyDiv' var controls = document.getElementById('controls') var joyDiv = document.getElementById('joyDiv') var keyDiv = document.getElementById('keysDiv') const arrowKeysButton = document.getElementById('arrowKeysButton'); const joystickButton = document.getElementById('joystickButton'); const arrowKeys = document.getElementById('arrowKeys'); const joystick = document.getElementById('joystick'); arrowKeysButton.addEventListener('click', function () { controlType = "keys"; arrowKeysButton.classList.add('active'); joystickButton.classList.remove('active'); joyDiv.style.display = "none" keyDiv.style.display = "" }); joystickButton.addEventListener('click', function () { controlType = "joystick"; arrowKeysButton.classList.remove('active'); joystickButton.classList.add('active'); joyDiv.style.display = "" keyDiv.style.display = "none" }); ``` -------------------------------- ### Run benchmarks Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/etag/README.md Execute the performance benchmark suite. ```bash $ npm run-script bench > etag@1.8.1 bench nodejs-etag > node benchmark/index.js http_parser@2.7.0 node@6.11.1 v8@5.1.281.103 uv@1.11.0 zlib@1.2.11 ares@1.10.1-DEV icu@58.2 modules@48 openssl@1.0.2k > node benchmark/body0-100b.js 100B body 4 tests completed. buffer - strong x 258,647 ops/sec ±1.07% (180 runs sampled) buffer - weak x 263,812 ops/sec ±0.61% (184 runs sampled) string - strong x 259,955 ops/sec ±1.19% (185 runs sampled) string - weak x 264,356 ops/sec ±1.09% (184 runs sampled) > node benchmark/body1-1kb.js 1KB body 4 tests completed. buffer - strong x 189,018 ops/sec ±1.12% (182 runs sampled) buffer - weak x 190,586 ops/sec ±0.81% (186 runs sampled) string - strong x 144,272 ops/sec ±0.96% (188 runs sampled) string - weak x 145,380 ops/sec ±1.43% (187 runs sampled) > node benchmark/body2-5kb.js 5KB body 4 tests completed. buffer - strong x 92,435 ops/sec ±0.42% (188 runs sampled) buffer - weak x 92,373 ops/sec ±0.58% (189 runs sampled) string - strong x 48,850 ops/sec ±0.56% (186 runs sampled) string - weak x 49,380 ops/sec ±0.56% (190 runs sampled) > node benchmark/body3-10kb.js 10KB body 4 tests completed. buffer - strong x 55,989 ops/sec ±0.93% (188 runs sampled) buffer - weak x 56,148 ops/sec ±0.55% (190 runs sampled) string - strong x 27,345 ops/sec ±0.43% (188 runs sampled) string - weak x 27,496 ops/sec ±0.45% (190 runs sampled) > node benchmark/body4-100kb.js 100KB body 4 tests completed. buffer - strong x 7,083 ops/sec ±0.22% (190 runs sampled) buffer - weak x 7,115 ops/sec ±0.26% (191 runs sampled) string - strong x 3,068 ops/sec ±0.34% (190 runs sampled) string - weak x 3,096 ops/sec ±0.35% (190 runs sampled) > node benchmark/stats.js stat 4 tests completed. real - strong x 871,642 ops/sec ±0.34% (189 runs sampled) real - weak x 867,613 ops/sec ±0.39% (190 runs sampled) fake - strong x 401,051 ops/sec ±0.40% (189 runs sampled) fake - weak x 400,100 ops/sec ±0.47% (188 runs sampled) ``` -------------------------------- ### Import ee-first Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/ee-first/README.md Require the module to begin using the library. ```js var first = require('ee-first') ``` -------------------------------- ### Perform simple type negotiation Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/accepts/README.md Demonstrates how to respond with different content types based on client preferences using the accepts object. ```js var accepts = require('accepts') var http = require('http') function app (req, res) { var accept = accepts(req) // the order of this list is significant; should be server preferred order switch (accept.type(['json', 'html'])) { case 'json': res.setHeader('Content-Type', 'application/json') res.write('{"hello":"world!"}') break case 'html': res.setHeader('Content-Type', 'text/html') res.write('hello, world!') break default: // the fallback is text/plain, so no need to specify it above res.setHeader('Content-Type', 'text/plain') res.write('hello, world!') break } res.end() } http.createServer(app).listen(3000) ``` -------------------------------- ### Initialize accepts Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/accepts/README.md Require the module to begin using it in your Node.js application. ```js var accepts = require('accepts') ``` -------------------------------- ### StorageClient.from().getPublicUrl Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO2/NodeServer/node_modules/@supabase/storage-js/README.md Gets a public URL. ```APIDOC ## storageClient.from(bucketId).getPublicUrl(path) ### Description Retrieves the public URL for an asset in a public bucket. ``` -------------------------------- ### Basic Usage of qs Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/qs/README.md Demonstrates the fundamental parse and stringify operations. ```javascript var qs = require('qs'); var assert = require('assert'); var obj = qs.parse('a=c'); assert.deepEqual(obj, { a: 'c' }); var str = qs.stringify(obj); assert.equal(str, 'a=c'); ``` -------------------------------- ### get(obj) Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32_Stream_Robot3/NodeServer/node_modules/es6-iterator/README.md Returns an iterator for any iterable object. ```APIDOC ### Function: get(obj) #### Description Returns an iterator for any iterable object. #### Parameters - **obj** (Object) - Required - The object to retrieve an iterator for. ``` -------------------------------- ### Development commands Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/send/node_modules/ms/readme.md Commands for linking the package locally and running tests. ```bash npm link npm link ms npm test ``` -------------------------------- ### Parse Content-Disposition header Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/content-disposition/README.md Example of parsing a header string into an object. ```js var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt') ``` -------------------------------- ### Initialize Control Interface Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/Pages/controls.html Sets up the initial state of the joystick and key control elements upon DOM content loading. ```javascript var joy; var controlType = "keys"; // document.addEventListener('DOMContentLoaded', function () { // fix mainpage height: // mainPage.style.height = `calc(100% - ${navBar.offsetHeight}px)` // keyDiv.style.fontSize = `${keyDiv.offsetWidth/15}px`; keyDiv.style.display = "none" console.log(joyDiv.style.display) joyDiv.style.width = `${joyDiv.offsetHeight}px` joy = new JoyStick('joyDiv'); joyDiv.style.margin = "auto"; joyDiv.style.display = "none" keyDiv.style.display = ""; }); ``` -------------------------------- ### mime.extension(type) Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime/README.md Get the default extension for a given MIME type. ```APIDOC ## mime.extension(type) ### Description Returns the default extension associated with the provided MIME type string. ### Parameters - **type** (string) - Required - The MIME type to look up. ### Example ```js mime.extension('text/html'); // => 'html' ``` ``` -------------------------------- ### Get an iterator for an object Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/es6-iterator/README.md Utility to return an iterator for any iterable object. ```javascript var getIterator = require('es6-iterator/get'); var iterator = get([1,2,3]); iterator.next(); // { value: 1, done: false } iterator.next(); // { value: 2, done: false } iterator.next(); // { value: 3, done: false } iterator.next(); // { value: undefined, done: true } ``` -------------------------------- ### Get All Channels Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/realtime-js/README.md Retrieve a list of all channels currently instantiated by the client. ```js // Setup... client.getChannels() ``` -------------------------------- ### StorageClient.from().list Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO2/NodeServer/node_modules/@supabase/storage-js/README.md Lists files in a bucket folder. ```APIDOC ## storageClient.from(bucketId).list(path) ### Description Lists all files within a specific folder in a bucket. ``` -------------------------------- ### Create Storage Bucket Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Create a new storage bucket with specified options. ```js const { data, error } = await storageClient.createBucket( 'test_bucket', // Bucket name (must be unique) { public: false } // Bucket options ) ``` -------------------------------- ### Initialize WebSocket Client and Stream Handling Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/client.html Establishes a connection to the robot server and updates the image source using Blob objects from incoming binary data. ```javascript const params = new URLSearchParams(window.location.search); const robotID = params.get('id'); // Retrieves the value of the 'name' parameter (John) const img = document.querySelector('img'); const headers = { 'type': 'Website', 'id': robotID }; const searchParams = new URLSearchParams(headers); const queryString = searchParams.toString(); const WS_URL = 'ws:///10.0.0.36:8888?'+queryString; const ws = new WebSocket(WS_URL); let urlObject; // Events document.getElementById('lightBtn').addEventListener('click', function() { console.log('Button clicked!'); ws.send('Button clicked!'); }); ws.onopen = () => console.log(`Connected to ${WS_URL}`); ws.onmessage = message => { const arrayBuffer = message.data; if(urlObject){ URL.revokeObjectURL(urlObject); } urlObject = URL.createObjectURL(new Blob([arrayBuffer])); img.src = urlObject; } ``` -------------------------------- ### Get Default Extension Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/mime/README.md Retrieves the default extension for a given MIME type. ```javascript mime.extension('text/html'); // => 'html' mime.extension('application/octet-stream'); // => 'bin' ``` -------------------------------- ### Get Public URL Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Retrieve the public URL for an asset in a public bucket. ```js const { data, error } = await storageClient.from('public-bucket').getPublicUrl('path/to/file') ``` -------------------------------- ### Add comments to .env Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/dotenv/README.md Comments can be added on their own lines or inline, starting with a # character. ```dosini # This is a comment SECRET_KEY=YOURSECRETKEYGOESHERE # comment SECRET_HASH="something-with-a-#-hash" ``` -------------------------------- ### Disable compression on client Source: https://github.com/williamsokol/esp32robots/blob/main/NodeJS-CommandStream-Server/node_modules/ws/README.md Example of initializing a WebSocket client with permessage-deflate explicitly disabled. ```javascript import WebSocket from 'ws'; const ws = new WebSocket('ws://www.host.com/path', { perMessageDeflate: false }); ``` -------------------------------- ### Initialize WebSocket Client and Image Stream Source: https://github.com/williamsokol/esp32robots/blob/main/WifiSystems/GlobalWifiwebsocketIO/NodeServer/client.html Establishes a WebSocket connection using URL parameters and updates an image element with incoming binary data. ```javascript const params = new URLSearchParams(window.location.search); const robotID = params.get('id'); // Retrieves the value of the 'name' parameter (John) const img = document.querySelector('img'); const headers = { 'type': 'Website', 'id': robotID }; const searchParams = new URLSearchParams(headers); const queryString = searchParams.toString(); const WS_URL = 'ws:///10.0.0.36:8888?'+queryString; // IMPORTANT ip must be updated for every new server ip const ws = new WebSocket(WS_URL); let urlObject; // Events document.getElementById('lightBtn').addEventListener('click', function() { console.log('Button clicked!'); ws.send('Button clicked!'); }); ws.onopen = () => console.log(`Connected to ${WS_URL}`); ws.onmessage = message => { // console.log(message.data) const arrayBuffer = message.data; if(urlObject){ URL.revokeObjectURL(urlObject); } urlObject = URL.createObjectURL(new Blob([arrayBuffer])); img.src = urlObject; } ``` -------------------------------- ### Get status message by code Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/statuses/README.md Retrieve the string message for a numeric status code. ```js status.message[404] // => 'Not Found' ``` -------------------------------- ### Get all request addresses Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/proxy-addr/README.md Retrieve all addresses in the request chain, optionally filtered by trust. ```js proxyaddr.all(req) ``` ```js proxyaddr.all(req, 'loopback') ``` -------------------------------- ### Constructing Headers objects Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/node-fetch/README.md Demonstrates various ways to initialize a Headers object using objects, arrays, Maps, or existing Headers instances. ```javascript // Example adapted from https://fetch.spec.whatwg.org/#example-headers-class const meta = { 'Content-Type': 'text/xml', 'Breaking-Bad': '<3' }; const headers = new Headers(meta); // The above is equivalent to const meta = [ [ 'Content-Type', 'text/xml' ], [ 'Breaking-Bad', '<3' ] ]; const headers = new Headers(meta); // You can in fact use any iterable objects, like a Map or even another Headers const meta = new Map(); meta.set('Content-Type', 'text/xml'); meta.set('Breaking-Bad', '<3'); const headers = new Headers(meta); const copyOfHeaders = new Headers(headers); ``` -------------------------------- ### Include via CDN Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/cross-fetch/README.md Load the fetch function directly into the window object using a script tag. ```html ``` -------------------------------- ### Install debug via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/debug/README.md Use this command to add the debug package to your project dependencies. ```bash $ npm install debug ``` -------------------------------- ### createBucket Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/@supabase/storage-js/README.md Creates a new storage bucket. ```APIDOC ## createBucket(id, options) ### Description Creates a new storage bucket with the specified ID and options. ### Parameters - **id** (string) - Required - The unique name of the bucket. - **options** (object) - Optional - Configuration options, such as { public: boolean }. ``` -------------------------------- ### Install path module via npm Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/path/README.md Use this command to add the path module as a dependency in your project. ```sh $ npm install --save path ``` -------------------------------- ### Import media-typer Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/media-typer/README.md Require the module to begin using the library. ```js var typer = require('media-typer') ``` -------------------------------- ### Run tests Source: https://github.com/williamsokol/esp32robots/blob/main/RobotBuilds/Esp32-Stream-Robot2/NodeServer/node_modules/content-disposition/README.md Command to execute the test suite for the package. ```sh $ npm test ```