imp(benchmarks): updated benchmarks to use current API
MODIFY
benchmarks/middlewares.js
benchmarks/middlewares.js
const http = require('http');
const { mapTo, filter } = require('rxjs/operators');
-const { httpListener, EffectFactory } = require('../packages/core/dist');
+const { bindTo, createContext, createServer, httpListener, r, registerAll, ServerClientToken } = require('../packages/core/dist');
const n = parseInt(process.env.MW || '1', 10);
-const root$ = EffectFactory
- .matchPath('/')
- .matchType('GET')
- .use(req$ => req$.pipe(
+const root$ = r.pipe(
+ r.matchPath('/'),
+ r.matchType('GET'),
+ r.useEffect(req$ => req$.pipe(
mapTo({ body: 'Hello World' })
- ));
+ )),
+);
const middlewares = [];
const effects = [root$];
@@ -18,7 +19,9 @@ for (let i = 0; i < n; i++) {
middlewares.push(req$ => req$);
}
-const app = httpListener({ middlewares, effects });
+const server = createServer({
+ port: 1337,
+ httpListener: httpListener({ effects, middlewares }),
+});
-console.log(` ${n} middlewares - Marble.js`);
-http.createServer(app).listen(1337);
+server().then(() => console.log(` ${n} middlewares - Marble.js`));

MODIFY
benchmarks/routing.js
benchmarks/routing.js
const http = require('http');
const { mapTo } = require('rxjs/operators');
-const { httpListener, EffectFactory } = require('../packages/core/dist');
+const { bindTo, createContext, createServer, httpListener, r, registerAll, ServerClientToken } = require('../packages/core/dist');
const n = parseInt(process.env.MW || '1', 10);
@@ -9,26 +9,31 @@ const effects = [];
for (let i = 0; i < n-1; i++) {
effects.push(
- EffectFactory
- .matchPath(`/test-${i}`)
- .matchType('GET')
- .use(r$ => r$.pipe(
- mapTo({ body: 'Hello World' })
- ))
+ r.pipe(
+ r.matchPath(`/test-${i}`),
+ r.matchType('GET'),
+ r.useEffect(r$ => r$.pipe(
+ mapTo({ body: 'Hello World' }),
+ )),
+ ),
);
}
effects.push(
- EffectFactory
- .matchPath(`/`)
- .matchType('GET')
- .use(r$ => r$.pipe(
- mapTo({ body: 'Hello World' })
- ))
+ r.pipe(
+ r.matchPath(`/`),
+ r.matchType('GET'),
+ r.useEffect(r$ => r$.pipe(
+ mapTo({ body: 'Hello World' }),
+ )),
+ ),
);
const app = httpListener({ middlewares, effects });
-console.log(` ${n} endpoints -- Marble.js`);
+const server = createServer({
+ port: 1337,
+ httpListener: httpListener({ middlewares, effects }),
+});
-http.createServer(app).listen(1337);
+server().then(() => console.log(` ${n} endpoints - Marble.js`));

imp(benchmarks): updated benchmarks to use current API