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

para-client-js

v1.39.3

Published

JavaScript Client for Para

Downloads

251

Readme

Logo

JavaScript Client for Para

npm version Join the chat at https://gitter.im/Erudika/para

What is this?

Para was designed as a simple and modular backend framework for object persistence and retrieval. It helps you build applications faster by taking care of the backend. It works on three levels - objects are stored in a NoSQL data store or any old relational database, then automatically indexed by a search engine and finally, cached.

This is the JavaScript client for Para.

Quick start

$ npm install para-client-js --save

Usage

Initialize the client in your code like so:

import { ParaClient } from 'para-client-js';
var pc = new ParaClient('ACCESS_KEY', 'SECRET_KEY');

If your code runs in a browser environment, you should use a blank secret key and then call signIn():

pc.signIn("password", "{email}::{password}", function(user) {
  // do something with the newly created user
});

It's a bad idea to hardcode your Para secret key in your code because it will run in an insecure client-side environment. Instead use the signIn() method to get an access token (JWT) with limited client permissions. Think of it like this: API key+secret = full API access, paraClient.signIn() = limited API access for clients with JWT tokens. You can have a special user object created just for your JS app and assign it special permissions so that your app can access a part of the Para API before authenticating another real user. Read the documentation for more information about client permissions. For granting resource permissions to your client users go to console.paraio.org where you can edit your app object and allow your users the call specific API methods.

Browser usage

To use para-client-js in the browser run:

$ npm install
$ npm run build

This will generate a "bundle.js" file which you can use inside your HTML code:

<html>
  <head>
    <script src="bundle.js"></script>
  </head>
  <body>
    <script>
      var ParaClient = require('para-client-js');
      var pc = new ParaClient('ACCESS_KEY', 'SECRET_KEY');
    </script>
  </body>
</html>

Promises and callbacks

All methods return a promise object and also accept a callback function as last parameter. You can choose to either use callbacks or promises. For example:

// using promises
pc.read("user", "1234").then(function (user) {
	// do something with user object
}, function (err) {
	// request failed
});

// using callbacks
pc.read("user", "1234", function (user, err) {
	// do something with user object
});

Documentation

Read the Docs

Contributing

  1. Fork this repository and clone the fork to your machine
  2. Create a branch (git checkout -b my-new-feature)
  3. Implement a new feature or fix a bug and add some tests
  4. Commit your changes (git commit -am 'Added a new feature')
  5. Push the branch to your fork on GitHub (git push origin my-new-feature)
  6. Create new Pull Request from your fork

For more information see CONTRIBUTING.md

License

Apache 2.0