An assortment of Google Cloud utilities.
npm install @valentine-stone/googleapi-utilsAn assortment of Google Cloud utilities.
pubsub - Google Cloud Pub/Sub powered P2P tunnel (spawns necessary resources automatically)google-iot - Google IoT Commands powered P2P tunnel (spawns necessary resources automatically)google-iot-controlled - google-iot, but with TCP-like session managmentserialport - An adapter-wrapper for serialportudp - Adapter-wrapper for UDP (dgram) server (listens on (owns) a given ip and port)udp-proxy - Adapter-wrapper for UDP (dgram) client (talks to a given ip and port)tcp - Adapter-wrapper for TCP server (listens on a given ip and port for any connections, reads from all writes to all)chain - as the name implies, chain multiple adapters together, creating a data conveyormeasure - measure and log any adapter's input/outputthrottle - Throttles the bytes sent by delaying send untill a given amount of bytes is ready to be senttransform - Arbitrarily transform input and output (can be used for logging or sideeffects)atcp - Abstract pure js TCP implementation (not finished, does not work)git clone https://github.com/ValentineStone/googleapi-utilscd googleapi-utilsnpm icp .env.example .env and change it according to your setupnode claim set custom claim node claim --clear clear custom claims node claim get custom claim node claim get all custom claims node claim --clear clear all custom claimsIn all commands userId can be multiple ids, separated by a comma, like so:
``sh`
node claim wejq7RynaVC2H3WK4toXxT3BHgWS,43f5xpVkCmXz22OdIlSshYMZANF2,7Y9nKfPY1JMMVEVE8Q4tSH9pwsGG admin true> wejq7RynaVC2H3WK4toXxT3BHgWS admin = true
> 43f5xpVkCmXz22OdIlSshYMZANF2 admin = true
> 7Y9nKfPY1JMMVEVE8Q4tSH9pwsGG admin = true
set the claim 'admin' to true for 3 users
node rstr $3
length
Generate random string of symbols consisting of symbols. firstsymbols
If is present the first symbol of the string will be selected from it.
Default length is 32, default symbols:`!@#$%^&*()_-+={[}]|\:;"\'<,>.?/
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~
``symbols
Both and firstsymbols can be one of the following shortcuts: -alpha -num -alnum -other -url -any.node rdate $3
`sh`
node rdate> 1994-10-21 20:52:55
node rdate 0001-01-01 1000-01-01> 0396-01-05 00:02:07
node uuid $3
to generate a UUID-5 (if name is not provided is it set to Date.now() + '-' + Math.random())node adapters/connect $3
A quick and easy way to get some data from one source to another, a simple multitool for the ages.
For adapters types see above and for their parameters see in the code.
Example:
`sh`
node adapters/connect tcp localhost,55757 serialport COM8,115200> [tcp]: localhost:55757
> [serialport]: COM8:115200
node rtdb mv [--push] $3
move value node rtdb cp [--push] copy value node rtdb rm remove value from path node rtdb set [--push] set value node rtdb get get value, duh
None of the methods that change the database would override an existing path, you need to remove whatever is there before you can write anything new. If you want to just add an item to a collection with an auto generated Firebase key use --push, like so:`sh``
node rtdb set --push /badguys '{ "name": "Mare-do-well", "type": "pony" }'> setting...
> set /badguys/-M_vA9s0ksgQHI54DUF9
Whops, Mare-do-well is not a villan, she is a hero, lets fix that
node rtdb mv --push /badguys/-M_vA9s0ksgQHI54DUF9 /goodguys> moving...
> moved /badguys/-M_vA9s0ksgQHI54DUF9 to /goodguys/-M_vAODTlncCrpePrYeZ
But she has an evil invisible twin sister,
lets copy the record and change it accordingly
node rtdb cp --push /goodguys/-M_vAODTlncCrpePrYeZ /badguys> copying...
> copied /goodguys/-M_vAODTlncCrpePrYeZ to /badguys/-M_vAg7zsv3xie7bBlIU
For security reasons there is no way to change a value in this cli,
so lets remove the name and set the new one
node rtdb rm /badguys/-M_vAg7zsv3xie7bBlIU/name> removing...
> removed /badguys/-M_vAg7zsv3xie7bBlIU/nam
node rtdb set /badguys/-M_vAg7zsv3xie7bBlIU/name "Ne'er-do-well"> setting...
> set /badguys/-M_vAg7zsv3xie7bBlIU/name
Lets check our handywork
node rtdb get /badguys> getting...
> { '-M_vAg7zsv3xie7bBlIU': { name: "Ne'er-do-well" } }
node rtdb get /goodguys> getting...
> { '-M_vAODTlncCrpePrYeZ': { name: 'Mare-do-well' } }
Glorious work!