Skip to content

Commit c3e1705

Browse files
committed
missing files
1 parent d19de76 commit c3e1705

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

src/service/endpoint-runner.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

src/service/irunner.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

src/service/middleware-runner.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)