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

code-rag-sdk

v1.1.0

Published

An amazing SDK connector for APIed-Piper

Downloads

65

Readme

Code Rag SDK

An amazing SDK connector client for APIed-Piper.

If you want to install APIed-Piper visit npm APIed-Piper docs

Install

NodeJs

npm install code-rag-sdk

WEB


<body>
... your code here

<!-- from github raw cdn  -->
<script src="https://raw.githubusercontent.com/leganux/code-rag-sdk/main/index.js"></script>

<!-- or from local  -->
<script src="path/to/code-rag/index.js"></script>
</body>

Initialize and run


let f_error = async function (e) {
    console.error('An error has been occurred', e)
}

let options = {
    engine: "axios", // defualt fetch, please usae axios if you execute from node
    f_error: f_error // default request function in case of  HTTP error
}

/** Only NodeJS */
let codeRagSdk = require('code-rag-sdk')

/** NodeJS and WEB */

let uri = 'http://localhost:3000/' //Base uri of APIed-Piper project
let base_path = 'apiv2/' //base path of APIed-Piper project

let api_rest = new codeRagSdk(uri, base_path, options)

let main = async function () {
    // the first method you must to execute is the discover
    await api_rest.discover()

}
main()

Methods

LOGIN

This method allows you to login system and add config to localStorage if you prefer

let password = 'Meinertzhagens-Haversack'
let user = 'Jared'
let allow_save_localstorage = false // default true .allows save token  in localstorage

let login = await api_rest.login(password, user, allow_save_localstorage);

verify

This method allows you verify login and set in local storage the user data

let token = '0aidkjw9823ewajdw9832ebjdskndsjke93oue93.....'

let verify = await api_rest.verify(token); //will take from localstorage

Register

This method allows you to create new user

let user = {
    user: 'erick',
    pass: 'sZon03939jjd$%',
    email: '[email protected]'
}

let role = 'User'
let register = await api_rest.register(role, user); //will take from localstorage

Forgot Password

This method allows you to send mail for recovery password

let email = '[email protected]'

let forgotPassword = await api_rest.forgotPassword(user); 

New Password

This method allows you assign new password after email

let email = '[email protected]'
let password = 'sZon03939jjd$%'
let password2 = 'sZon03939jjd$%'
let ChangeCode = '9832ye9ndw903urwnsdlk390' // you can find this in the email you recieve

let forgotPassword = await api_rest.forgotPassword(email, password, password2, ChangeCode); 

logout

This method remove config of login

let login = await api_rest.logout();

resourceAccess

This method returns the allowed resource access configured in APIed-Piper

let access = await api_rest.resourceAccess()

Stats

This method returns the server info and count model from server of APIed-Piper extend config

let access = await api_rest.stats()

setResource

This method chooses the route model app where is working with, could be single or with some of the actions of crud

//single
api_rest.setResource('classmate')
// an then operation
let access = await api_rest.getMany()


//with operation
let access = await api_rest.setResource('classmate').getmany()

Method Queries

createOne

This method allows you to create a new element in selected resource

  • params
    • body:object = The element to save
    • query: {some options to see which fields return and populates }
let data = await api_rest.createOne({object}, {query})

createMany

This method allows you to create a new elements in selected resource

  • params
    • body:[object] = The array of elements to save
    • query: {some options to see which fields return and populates }
let data = await api_rest.createMany([array objects], {query})

getMany

This method allows you to get elements from a resource

  • params
    • query: {some options to see which fields return where and populates }
let data = await api_rest.getMany({query})

getOneWhere

This method allows you to get one element from a resource

  • params
    • query: {some options to see which fields return where and populates }
let data = await api_rest.getOneWhere({query})

getOneById

This method allows you to get one element from a resource

  • params
    • id: id of an element
    • query: {some options to see which fields return where and populates }
let data = await api_rest.getOneById(id, {query})

findUpdateOrCreate

This method allows you to get one element and update or create if not exists

  • params
    • body: element to create
    • query: {some options to see which fields return where and populates }
let data = await api_rest.findUpdateOrCreate({object}, {query})

findUpdate

This method allows you to get one element and update but not create if not exists

  • params
    • body: element to create
    • query: {some options to see which fields return where and populates }
let data = await api_rest.findUpdate({object}, {query})

updateById

This method allows you to get one element by id and update

  • params
    • id: element ide to find
    • body: fields to edit
    • query: {some options to see which fields return where and populates }
let data = await api_rest.updateById(id, {object}, {query})

findIdAndDelete

This method allows you to delete one element by id

  • params
    • id: element ide to find
    • query: {some options to see which fields return where and populates }
let data = await api_rest.findIdAndDelete(ids, {query})

datatableAJAX

This method allows you to get the config for ajax datatable

  • params
    • id: element ide to find
    • query: {some options to see which fields return where and populates }
let data = await api_rest.datatableAJAX()

Object request query URL example

where

let where = {
    name: 'erick',
    age: 30
}

whereObject

let whereObject = {
    user_id: ObjectId('60e243c82b4d320571d00639'),
}

like

let like = {
    name: {$regex: 'eri', $options: 'i'},
}

paginate

let paginate = {
    page: 1,
    limit: 10
}

sort

let sort = {
    name: "DESC",
    age: "ASC"
}

select

let select = {
    name: 1,
    age: 1,
    location: 0,
}

populate

let populate = {
    class: 1,
    kind: 1,
    users: 0,
}