File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ const IRunner = require ( './irunner' )
2+
3+ const EndpointInfoSandbox = require ( '../sandbox/endpoint-info-sandbox' )
4+ const MiddlewareExecSandbox = require ( '../sandbox/middleware-exec-sandbox' )
5+
6+ class EndpointRunner extends IRunner {
7+ constructor ( code ) {
8+ super ( {
9+ info : new EndpointInfoSandbox ( code ) ,
10+ exec : new MiddlewareExecSandbox ( code ) ,
11+ start : new MiddlewareExecSandbox ( code , 'start' )
12+ } )
13+ }
14+ }
15+
16+ module . exports = EndpointRunner
Original file line number Diff line number Diff line change 1+ const Hoek = require ( '@hapi/hoek' )
2+ const debug = require ( 'debug' ) ( 'dataparty.irunner' )
3+
4+ class IRunner {
5+ constructor ( { info, exec, start} ) {
6+ this . sandboxes = {
7+ info, exec, start
8+ }
9+ }
10+
11+ get info ( ) {
12+ return Hoek . reach ( this . sandboxes , 'info.info' )
13+ }
14+
15+ async getInfo ( ) {
16+ if ( ! this . sandboxes . info . info ) {
17+ await this . sandboxes . info . run ( )
18+ }
19+
20+ return this . sandboxes . info . info
21+ }
22+
23+ async start ( serviceContext ) {
24+ debug ( 'start' )
25+ return await this . sandboxes . start . run ( serviceContext )
26+ }
27+
28+ async run ( context ) {
29+ debug ( 'run' )
30+ return await this . sandboxes . exec . run ( context )
31+ }
32+
33+ self ( ) {
34+ return this
35+ }
36+ }
37+
38+ module . exports = IRunner
Original file line number Diff line number Diff line change 1+ const IRunner = require ( './irunner' )
2+
3+ const MiddlewareInfoSandbox = require ( '../sandbox/middleware-info-sandbox' )
4+ const MiddlewareExecSandbox = require ( '../sandbox/middleware-exec-sandbox' )
5+
6+ class MiddlewareRunner extends IRunner {
7+ constructor ( code ) {
8+ super ( {
9+ info : new MiddlewareInfoSandbox ( code ) ,
10+ exec : new MiddlewareExecSandbox ( code ) ,
11+ start : new MiddlewareExecSandbox ( code , 'start' )
12+ } )
13+ }
14+ }
15+
16+ module . exports = MiddlewareRunner
You can’t perform that action at this time.
0 commit comments