Directus 9 : sample NodeJS scripts?
-
I'm developing a small app for a society.
Currently favouring Budibase because it has front-end and back-end and app designer.
But keen to explore how Directus could handle the same project.Installed custom Directus 9 as a Cloudron app (thanks to @atrilahiji)
I'll think about front-end for Directus app later.
Fo now I want to prove out the storing and retrieval of data in/from Directus.But not finding any suitable example NodeJS scripts.
Yes, I have read Directus Docs. But no 'tutorial' for noobs like me.
Does anyone have any pointers ? -
@timconsidine can you describe what you're trying to do, in terms of the app?
-
@robi At this stage, I'm just scaffolding a simple command line CRUD script to prove connection to the hosted Directus.
I've managed to craft a bare-bones script for create and read (in case it helps any other noob).
import { Directus } from '@directus/sdk'; const directus = new Directus('https://domain/'); await directus.auth.static('static_token'); const test = directus.items('test'); await test.createOne({ status: 'draft', name: 'Jo', age: 20, points: 5, }); const tests = await directus.items('test').readMany(); console.log({ items: tests.data, // total: tests.meta.total_count, });
The "total: tests.meta.total_count" is straight from web docs, but doesn't work, so investigating. Probably my error as usual.
So now I know calls to Directus work fairly easy.
I guess where my knowledge is failing (apart from this being the very first Node script I've done) is linking CRUD functions to a front-end. But I will keep looking.The intended app is also v.simple.
- Users self-register
- Users login
- User then views available events
- User registers for event and buys tickets to event (probably handle that through a Stripe call)
- Email ticket confirmation and receipt to user
- User can reset their password
I guess I will figure out, just always prefer to use a library or framework for the heavy lifting and reduce scope for errors in my DIY coding.
-
@timconsidine ah, let's see what @marcusquinn thinks about that, as he's been using EspoCRM for similar things.
-
@timconsidine ah so you’re working on auth. I haven’t done any auth stuff in there yet but I can give it a shot at some point here. As for that script, idk I haven’t used their SDK ever. My use case involved publicly readable data so I just make a basic get request to there using the axios library