Saturday, 6 May 2017

What is the best way to run npm packages in demand as mircoservices without installing it locally?

Let's say I have these npm packages published to npm: service1@v1.0 service1@v2.0 service2@v1.0 each package has a single function:

function run(extraStr) {
  return 'package_name_and_version' + extraStr; // i.e. service1 v1.0 extraStr
}

And I want to write nodejs code that use the packages without installing it locally

var server = require("my-server-sdk");
  // get(package_name, version, function_in_package, arguments, callback)
  server.get('service1', '2.0', 'run', ['app1'], (err, result) => {
  console.log(result); // this should print service1 v2.0 app1
});

where my-server-sdk is an sdk that interface with my server's api where it install the required packages and cache it for later use. What is the best way to do that? what the security concerns and how to prevent any?

NOTE: service1@v1.0 service1@v2.0 service2@v1.0 are just examples to any packages in npm i.e. lodash



via Divoo

No comments:

Post a Comment