Finally another update on my personal blog ;-) I've been busy the past year - learning new stuff and improving on existing skills.
So, what did I do? Mostly I've been learning Angular, TypeScript, working on some php projects and improving on EAM and requirements engineering.
Today I want to share some of my learnings I had while working with nodejs on raspberry pi. The objective was to create a backup tool which runs on said raspberry, with a lot of restrictions. Backups had to be downloaded via FTP only, also the backup had to start on an interval only if there's a USB stick present. Maybe use a binary to start everything. Simple, so far.
I started with a lot of research on how to detect the presence of a USB device and on how to mount/manage it. Soon, I came up with a USB detection library that reacts on('add', (device: Device) => {})
and on('remove', (device: Device) => {})
.
Besides, I had to establish some baseline and reliable setup for working with node and creating cli applications. There my Angular experiences came in handy, since all development is done with TypeScript, I opted to do likewise.
"main": "./lib/app.js",
"bin": "./lib/app.js",
"scripts": {
"start": "nodemon --watch 'src/**/*.ts' --exec ts-node src/app.ts"
}
To have fancy colors, argument parsing, etc., I added:
"arg": "^4.1.1",
"basic-ftp": "^3.8.7",
"chalk": "^2.4.2",
"check-disk-space": "^2.1.0",
"clear": "^0.1.0",
"commander": "^3.0.0",
"dotenv": "^8.1.0",
"esm": "^3.2.25",
"figlet": "^1.2.3",
"fs": "0.0.1-security",
"node-schedule": "^1.3.2",
"nodemailer": "^6.3.0",
"path": "^0.12.7",
"pino": "^5.13.2",
"usb-detection": "^4.3.0"
With this basic setup, I could build all I need. Long story short: A lot of challenges came up, costing me loads of time to understand and overcome.
Not to forget logging and sending emails on special events like "device capacity below 20%". Another good example on how projects grow beyond the expected features :-)