New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-ark

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ark

A Node application creator about plugin architecture approach.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

node-ark

A Node application creator about plugin architecture approach.

Quick Example

Create your module with npm

mkdir -p plugins/myMainPackager
cd plugins/myMainPackager
npm init
touch index.js

Create a plugin plugins/myMainPackager/index.js

module.exports = function setup(imports, done) {
    imports.myValueExported = 123;

    done(); // call done when finish it
}

Your main.js script:

var ark = require('node-ark');

ark.create(["plugins/myMainPackager"], function (imports) {
    console.log("My application is running! All plugins are loaded");
})

Here is your package.json:

{
  "name": "myMainPackager",
  "version": "0.0.1",
  "description": "My Demo Application",
  "main": "index.js",
}

Dependencies

Edit the package.json from plugin that require the dependency.

{
    "name": "myMainPackager",
    "version": "0.0.1",
    "description": "My Demo Application",
    "main": "index.js",

    "plugin": {
      "requires": [
          "plugins/myAnotherPlugin"
      ]
    }
}

Create a new plugin

Create a new package.json:

{
    "name": "myAnotherPlugin",
    "version": "0.0.1",
    "description": "My Plugin",
    "main": "myPluginSetup.js"
}

Create the target plugin plugins/myAnotherPlugin/myPluginSetup.js:

module.exports = function setup(imports, done) {
    imports.shareThisObject = {
        name: "Amazing plugin system",
        run: function () {
            return this.name + " is running"
        }
    };

    done(); // call done when finish it
}

Then, from myMainPackager.js plugin you can do access the shared object:

module.exports = function setup(imports, done) {
    var sharedObject = imports.shareThisObject;

    console.log("Who is?", sharedObject.name);
    console.log("Do what?", sharedObject.run());

    done(); // call done when finish it
}

Keywords

node

FAQs

Package last updated on 02 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts