-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
94 lines (76 loc) · 2.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const Aggregate = require('./src/domain/aggregate')
const Identity = require('./src/domain/identity')
const Reference = require('./src/domain/reference')
const Balance = require('./src/domain/balance')
const Ledger = require('./src/domain/ledger')
const Wallet = require('./src/wallet/wallet')
const Workspace = require('./src/infrastructure/workspace')
const Repository = require('./src/infrastructure/repository')
const Utils = require('./src/utils')
const ValueObject = require('./src/domain/value-object')
const Projector = require('./src/infrastructure/projector')
const CommandHandler = require('./src/infrastructure/command-handler')
const { Pagination, paginationResolvers } = require('./pagination')
const NamespaceHandlerLocator = require('./src/infrastructure/bus-locator')
const BaseController = require('./src/rest/base')
const LoadRoutes = require('./src/rest/routes')
const Resource = require('./src/rest/Resource')
const collect = require('collect.js')
const Kernel = require('./src/app')
const RestAPI = require('./src/rest-api')
const Helper = require('./src/helper')
const aqp = require('./src/rest/query')
module.exports = {
Aggregate,
Identity,
Reference,
Balance,
Ledger,
Wallet,
Repository,
NamespaceHandlerLocator,
CommandHandler,
ValueObject,
Projector,
Workspace,
Pagination,
paginationResolvers,
Utils,
Kernel,
RestAPI,
Helper,
BaseController,
LoadRoutes,
aqp,
// Queue,
/**
* Router handlers, proxy for controllers
* Intersect method calls for `return` structure
*
* @param Handler
* @returns {*|void|never|*}
*/
makeHandler2: (handler) => {
const controller = new Proxy(handler, {
get (target, prop) {
const value = target[prop]
return (typeof value === 'function') ? new Proxy(value.bind(target), {
async apply(target, thisArg, args) {
const body = collect(args[0].request.body)
const withParams = body.merge(args[0].request.params)
const input = withParams.merge(args[0].request.query)
args[0].input = input
const result = await target.apply(thisArg, args)
if (result) {
return args[0].ok({
data: result
})
}
}
}) : value
}
})
return controller
},
Resource,
}