Reshuffle Integration Framework .Reshuffle is a lightweight and open source integration framework. With Reshuffle you can build integrations, connect systems, and build workflows.
Reshuffle is a lightweight and open source integration framework. With Reshuffle you can build integrations, connect systems, and build workflows.
Here is a simple workflow that listens to a cron event that runs every 5 sec:
const {Reshuffle, CronService} = require('reshuffle');
const app = new Reshuffle();
const cronService = new CronService();
app.register(cronService);
app.when(cronService.on({'interval':5000}), (event) => {
console.log('Hello World!')
});
app.start();
At its core Reshuffle is an event-based engine. Very similar to programming with a web server, you just need to define a function that will be called when an event is triggered.
Events can be anything from a file change, S3 bucket update, a cron job timer, your own custom event, or even an HTTP call.
Here is an example of listening to a HTTP get event on /test, using the HTTP service:
const {Reshuffle, HttpService} = require('reshuffle');
const app = new Reshuffle();
const httpService = new HttpService();
app.register(httpService);
app.when(httpService.on({'method':'GET','path':'/test'}), (event) => {
event.res.end("Hello World!");
});
app.start(8000);
A service on({eventOptions}) method is kinda smart, and enables short-handing, so:
app.when(httpService.on({'method':'GET','path':'/test'}), (event) => {
event.res.end("Hello World!");
});
Is syntactically equivalent to:
httpService.on({'method':'GET','path':'/test'}).do((event) => {
event.res.end("Hello World!");
});
Note: Remember to add the app.register(service) prior to when(...) or on(...).
More examples can be found here [TBD]
A critical aspect of building integrations is configuring how to connect to different services we want to integrate with. With Reshuffle you can easily configure Service objects and inject them.
Let's expend the example above and send a message to a Slack, every time someone triggers the 'HTTP/GET/test' event:
const {Reshuffle, HttpService, SlackService} = require('reshuffle')
const app = new Reshuffle();
const connectionOptions = {
'APIToken':process.env.SLACK_AUTH_KEY,
'team':'ourTeam',
};
const httpService = new HttpService();
app.register(httpService);
// the 2nd parameter is used to identify the service later on
const slackService = new SlackService(connectionOptions, 'services/Slack');
app.register(slackService);
app.when(httpService.on({'method':'GET','path':'/test'}), (event) => {
event.getService('services/Slack')
.send('Somebody called this event!', '#reports');
})
app.start();
Service objects expose the API and Events that the external service (from a DB to an ERP) provides. You can specify an id when you register a service to the app with the register(service), providing a identifier in the service constructor, and then access that service using the getService(serviceId) method.
You noticed in the code sample that we provided important information on how to connect to the 3rd party system (in that case, Slack). Services are an easy way to separate the connection configuration from your code, configure a connection to a service once and use it anywhere.
You can use the Service object to take action on a remote service (such as adding a row to a CRM) and configure events that trigger when something happens in that system. We will show you how to do that in the next section.
A full list of Services, and how to create your own Service, can be found here [TBD]
As we saw, services are basically adapters that connect external systems, such as Slack, Database, CRM, or any other system. Services can be configured to emit a Reshuffle event, when a preconfigured thing happens in these systems.
Here is how you would configure a SlackService to listen to a message from Slack:
const {Reshuffle, SlackService} = require('reshuffle');
const app = new Reshuffle();
const connectionOptions = {
'APIToken':process.env.SLACK_AUTH_KEY,
'team':'ourTeam',
};
const slackService = new SlackService(connectionOptions, 'services/Slack');
app.register(slackService);
const eventOptions = {
'event_type':'new_message',
'channel':'C6646754636',
'type':'new_message'
};
app.when(slackService.on(eventOptions), (event) => {
event.getService('services/Slack').reply('Thank you for your message!');
})
app.start();
It is the responsibility of the SlackService to listen to the events in Slack and emit corresponding events in Reshuffle. Your code can listen to these events and run business logic.
As you can see, both the event creation and the business logic, use the same Service configuration. This makes configuration easier to manage.
A full list of events, and how to create your own event, can be found here [TBD]
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
If this is a brand new project, make sure to create a package.json
first with the npm init
command.
Installation is done using the npm install
command:
$ npm install reshuffle
Install the engine
$ npm install -g reshuffle
Copy the helloWorldHTTPExample.js
example from the example folder into your /tmp/foo.
Install dependencies:
$ npm install
$ node helloWorldHTTPExample
got to http://localhost:8000/test
Examples can be found in the /examples folder
Author: reshufflehq
Demo: https://reshuffle.com/
Source Code: https://github.com/reshufflehq/reshuffle
node-canvas is a Cairo-backed Canvas implementation for Node.js.
A decade has passed since initial release of the node.js, it has gained immense popularity. Read in this article, what is nodejs used for? Nodejs Use Cases.
A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.
Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...
The main goal of this blog is to explain the “Architecture of Nodejs” and to know how the Nodejs works behind the scenes. Generally, most of the server-side languages, like PHP, ASP.NET, Ruby, and including Nodejs follows multi-threaded architecture. That means for each client-side request initiates a new thread or even a new process.