
Security News
Federal Audit Finds NIST Wasted Funds With No Plan to Clear NVD Backlog
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.
一个微服务(Microservices)被定义为一个JS类(Class)。
nodeway直接发布这个JS类,使浏览器或nodejs可以远程调用。
# npm install nodeway -g
# vi ~/.bash_profile
export NODE_PATH="/usr/local/lib/node_modules:/root/node_modules"
# vi ~/.bashrc
export NODE_PATH="/usr/local/lib/node_modules:/root/node_modules"
# nodeway
Usage: nodeway [options]
Options:
-h, --help output usage information
-V, --version output the version number
--class <class>[,<class>]* class list
--host <host> Listen ip or hostname, default '127.0.0.1'
--port <port> Listen port, default '80'
--docs [root] Httpd docs root, optional
--config <file> Config file
Prompt:
Either --class or --config must be one.
建立测试目录,在测试目录下创建'HelloWorld.js'微服务,内容如下:
const Nodeway = require("nodeway");
class HelloWorld extends Nodeway {
constructor(uuid) {
super(uuid);
}
async say(message) {
this.broadcast('data', `${message}(${Nodeway.onlineCount})`);
return new Promise(function(resolve, reject) {
resolve(message);
});
}
}
module.exports = HelloWorld;
# nodeway --config nodeway-helloworld/config.js &
编写浏览器调用微服务测试文件'index.html',内容如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HelloWorld</title>
<script type="text/javascript" src="/HelloWorld.js"></script>
</head>
<body>
<script>
let api = new HelloWorld;
api.on('data', message => document.write(message+'<br/>'));
setInterval(async function(api) {
try {
let message = await api.say('Hello Safari!');
document.write(message+'<br/>');
}
catch(e) {}
}, 6000, api);
</script>
</body>
</html>
在浏览器中访问'http://localhost:8080'进行测试。
编写nodejs调用微服务测试文件'test_from_nodejs.js',内容如下:
const requireFromUrl = require('require-from-url');
const readline = require('readline');
function main(HelloWorld) {
let api = new HelloWorld;
api.on('data', console.log);
readline.createInterface({
input: process.stdin,
output: process.stdout
})
.on('line', async function(line) {
try {
let message = await api.say(line.trim());
console.log(message);
}
catch(e) {}
})
.on('close', process.exit);
}
requireFromUrl(["http://localhost:8080/HelloWorld.js"], function(err, HelloWorld) {
if(!err) main(HelloWorld);
});
执行node test_from_nodejs.js进行测试。
你也可以用命令npm install nodeway_helloworld直接安装这个测试例子。
MIT © May xiaoya zhang
FAQs
nodeway microservices
The npm package nodeway receives a total of 11 weekly downloads. As such, nodeway popularity was classified as not popular.
We found that nodeway demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.