Kitten

Technical Manual sections

Kitten stores its own files and the data of every app it serves under one data home, ~/.local/share/small-tech.org/kitten/ (paths.KITTEN_DATA_HOME). Kitten follows the XDG Base Directory Specification, so setting XDG_DATA_HOME to an absolute path moves it. src/lib/paths.ts defines Kitten’s paths. The global kitten.paths object exposes them (except the ones in updatePaths) along with the paths of the app being served (APP_DATA_DIRECTORY, APP_UPLOADS_DIRECTORY, and APP_REPL_DIRECTORY).

The data home contains:

Outside the data home, Kitten writes:

The data/ folder also marks the data layout as current: if it doesn’t exist when Kitten starts, the main script runs the data encapsulation migration.

Kitten uses JSDB for all three of its databases. Each top-level property of a database is a table, which JSDB persists as a JavaScript file that starts with the table’s initial value, followed by one line per change. When Kitten opens kitten.db or kitten._db, JSDB compacts their tables, unless the jsdbCompactOnLoad environment variable is 'false' (the kitten db commands set it). JSDB never compacts kitten.__db.

Remember that JSDB doesn’t persist properties whose names start with an underscore, and that it calls the constructor of each registered class with one parameter object when it loads a table. A class that you add to INTERNAL_DATABASE_CLASSES must accept that object.

Source code:

Like this? Fund us!

Small Technology Foundation is a tiny, independent not-for-profit.

We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.