I am working on a small web app that stores user data locally using indexedDB which can be imported/exported by making use of JSON files. Since I plan on adding updates to the site, I want to know what best practices I should follow to make sure my app can allow importing of user data from older versions. It could be related to how I should define the properties of my user data object to make it future proof, or any library or tool I could implement that would make this migration process easier.

Do keep these points in mind:

  1. I am using NextJS to build this application and Dexie to manage indexedDB
  2. Without going into details, the user data file makes use of heavily nested objects and arrays and most likely won’t fit in a cookie or even in the local storage API
  3. This web app acts as a proof of concept which must only make use of the aforementioned core technologies, regardless of whether more efficient alternatives exist or not.
  • expr
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    2 months ago

    Obligatory “JSON APIs are not REST because JSON is not hypermedia”.

    GraphQL is a mess too as you throw out any ability to reason about query performance and it still requires thick clients with complicated/duplicated business logic.

    If you’re doing RoR anyway, then go for https://htmx.org/. It’s much, much simpler and closer to how the web was originally designed. Highly recommend this book the author wrote on the subject (also provides tutorials walking through building an app): https://hypermedia.systems/book/contents/.

    • hosaka
      link
      fedilink
      arrow-up
      2
      ·
      2 months ago

      HTMX is great by I don’t think it’s what OP needs since the input and desired output is not hypermedia in the first place.

      • expr
        link
        fedilink
        arrow-up
        2
        ·
        2 months ago

        I was replying to someone talking about GraphQL and Ruby on rails, not the OP of this post.

      • expr
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        I don’t know what you mean by an API standard, but yes, it is technically a JavaScript library. But that’s only an implementation detail and the spirit of htmx is that you write very little JavaScript. Javascript is simply used to extend the HTML standard to support the full concept of hypermedia for interactive applications. An htmx-driven application embraces hypertext as the engine of application state, rather than the common thick client SPAs hitting data APIs. In such a model, clients are truly thin clients and very little logic of their own. Instead, view logic is driven by the server. It has been around for quite a long time and is very mature.

        It’s fundamentally different than most JavaScript libraries out there, which are focused on thick clients by and large.

        • Prison Mike@links.hackliberty.org
          link
          fedilink
          arrow-up
          1
          ·
          2 months ago

          I’m discussing APIs that can be consumed by others, not something for my frontend to use.

          My frontend uses Hotwire — I’m not using GraphQL as some Node.js guy writing the entire frontend in JavaScript.

          I think you’re discussing PWA technologies where I’m trying to talk about web APIs.

          • expr
            link
            fedilink
            arrow-up
            2
            ·
            1 month ago

            Ah I see, my bad. You mentioned Ruby on rails and GraphQL so I assumed you were talking about some kind of MPA situation.

            Yeah htmx doesn’t replace data APIs for sure. Still not a fan of GraphQL for that purpose for the reasons above. There’s a lot of good options for RPC stuff, or even better, you can use message queues. GraphQL is just a bad idea for production systems, IMO.

            • Prison Mike@links.hackliberty.org
              link
              fedilink
              arrow-up
              1
              ·
              1 month ago

              Yeah everyone says this then I look around at REST APIs (as a consumer and developer) and 99% are trash.

              I’m loving GraphQL mainly for “take only what you need” and type definitions. Every other standard I can find has some crummy gem, serializers that need to be hacked because they never work out of the box, etc.

              As soon as my experience changes maybe I’ll change my mind, but I’ve had to develop some REST APIs using Ruby and Rails and wasn’t happy. Meanwhile my side projects using GraphQL are just incredible, and I don’t want to kill myself after developing it.

              • expr
                link
                fedilink
                arrow-up
                1
                ·
                1 month ago

                I wasn’t suggesting making JSON “REST” APIs (not actually REST, more accurately you might call them JSON data APIs or something). I meant protocols that are specifically meant for RPC, like gRPC, JSON-RPC, etc. Or message queues like RabbitMQ.