javascript

Fix Relative Paths in NodeJS Apps

Most NodeJS apps consist of hundreds of .js files which are included wherever needed using require. While this makes the dependencies of modules really obvious, most of the paths look like this in the end: const createUuid = require('../../../support/utils/create_uuid'); The problem is that by default NodeJS uses relative paths for local modules (not stuff that’s inside the node_modules folder). Not only does this look really strange, it’s also hard to read and if you ever want to move files around you have to fix all paths in your application to make it work again (and since this is lazily evaluated, you’ll probably miss some for code paths that are not tested).

Creating a Fever API for Nextcloud News Part 1: Exploration / Mocking

In this series of screencasts I will create a Fever-compatible API layer for Nextcloud News, since I want to use this as my primary news reader. This API will be used to connect Nextcloud News to my Newsreader Apps on macOS and iOS. The API itself will be a separate application written in NodeJS that just uses the Nextcloud News database to query and write data. Later on I will probably create a Nextcloud App, but for now this series focuses on reverse engineering, functional programming and test-driven development in NodeJS.

NodeJS: Interactive shell with hot reload

I’m currently working on a project in NodeJS. It’s an REST API server for a web application. Since it supports multi-tenancy but all tenants are created manually, I needed a quick and easy way to be able to call the createTenant method whenever I need it. I could have written a command-line tool that would do it for me, but actually I needed something like rails console for Ruby on Rails apps: A shell where I can just execute code in the context of my app.

macOS: Change wallpaper by CLI

Current macOS versions are weird… Often when I connect my MacBook Pro to the two screens on my desk, the wallpaper on one of that guys is either gone or changed to a different one. After many attempts to search them in my bunch of 2k wallpapers, I eventually gave up and wrote a script that sets the wallpaper on all my screens like this: osascript -e 'tell application "System Events" to set picture of every desktop to ("/some/path/wallpaper.