mscp
TBD!
Last updated 6 months ago by palantus .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mscp 
SYNC missed versions from official npm registry.

MSCP: MicroService Communication Platform

TBD!

Sample server/client

const MSCP = require("mscp");
const Handler = require("./handler.js");
const path = require("path");

(async () => {
  let mscp = new MSCP(Handler)
  mscp.server.static(path.join(__dirname, 'www'));
  mscp.start();
})()

The handler constructor argument for MSCP can be either a single class (no namespaces) or an object. If it is an object, then it maps namespaces to handler classes. The root handler is "".

In your handler, you can access the context of the current reqest using the properties:

  • this.mscp: reference to mscp class
  • this.definition: reference to the definition.json file parsed as an object
  • this.global: An empty object that is the same between requests
  • this.request = An object containing path (url path of request), data (all url/post parameters) and req (express req object - has mscp.ip and mscp.accessKey)

Sample browser client:

<script src="/mscp/js/browser.js"></script>
<script src="/mscp/js/jquery.min.js"></script>
<script>
$(function() {
  mscp.ready.then(myFunction)
});

async function myFunction(){
  let value = await mscp.getValue("123")
  console.log(value)
}
</script>

Requirements

You need note 7+ and (if version < 8) the node flag --harmony-async-await. For the browser client, you need Chrome 56 or Firefox 52 (for async/await).

Setup parameters

  • trustProxy: Instructs Express to trust the proxy that sent the request. Only use, when you are behind a proxy that you trust.
  • useForwardedHeader: If set to true, then the security module will check the headers for 'x-forwarded-for' header to get the IP of the client, instead of the proxy server. Only use this, if you are behind a proxy that sets this variable.
  • useRealIPHeader: If set to true, then the security module will check the headers for 'x-real-ip' header to get the IP of the client, instead of the proxy server. Only use this, if you are behind a proxy that sets this variable.

Sample simple UI

TBD

Sample UI Setup, with a single function as entry:

{
  "apps": {
    "": {"title": "Starter", "items": ["services", "kill", "log"], "defaultIndex": 0, "showMenu": false}
  },
  "items": {
    "services": {
      "title":" List services",
      "autorun": true,
      "actions":{
        "<row>": [
          {"call": "log", "title": "View log", "args": {"name": "active.name"}},
          {"call": "setup", "title": "Show setup", "args": {"name": "active.name"}},
          {"call": "gitpull", "title": "Execute: git pull", "args": {"name": "active.name"}, "ui": "notify-result", "notifytimeout": 7000},
          {"call": "npminstall", "title": "Execute: npm install", "args": {"name": "active.name"}, "ui": "notify-result", "notifytimeout": 7000},
          {"call": "kill", "title": "Force stop", "args": {"name": "active.name"}, "ui": "notify-result"},
          {"call": "enableService", "title": "Enable", "args": {"name": "active.name"}, "ui": "notify-result", "rerunParentAfter": true},
          {"call": "disableService", "title": "Disable", "args": {"name": "active.name"}, "ui": "notify-result", "rerunParentAfter": true},
          {"type": "link", "url": "<curhostnoport>:<active.http_port>/mscp", "title": "Open: MSCP Setup"},
          {"type": "link", "url": "<curhostnoport>:<active.http_port>/api/browse", "title": "Open: API Browser"},
          {"type": "link", "url": "<curhostnoport>:<active.http_port>", "title": "Open: Root"}
        ],
        "": [
          {"type": "link", "item": "services", "title": "Refresh"}
        ]
      }
    },
    "log": {"title":"Get log"},
    "kill": {"title":"Restart service"}
  }
}

Reserved URL parameters:

  • accessKey: used when securing (som parts of) the server with access keys
  • responseType: can be used to set response type to XML instead of JSON

CORS

You can enable CORS by setting ''allowedOrigins'' in ''setup.json'' to the domains that should be allowed. It supports regexps.

Access keys

Access keys expire every 18 days by default, but can be extended by setting ''accessKeyExpirationDays'' in setup.json.

Depend on download function

You can access the file if you call a download function dependency like this:

let file = await this.mscp.files.download.call(this, "123")
file.toBuffer().toString()

Current Tags

  • 1.3.4                                ...           latest (6 months ago)

119 Versions

  • 1.3.4                                ...           6 months ago
  • 1.3.2                                ...           6 months ago
  • 1.3.1                                ...           6 months ago
  • 1.3.0                                ...           6 months ago
  • 1.2.99                                ...           6 months ago
  • 1.2.98                                ...           6 months ago
  • 1.2.97                                ...           7 months ago
  • 1.2.96                                ...           7 months ago
  • 1.2.95                                ...           8 months ago
  • 1.2.94                                ...           9 months ago
  • 1.2.93                                ...           a year ago
  • 1.2.92                                ...           a year ago
  • 1.2.91                                ...           a year ago
  • 1.2.90                                ...           a year ago
  • 1.2.89                                ...           a year ago
  • 1.2.88                                ...           a year ago
  • 1.2.87                                ...           a year ago
  • 1.2.86                                ...           a year ago
  • 1.2.85                                ...           a year ago
  • 1.2.84                                ...           a year ago
  • 1.2.83                                ...           a year ago
  • 1.2.82                                ...           a year ago
  • 1.2.81                                ...           a year ago
  • 1.2.80                                ...           a year ago
  • 1.2.79                                ...           2 years ago
  • 1.2.78                                ...           2 years ago
  • 1.2.77                                ...           2 years ago
  • 1.2.76                                ...           2 years ago
  • 1.2.75                                ...           2 years ago
  • 1.2.74                                ...           2 years ago
  • 1.2.73                                ...           2 years ago
  • 1.2.72                                ...           2 years ago
  • 1.2.71                                ...           2 years ago
  • 1.2.70                                ...           2 years ago
  • 1.2.69                                ...           2 years ago
  • 1.2.68                                ...           2 years ago
  • 1.2.67                                ...           2 years ago
  • 1.2.66                                ...           2 years ago
  • 1.2.65                                ...           2 years ago
  • 1.2.64                                ...           2 years ago
  • 1.2.63                                ...           2 years ago
  • 1.2.61                                ...           2 years ago
  • 1.2.60                                ...           2 years ago
  • 1.2.59                                ...           2 years ago
  • 1.2.58                                ...           2 years ago
  • 1.2.57                                ...           2 years ago
  • 1.2.56                                ...           2 years ago
  • 1.2.55                                ...           2 years ago
  • 1.2.54                                ...           2 years ago
  • 1.2.53                                ...           2 years ago
  • 1.2.52                                ...           2 years ago
  • 1.2.51                                ...           2 years ago
  • 1.2.50                                ...           2 years ago
  • 1.2.48                                ...           2 years ago
  • 1.2.47                                ...           2 years ago
  • 1.2.46                                ...           2 years ago
  • 1.2.45                                ...           2 years ago
  • 1.2.44                                ...           2 years ago
  • 1.2.43                                ...           2 years ago
  • 1.2.42                                ...           2 years ago
  • 1.2.41                                ...           2 years ago
  • 1.2.40                                ...           2 years ago
  • 1.2.39                                ...           2 years ago
  • 1.2.38                                ...           2 years ago
  • 1.2.37                                ...           2 years ago
  • 1.2.36                                ...           2 years ago
  • 1.2.35                                ...           2 years ago
  • 1.2.34                                ...           2 years ago
  • 1.2.33                                ...           2 years ago
  • 1.2.32                                ...           2 years ago
  • 1.2.31                                ...           2 years ago
  • 1.2.30                                ...           2 years ago
  • 1.2.29                                ...           2 years ago
  • 1.2.28                                ...           3 years ago
  • 1.2.27                                ...           3 years ago
  • 1.2.26                                ...           3 years ago
  • 1.2.25                                ...           3 years ago
  • 1.2.24                                ...           3 years ago
  • 1.2.23                                ...           3 years ago
  • 1.2.22                                ...           3 years ago
  • 1.2.21                                ...           3 years ago
  • 1.2.19                                ...           3 years ago
  • 1.2.18                                ...           3 years ago
  • 1.2.16                                ...           3 years ago
  • 1.2.15                                ...           3 years ago
  • 1.2.14                                ...           3 years ago
  • 1.2.13                                ...           3 years ago
  • 1.2.12                                ...           3 years ago
  • 1.2.11                                ...           3 years ago
  • 1.2.10                                ...           3 years ago
  • 1.2.9                                ...           3 years ago
  • 1.2.8                                ...           3 years ago
  • 1.2.7                                ...           3 years ago
  • 1.2.6                                ...           3 years ago
  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.8                                ...           3 years ago
  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.5                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 122
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |