cvennevik,
@cvennevik@hachyderm.io avatar

I want to make a web app for viewing, creating, and modifying entries saved to a local file. I will use it on my old budget Android phone, and I want it to be as performant as I can possibly make it.

What do I use to build it?

#webdev

aral,
@aral@mastodon.ar.al avatar

@cvennevik Take a look at Kitten (https://codeberg.org/kitten/app) and let me know if it works for you or not :)

cvennevik,
@cvennevik@hachyderm.io avatar

@aral I was wondering about pinging you and asking 😊 I might just try it out!

Maybe what I'll have to end up doing is building the app in several different frameworks and comparing them!

(That sounds like the kind of ambitious thing that I'd love to do and, of course, never get around to)

aral, (edited )
@aral@mastodon.ar.al avatar

@cvennevik Cool. And while you can use the file system directly, of course, Kitten does come with a built-in database that you can use via pure JavaScript.

e.g,

kitten.db.entries = [
{ name: 'Aral’, site: 'aralbalkan.com' },
{ name: 'Laura', site: 'laurakalbag.com' }
]
kitten.db.entries[0].site = 'ar.al'

That’s valid Kitten code that persists an array of entries and then updates one (again, automatically persisting the change to an append-only JavaScript log).

aral,
@aral@mastodon.ar.al avatar

@cvennevik (Behind the magic is the built-in JSDB database exposed via the kitten.db global: https://codeberg.org/small-tech/jsdb)

cvennevik,
@cvennevik@hachyderm.io avatar

@aral I'm planning on storing the data in a plain JSON file, so I can easily sync it between devices and potentially create new (non-JavaScript?) apps to work with it!

aral,
@aral@mastodon.ar.al avatar

@cvennevik Makes sense. You could always use the internal database to make updates easy and then store a JSON serialised copy into a file for portability.

(Much easier than persisting JSON updates manually.)

e.g., see https://codeberg.org/aral/gists/src/branch/main/kitten-export-json.md

aral,
@aral@mastodon.ar.al avatar

@cvennevik In fact, come to think of it, you don’t even have to save the JSON file. You can just have a route that runs the JSON.stringify and returns the JSON.

aral,
@aral@mastodon.ar.al avatar

@cvennevik …And, in case you do decide to go this route, to make it easier for you, I just added .json() and .jsonFile() response helpers to the response objects passed to Kitten routes :)

Example: https://codeberg.org/aral/gists/src/branch/main/kitten-return-json.md

(If you already have Kitten installed, please update it using kitten update to get the new methods.)

Best of luck with your project no matter what you end up using :)

:kitten: 💕

#Kitten #SmallWeb #json #jsonFile #response #helpers #JavaScript #web #dev

  • All
  • Subscribed
  • Moderated
  • Favorites
  • webdev
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines