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

parse-server-jsreactor

v1.0.32

Published

> WARNING: this project is in BETA and under huge development

Downloads

2

Readme

WARNING: this project is in BETA

An flexible IFTTT-engine with generated gui. This is basically a wrapper for jsreactor.

Installation

npm install parse-server-jsreactor @coderofsalvation/jsreactor --save

then in your cloud-code entrypoint (cloud/index.js e.g.) add this:

// add the business rule engine (BRE) + channels
var BRE         = require('parse-server-jsreactor')
var Database    = require('parse-server-jsreactor/channel/Database')
var Input       = BRE.Channel.Input 

var bre = new BRE(Parse,{languages:['EN'],logConsole:true})

new Database({bre})
new Input({bre})

bre.init()

Then specify which (database) classes you want to expose to it:

Do yourself a favor and don't include the Rule-class (recursion:the universe will explode)

NOTE: All the Parse Config-variables are accessible (and refreshed when needed) in the channels thru the opts-variable. Therefore you could also move the languages:['EN']-array from the init-code here (so it can be updated outside of the code)

Running the BRE

This will pass {foo:1} into the BRE (channels)

var res = await Parse.Cloud.run('bre',{foo:1})

NOTE: set environment variable MEMOIZE_AGE=10000 to change database-call-cache for 10 seconds (getting roles, getting schemas) etc. (default is 15sec on production, 5sec on localhost)

What are Channels?

A channel is basically an object which describes triggers and/or actions. For example, Twilio (the smsservice) can be seen as a channel with triggers (receive sms) and actions (send sms)

search for jsreactor-channel on npm, and check the jsreactor docs on how to use them

Live-coding cloud functions

Setup a cloudfunction-trigger (with name foo e.g.), and add a javascript-action like so:

Parse.Cloud.on.foo = (req) => new Promise((resolve,reject) => {
  resolve({foo:123})
})

Extending the Rule-class

Feel free to just add columns from the Parse dashboard, as your used to. However, in case your user-interface is using jsonschema to generate itself, you might want to read along:

NOTE: during runtime this package automatically creates a Rule parseClass to store the rules. In case you want to add custom properties to that class then write your own adapter and pass it as new BRE(Parse,myAdapter) (Just copy the adapter-code from index.js and modify it)

Bear in mind that you probably want to patch the breGetSchema-endpoint to hint your custom fields to your frontend-app.

Forwarding the Parse-email-adapter to BRE

In case you want to enjoy editable sendgrid templates when using Parse's password reset feature, you can redirect all email to the BRE:

Just use this emailadapter when initializing Parse:

    verifyUserEmails:true,
    emailAdapter: require('parse-server-jsreactor').emailAdapter(),

NOTE: dont forget to run npm install jsreactor-channel-sendgrid and read its docs

Multi-tenant: Unique Rules per App

The Parse-object is a singleton by default. However, we can work around this to enable per-app Parse instances:

     Parse.initializeMulti = (appId, javascriptKey, masterKey, Parse) => {                                                       
		Object.keys(require.cache).forEach(function(key) { delete require.cache[key] })
        var _Parse = require('parse/node')
        _Parse.initialize( appId, javascriptKey, masterKey )
        _Parse.Cloud = Parse.Cloud                                                                                                
	    return _Parse
      }                                                                                                                   
      var init = async (app) => {
          // init globally
          Parse.initialize( app.appId, app.javascriptKey, app.masterKey ) // remember instance
			// but also 'fork' an instance
          Parse[ app.appId ] = Parse.initializeMulti( app.appId, app.javascriptKey, app.masterKey, Parse )
          Parse[ app.appId ].serverURL = app.serverURL
          ...
		  // use Parse[ app.appId ] from here to initialize BRE
	      var bre = new BRE(Parse[ app.appId ],{languages:['EN'],logConsole:true})
		
	  }

	  for( var i in apps ) await init(apps[i])