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

express-integrator-extension

v0.3.1

Published

Express based extension for Integrator.io

Downloads

5,380

Readme

express-integrator-extension

js-standard-style

This module extends integrator-extension and can be used to create an express app which exposes an API that is used by integrator.io to invoke the extension functions and get back the results. This extension type is based on the stack of type server in integrator.io. The baseURI for the API will be same as the hostURI of the stack and stack's systemToken is used to authenticate the requests made to the API. You can host the express app on a single server or a set of servers behind a load balancer to scale as needed.

Installation

Using npm:

$ npm i --save express-integrator-extension

Usage

var expressExtension = require('express-integrator-extension')

expressExtension.createServer(config, function (err) {

})

expressExtension.stopServer(function (err) {

})

createServer(config, callback)

createServer function loads the configuration and starts an express app. Given below are the configuration fields that can be set along with the fields mentioned in integrator-extension configuration.

port

Optional. This field specifies the port that should be used by the express server. Default port is 80.

systemToken

Required. This needs to be set to the stack's systemToken that you created in integrator.io.

maxSockets

Optional. This field is to customize the value for https.globalAgent.maxSockets. Default value is set to Infinity.

winstonInstance

Optional. This field is used to pass the winston instance which will be used to log information. By default logs go only to the console output.

stopServer(callback)

stopServer function stops the express app from listening on the designated port.

Getting Started

Given below are the complete steps to create a working Express based stack.

  1. Create a stack in integrator.io

  2. Login into integrator.io.

  3. Click on options field present at the top right corner and select stacks.

  4. Click on the New Stack button.

  5. Give an appropriate name for the stack.

  6. Select type as "Server".

  7. Set the "Host" field to the URI on which the project will be hosted on. Don't worry if the URI is not available at this time. You can come back and update the stack later!

  8. Click save to create the stack.

  9. You will be redirected to the stacks page. Please make note of the System Token by clicking on "click to display" under the System Token column corresponding to the stack which you have created.

  10. Write code

  11. Run "npm init" to create node project in a new folder.

  12. Run "npm i --save express-integrator-extension".

  13. Create a new file functions.js and save the following extension functions in it. ```js var obj = { hooks: { preSaveFunction: function (options, callback) { // your code }
    },

    wrappers: { pingFunction: function (options, callback) { // your code } } };

    module.exports = obj; ```

  14. Create a new file index.js and save the following code in it. Either the DIY or connectors configuration should be used.

    var expressExtension = require('express-integrator-extension');
    var functions = require('./functions');
    
    var systemToken = '************'; // Set this value to the systemToken of the stack created in integrator.io
    var options = {
      diy: functions,
      // connectors: { _connectorId: functions }, // for connectors
      systemToken: systemToken
    };
    
    expressExtension.createServer(options, function (err) {
    
    });
  15. Host the node project on a single server or a set of servers behind a load balancer to scale as needed. Any server based hosting environment like AWS EC2, AWS Opsworks, Rackspace Cloud, Google Cloud, Heroku, etc. can be used to run the code. Update the stack in integrator.io with the endpoint URI of your server or load balancer.

Now, the stack is ready for use and it can be referenced from appropriate exports, imports and connections. To maintain security, systemToken should be stored securely on your server environment. Please refer to best practices of the respective system that you chose to run the express app.