Directing Frustration

avatar
(Edited)

In PHP land there are quite a few powerful ORM's to choose from when it comes to dealing with databases. They provide enough abstraction for a person to feel really really smart.

Obviously, until you hit the Polymorphic relations... Then you feel like an idiot again, heck in Eloquent I am only just starting to grok effective use of pivots in many to many relations.

As much as I shy away from writing pure SQL and using PDO I have only understood more of the concepts by actually manually setting them up with my own SQL queries.

So I guess it is just the nature of learning.

Headless CMS-ishes

Directus came on my radar for the first time in one of my many attempts to avoid dealing with a DB. These attempts usually coincide with the start of any new project I can't slap on WordPress and tell people to fuck off.

The first time I tried to use it was when it was still based on PHP with MYSQL but to actually use it I had to go through API calls and I was not in the mood for that.

In my head I install it to Laravel and use the routes by just passing stuff, I don't recall but it was not that simple. So I called it a day.

Now I am mucking about more in Node.js world and guess who has rewritten their entire system in javascript?

Their port to Directus 9 coincided with when I started working on Dreemport so I was quite bummed when things were still a bit up in the air and I did not want to take the time again to efficiently integrate their API with Laravel (again).

In the end my Dreemport stack is just straight up LEMP with some Alpine.js sprinkled in.

I really wanted to use Svelte though, but the same thing, the projects on node.js are either fanboy stable or fragmented due to perpetual migration from legacy.

I actually did bite the bullet for a good month and dived into the shallow side of using a full node.js environment and Strapi.js, it sucked.

Yes, objectively Strapi sucked from my subjective point of view. It was the push I needed to just say screw all this wannabe nonsense I am going full LEMP... LEPP

Linux, Nginx, Postgresql and PHP.

Bot a good and bad decision really but the bad or more like tedious part is where Directus comes in, and anyway the bad is in every single application.

Interfacing with data is a hassle, writing forms suck and building a button for every stupid action to then do stuff becomes tedious.

Building out a framework from scratch to possibly just do that in a modular and intelligent fashion is beyond my abilities and patience level.

So I do find myself repeating tasks I wish I could sit down and automate and that will always come up against , "Ok but then I need a month" or whatnot.

For me, Directus solves this, by wrapping any DB up into a neat little admin and it is your choice to interface with it, update the db direct from say your PHP app but allow creation via the Directus admin and or to just use it as a simple overview of your data instead of dealing with stuff like PgAdmin.

Ontop of that it simplifies the question for me in Node.js specifically. What ORM should I use, what package makes life simpler for simple state management server side?

None, they all are pretty horrible and some even use react... In Node.js land these Popes of applications will recommend and push for fundamentally always fragmented systems. Things like storing state become a minefield of , "ok but which state?"

State, motherfucker. I said State! Store it!

Here is looking at you Pinia, stupid thing needs a plugin to actually persist.. It seems to me like persisting state should not be a feature but a bloody default when it comes to something like remembering if you took a dump or should still take a dump.

Then you get the flip-side where Vue decided by default a Fetch should persist... Basically that means it thinks for some reason I will be updating a form or route with exactly the same parameters and should always get the same error.

Then again I am slow so I admit there are fundamentals I miss in the same way a human rights activist misses dealing with issues of humans.

Hive and Directus

This is where it really clicked for me, and is currently tickling my taint in just the right way. I have been shying away from many things hive and automated because fundamentally I always want a store of sorts and I want to see things and update things but I do not want to build all those things.

Well Directus makes it easy to visually build out my DB and then I can just run a simple Node.js script to interface with Hive, grab settings and store data to the Directus API without much hassle.

I can then choose to slap a interface ontop of that DB on a separate site and provide user engagement with the Data.

Currently, that would be specifically a token manager and or comment bot. Think Poshtokens site or dividend display via Brofund or a Pizza Dash all can easily hook up their bot's data to Directus and have their sites provide that data visually to users via whatever login they like.

On top of that you can construct Multitenancy for multiples of such services and just use it as a personal control center.

So in simple terms I am happy I finally took the leap in fiddling with these things as there are quite a few Hive operations I need to continue building and keep integrating with Dreemport .

I could build it into my Laravel backend and tie it to my system but I think any Hive or similar headless integration does need to be independent and if I can make it a simple case of auto API for me to query no matter the service then that will give me proper separation of concerns.

Anyhow, just a few ideas on something I think is super useful compared to many most of my Node.js experiences to date.



0
0
0.000
0 comments