feat: decouple l-s entrypoint
This commit is contained in:
parent
2a2c1fccc8
commit
f4d6b5e454
48 changed files with 411 additions and 232 deletions
|
|
@ -4,12 +4,23 @@ const url = require('url')
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const util = require('util')
|
||||
const options = require('../options')
|
||||
const _ = require('lodash/fp')
|
||||
const logger = require('../logger')
|
||||
|
||||
const DOWNLOAD_DIR = path.resolve('/tmp')
|
||||
|
||||
const OFAC_DATA_DIR = process.env.OFAC_DATA_DIR
|
||||
const OFAC_SOURCES_NAMES = process.env.OFAC_SOURCES_NAMES.split(',')
|
||||
const OFAC_SOURCES_URLS = process.env.OFAC_SOURCES_URLS.split(',')
|
||||
|
||||
const ofacSources = _.map(
|
||||
it => ({
|
||||
name: it[0],
|
||||
url: it[1]
|
||||
}),
|
||||
_.zip(OFAC_SOURCES_NAMES, OFAC_SOURCES_URLS)
|
||||
)
|
||||
|
||||
function mkdir (path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.mkdir(path, err => {
|
||||
|
|
@ -97,14 +108,12 @@ const moveToSourcesDir = (srcFile, ofacSourcesDir) => {
|
|||
}
|
||||
|
||||
function update () {
|
||||
const OFAC_DATA_DIR = options.ofacDataDir
|
||||
|
||||
if (!OFAC_DATA_DIR) {
|
||||
throw new Error('ofacDataDir must be defined in lamassu.json')
|
||||
throw new Error('ofacDataDir must be defined in the environment')
|
||||
}
|
||||
|
||||
if (!options.ofacSources) {
|
||||
logger.error('ofacSources must be defined in lamassu.json')
|
||||
if (!ofacSources) {
|
||||
logger.error('ofacSources must be defined in the environment')
|
||||
}
|
||||
|
||||
const OFAC_SOURCES_DIR = path.join(OFAC_DATA_DIR, 'sources')
|
||||
|
|
@ -125,7 +134,7 @@ function update () {
|
|||
return {}
|
||||
})
|
||||
|
||||
const promiseNewEtags = Promise.resolve(options.ofacSources || [])
|
||||
const promiseNewEtags = Promise.resolve(ofacSources || [])
|
||||
.then(sources => Promise.all(_.map(promiseGetEtag, sources))
|
||||
.then(etags => _.map(
|
||||
([source, etag]) => ({...source, etag}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue