Express meets RxJS. Let's start reactive server with tyrannosaurus!
$ npm install rxpressive
THIS PACKAGE IS NOW UNDER DEVELOPMENT. APIs are not completed and subject to change.
Basically, this framework uses server framework Express and reactive library RxJS. If you are not familiar with those framework/library, I recommend you to read documents about them first.
For ES6 user (or for babel user)
const rxpressive = require('rxpressive');
const app = rxpressive();
app.get('/').subscribe(({ req, res }) => {
res.send('Hello World!');
});
app.listen(3000).subscribe(() => {});
For ES5 or lesser version user
var rxpressive = require('rxpressive');
var app = rxpressive();
app.get('/').subscribe(function(rxpressive) {
rxpressive.res.send('Hello World!');
});
app.listen(3000).subscribe(function () {});
-
All http verbs supported by express. There are few examples on following.
- GET
var rxpressive = require('rxpressive'); var app = rxpressive(); app.get('/').subscribe(function(rxpressive) { rxpressive.res.send('Hello World!'); }); app.listen(3000).subscribe(() => {});
- POST with application/x-www-form-urlencoded data
var rxpressive = require('rxpressive'); var bodyParser = require('body-parser'); var app = rxpressive(); app.use(bodyParser.urlencoded({ extended: false })) .subscribe(function(rxpressive) { rxpressive.next(); }); app.post('/').subscribe(function(rxpressive) { console.log(rxpressive.req.body); rxpressive.res.send('posted'); });