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

jquery-rest-client

v0.3.7

Published

Minimal library for restful client based on jQuery Ajax. Include a semaphore that controls the execution of each session. The purpose of this library is to improve the integration with restfull server on the client side using jQuery Ajax based and a struc

Downloads

21

Readme

CupCoffeeJs jQuery Rest Client

Minimal library for restful client based on jQuery Ajax. Include a semaphore that controls the execution of each session. The purpose of this library is to improve the integration with restfull server on the client side using jQuery Ajax based and a structure that allows simulate an asynchronous architecture.

Install

bower install jquery-rest-client

npm install jquery-rest-client

What you should know to use

This library is being built to work with CupCoffee Js, specifically Cupcoffee Auth JWT, but should work perfect mind in any structure, follow these tips: The communication paths generated here are these standards:

Create / Insert / Post (value) [Method POST]

[url_api] / [controller] / [method]

Read / Get (method) Method GET

[url_api] / [controller] / [method] / [id]? Query = query & ...

Update (value) [Method Put]

[url_api] / [controller] / [method] / [id]

Delete (value) [Method Delete]

[url_api] / [controller] / [method] / [id]

Examples

    var rest = new $.RestClient('http://localhost:3000')
        rest.add('login') // http://localhost:3000/login
        rest.add('categories', 'api/categories')  //http://localhost:3000/api/categories
        rest.add('comments', 'api/comments') //http://localhost:3000/api/comments
        rest.add('posts', 'api/posts') ////http://localhost:3000/api/posts
        rest.add('users', 'api/users') ////http://localhost:3000/api/users

        rest.login.post({
            'username': "admin",
            "password": "123456"
        }).then(function(data) {
            rest.token(data.token, data.data.id);// Save x-access-token and x-key
            rest.release('login');
        })

        rest.wait('login')

        /*
            None of the sessions below will be performed unless "rest.release ('login')" is executed.
         */

        rest.users.read('find').query({
            'id': '1'
        }).then(function(data) {
            rest.release('user');
            console.log(data)
        })

        rest.categories.wait('post').update('category').data({
            title: 'news',
            id: '3'
        }).then(function(data) {
            rest.comments.delete(3).then(function(data){
                if(data == true){
                    alert('Comment deleted!')
                }
            })
        })

        //to url/api/user/add, use action method
        rest.posts.wait('user').action('add').create({title: 'Hello', content: "Word!"}).then(function(data) {
            rest.release('posts')
        })

In this example requests the following order: Read User -> Create Post -> Update Category -> Delete comments

Options

{
    "waitingTime": 300, //Waiting time
    "waitLoopLimit": 60, //Quantity connection attempts limit
    "logger": 0, // Log display (0 and 1 = all, 2 = only errors)
    "fnError": function(msg) { //Called when an error is declared
        //...
     },
    "setup": {} //jQuery Ajax configuration http://api.jquery.com/jquery.ajax/
}

Methods

c

  • .post, .insert and .create: Send data in the body of the request using the POST method.
  • .remove, .delete, .del and .destroy: Send a removal request with request to the url uses the DELETE method.
  • .update: Sends data in the header of the body using the PUT method.
  • .read, .get: Send a request to the URL using the GET method.
  • .custom: Receives an object with all the settings for a model.
  • .isGet: Sets the method to GET.
  • .isPost: Sets the method to POST.
  • .isPut: Sets the method to PUT.
  • .isDelete: Sets the method to DELETE.
  • .method: Defines a method to be used.
  • .headers: Apply a header to this model.
  • .defaultHeaders: Apply a standard header to all models.
  • .token: Save x-access-token and x-key.
  • .then: Execute and return the values in a callback, return $ .ajax.
  • .exec: Run the command without callback, return $ .ajax.
  • .error: Returns an error message for a callback.
  • setApi: Defines the API address.
  • .wait: Force the model or models below to wait the release of certain event.
  • .release: Releases waits.
  • action: Add values in the URL path to access methods (actions) server

If the method has not yet defined .query() is applied, the method will be set as "GET". If .data() is applied, the method will be set to "POST".