Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-bigpipe
Advanced tools
bigpipe for nodejs,express,sails,thinkjs,node-web,modular bigpipe for node
start
, pipe
, end
Promise
, easy to writenpm install node-bigpipe --save-dev
]import {Bigpipe} from 'node-bigpipe'
or import {Bigpipe} from './back-end/Bigpipe'
var Bigpipe = require('node-bigpipe').Bigpipe
or var Bigpipe = require('./back-end/Bigpipe.es5')
jQuery
and mo.bigpipe.es5.js
files in your htmlBigpipe
API of Backendstart
api to ouput the pipe and render the unclosed base html framepipe
api to transport to browser the array composed by pipe blocks you createdend
api to finish this bigpipebigpipe.start(viewPath, [data])
: Start renderbigpipe.pipe(promiseList)
:transport the pipebigpipe.end([onEndFn])
: Stop and finish the pipebigpipe.render(selector, htmlData)
: Similar with $(selector).html(htmlData)
, set the dom html contentbigpipe.append(selector, htmlData)
: Similar with $(selector).append(htmlData)
, append the dom element contentbigpipe.fire(eventName, data)
: Trigger the event which subscribed in Front End. The event should is used to deal with the data transported by bigpipe. You can use on
api to subscribe the event.bigpipe.on(eventName).then(data=>{ // deal with data ... })
: Subscribe the eventName and you can use then
to add callback
fnbigpie.fire/render/append
Set the dom content, Same with mentioned above in Backend API.The implementation will be put into the tagPipe, bp
function tagPipe(bp){
return new Promise((resolve, reject)=>{
let rdata = {
'tag': 'your data'
}
// simulate the asynchronous response
setTimeout(()=>{
let html = '<div><span>TagA</span><span>TagB</span><span>TagC</span><span>TagD</span></div>'
let pipeData = {
'html': html,
'message': 'for tag pipe html'
'css': ['a.css'],
'js': ['b.js'],
}
//
bp.fire('tag', pipeData)
resolve()
}, 3000)
})
}
```
- In view controller, start the pipe
````Javascript
index (req, res, next, page=1){
let bp = new Bigpipe('karatBP', req, res)
/**
* bp.start will put the _bigpipe_id into the template `data`。
* So Front End can get the id just by `new Bigpipe('{{_bigpipe_id}}')`
* The Object is global in browser
*/
bp.start('view/home')
.pipe([
articlePipe,
tagPipe,
// other ...
])
.end()
},
```
- Front End
````Html
<script type="text/javascript">
// this method will automatically export a object `karatBP` in window, and the `_bigpipe_id` shoud match the definition in backend
new Bigpipe('karatBP')
// you can also get the `_bigpipe_id` from data which has been mixed by Bigpipe:
// new Bigpipe('{{_bigpipe_id}}')
</script>
```
- Full backend code TestController.js:
````Javascript
function tagPipe(bp){
return new Promise((resolve, reject)=>{
let rdata = {
'tag': 'your data'
}
// simulate the asynchronous response
setTimeout(()=>{
let html = '<div><span>TagA</span><span>TagB</span><span>TagC</span><span>TagD</span></div>'
let pipeData = {
'html': html,
'message': 'for tag pipe html'
'css': ['a.css'],
'js': ['b.js'],
}
// here the `tag` match the event in front end.
bp.fire('tag', pipeData)
resolve()
}, 3000)
})
}
function articlePipe(bp){
return new Promise((resolve, reject)=>{
let rdata = {
'article': 'your data'
}
bp.res.render('view/article', rdata, (err, html)=>{
bp.render('.wrap > .content', html)
resolve()
})
})
}
// here the `index` fn should be bound in router so it can be views by url
export default {
index (req, res, next, page=1){
let bp = new Bigpipe('karatBP', req, res)
bp.start('view/home')
.pipe([
articlePipe,
tagPipe,
// other ...
])
.end()
},
}
```
- Full front end code
````HTML
<script type="text/javascript" src="/static/jquery.min.js"></script>
<script type="text/javascript" src="/static/mo.bigpipe.es5.js"></script>
<script type="text/javascript">
new Bigpipe('karatBP')
// subscribe the events which match the backend API `fire`, like fire('tag', data)
karatBP.on('tag')
.then(function (data) {
var pipeData = JSON.parse(data)
console.log(pipeData.message)
$('#tag').html(pipeData.html)
})
</script>
```
### Support for ThinkJS
Difference of usage in Backend:
* Put an additional param `this` into `new Bigpipe()`, like `new Bigpipe('xxxBP', http.req, http.res, this)`
* Other API is the SAME
* More About ThinkJS: [https://thinkjs.org](https://thinkjs.org)
````Javascript
export default class extends Base {
indexAction(){
let http = this.http;
// Put an additional param: `this`
let bp = new Bigpipe('thinkBP', http.req, http.res, this)
// `start` method use default ThinkJS template path: index.html
// other API usage is the same
bp.start() // or bp.sart('xxx')
.pipe([
tagPipe,
testPipe
// other ...
])
.end()
}
}
```
### ES6 Version
- The default used file is `back-end/Bigpipe.es5.js` which is ES5
- If you want use the ES6 version ,just modify the `package.json` in node-bigpipe dir, and modify the `"main": "back-end/Bigpipe.es5.js",` into `"main": "back-end/Bigpipe.js",`
### Readme
View full demo code in this github repo files.
FAQs
bigpipe for nodejs,express,sails,thinkjs,node-web,modular bigpipe for Node
The npm package node-bigpipe receives a total of 4 weekly downloads. As such, node-bigpipe popularity was classified as not popular.
We found that node-bigpipe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.