chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
32
packages/server/lib/plugin-helper.js
Normal file
32
packages/server/lib/plugin-helper.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const pluginCodes = {
|
||||
TICKER: 'ticker',
|
||||
EXCHANGE: 'exchange',
|
||||
WALLET: 'wallet',
|
||||
WALLET_SCORING: 'wallet-scoring',
|
||||
LAYER2: 'layer2',
|
||||
SMS: 'sms',
|
||||
EMAIL: 'email',
|
||||
ZERO_CONF: 'zero-conf',
|
||||
COMPLIANCE: 'compliance'
|
||||
}
|
||||
|
||||
module.exports = _.assign({load}, pluginCodes)
|
||||
|
||||
function load (type, pluginCode) {
|
||||
if (!_.includes(type, _.values(pluginCodes))) {
|
||||
throw new Error(`Unallowed plugin type: ${type}`)
|
||||
}
|
||||
|
||||
if (!pluginCode) throw new Error(`No plugin defined for ${type}`)
|
||||
|
||||
if (pluginCode.search(/[a-z0-9-]/) === -1) {
|
||||
throw new Error(`Unallowed plugin name: ${pluginCode}`)
|
||||
}
|
||||
|
||||
return require(`./plugins/${type}/${pluginCode}/${pluginCode}`)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue