feat: add button to check against OFAC sanction list
This commit is contained in:
parent
a29f3fc13c
commit
c77fda2623
11 changed files with 114 additions and 5 deletions
28
lib/new-admin/middlewares/loadSanctionLists.js
Normal file
28
lib/new-admin/middlewares/loadSanctionLists.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const logger = require('../../logger')
|
||||
const sanctions = require('../../ofac')
|
||||
|
||||
const sanctionStatus = {
|
||||
loaded: false,
|
||||
timestamp: null
|
||||
}
|
||||
|
||||
const loadSanctionLists = (req, res, next) => {
|
||||
if (!sanctionStatus.loaded) {
|
||||
logger.info('No sanction lists loaded. Loading sanctions...')
|
||||
return sanctions.load()
|
||||
.then(() => {
|
||||
logger.info('OFAC sanction list loaded!')
|
||||
sanctionStatus.loaded = true
|
||||
sanctionStatus.timestamp = Date.now()
|
||||
return next()
|
||||
})
|
||||
.catch(e => {
|
||||
logger.error('Couldn\'t load OFAC sanction list!')
|
||||
return next(e)
|
||||
})
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
module.exports = loadSanctionLists
|
||||
Loading…
Add table
Add a link
Reference in a new issue