npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@avanda/avandajs

v0.2.5

Published

Avanda javascript client

Downloads

88

Readme

Avanda JSGA

Avanda Json Graph Api is a Json based graph API built on top of javascript and nodejs, this library lets you communicate with the backend controllers and functions

Installation

To install Avanda Json Graph Api, run:

$ npm i @avanda/avandajs // or yarn add @avanda/avandajs

Calling backend controller/Service function

To call and get response from backend function, you first have to import avanda json graph API

import Graph from "@avanda/avandajs";

then proceed to instantiating it

let user = await new Graph().service('User/get')

'User' in the .service() function is the controller class name you already created in the backend, 'get' is the function in the User controller(class), this could also be any function

you can now specify which column from user response you want

let user = await new Graph()
                .service('User/get')//ServiceName/MethodName
                .select("full_name","number_of_posts")//needed columns

you can now specify what type of request you want to send to it

let user = await new Graph()
                .service('User/get')//ServiceName/MethodName
                .select("full_name","number_of_posts")//needed columns
                .get()//get request will be sent to this function, this could be .post(), .delete() and so on

Nesting backend function calls

The real power of avanda json graph API comes from the fact that you can nest as many and as deep Graph instance you want, an example of a nested graph calls below

let blog = new Graph().service("Blog/getAll").as("posts")
let user = await new Graph()
                .service('User/get')
                .select("id","full_name","number_of_posts",blog)//Avanda will automatically link relative blog to their users so far blogs has a user_id in it's associated model's structure
                .get()

the code above will produce a response like this:

{
  "msg": "",
  "data": {
    "id":1,  
    "full_name": "aisha",
    "number_of_posts": 1,
    "posts": [{//all blog posts with user_id of 1
      "title":"hello world"
    }]
  },
  "status_code": 200
}

Add constraint clauses

Avanda avanda json graph API lets you add some constraints to limit the amount of data to fetch, below is an example of howto do that

let blog = new Graph().service("Blog/getAll")
let user = await new Graph()
                .service('User/get')
                .select(
                    "id",
                    "full_name",
                    "number_of_posts",
                    blog.as("posts")
                 )
                .where("number_of_posts").lessThan(10)
                .get()//gets only users with posts less than 10

Security at the back of your mind

while it is easier to just use the constraint clauses on the go, be sure you aren't giving user's access to too much by add additional constraints to the model associated to your Service/controller on the server side and also implementing necessary middleWares