Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Cloudron Forum

Apps | Demo | Docs | Install

Directus 9 : sample NodeJS scripts?

Scheduled Pinned Locked Moved Directus
5 Posts 3 Posters 419 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • timconsidineT Offline
    timconsidineT Offline
    timconsidine App Dev
    wrote on last edited by timconsidine
    #1

    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 ?

    robiR 1 Reply Last reply
    0
  • robiR Offline
    robiR Offline
    robi
    replied to timconsidine on last edited by
    #2

    @timconsidine can you describe what you're trying to do, in terms of the app?

    Life of sky tech

    timconsidineT 1 Reply Last reply
    0
  • timconsidineT Offline
    timconsidineT Offline
    timconsidine App Dev
    replied to robi on last edited by
    #3

    @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.

    robiR ? 2 Replies Last reply
    0
  • robiR Offline
    robiR Offline
    robi
    replied to timconsidine on last edited by
    #4

    @timconsidine ah, let's see what @marcusquinn thinks about that, as he's been using EspoCRM for similar things.

    Life of sky tech

    1 Reply Last reply
    0
  • ? Offline
    ? Offline
    A Former User
    replied to timconsidine on last edited by
    #5

    @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

    1 Reply Last reply
    0

  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Login

  • Don't have an account? Register

  • Login or register to search.