Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
api.routes.registerRoute('post', '/resque/delDelayed', 'resque:delDelayed')
api.routes.registerRoute('post', '/resque/runDelayed', 'resque:runDelayed')
api.routes.registerRoute('post', '/resque/delLock', 'resque:delLock')
/* ----- Proxy Middleware ----- */
const middleware = {
'ah-resque-ui-proxy-middleware': {
name: 'ah-resque-ui-proxy-middleware',
global: false,
preProcessor: () => { },
postProcessor: () => { }
}
}
if (api.config['ah-resque-ui'].middleware && api.config['ah-resque-ui'].middleware.length > 0) {
middleware['ah-resque-ui-proxy-middleware'].preProcessor = async (data) => {
for (const i in api.config['ah-resque-ui'].middleware) {
const middlewareName = api.config['ah-resque-ui'].middleware[i]
const middleware = api.actions.middleware[middlewareName]
if (typeof middleware.preProcessor === 'function') {
await middleware.preProcessor(data)
}
}
}
middleware['ah-resque-ui-proxy-middleware'].postProcessor = async (data) => {
for (const i in api.config['ah-resque-ui'].middleware) {
const middlewareName = api.config['ah-resque-ui'].middleware[i]
const middleware = api.actions.middleware[middlewareName]
if (typeof middleware.postProcessor === 'function') {
await middleware.postProcessor(data)
async initialize () {
api.models = {}
const sequelizeInstance = new Sequelize(
api.config.sequelize.database,
api.config.sequelize.username,
api.config.sequelize.password,
api.config.sequelize
)
api.sequelize = {
sequelize: sequelizeInstance,
connect: async () => {
const dir = path.normalize(api.projectRoot + '/models')
fs.readdirSync(dir).forEach((file) => {
var nameParts = file.split('/')
var name = nameParts[(nameParts.length - 1)].split('.')[0]
api.models[name] = api.sequelize.sequelize.import(dir + '/' + file)
})
await api.sequelize.sequelize.sync()
},
async initialize () {
api.models = {}
const sequelizeInstance = new Sequelize(
api.config.sequelize.database,
api.config.sequelize.username,
api.config.sequelize.password,
api.config.sequelize
)
api.sequelize = {
sequelize: sequelizeInstance,
connect: async () => {
const dir = path.normalize(api.projectRoot + '/models')
fs.readdirSync(dir).forEach((file) => {
var nameParts = file.split('/')
var name = nameParts[(nameParts.length - 1)].split('.')[0]
api.models[name] = api.sequelize.sequelize.import(dir + '/' + file)
})
async run ({response}) {
response.packageDetails = {}
response.packageDetails.packageJSON = packageJSON
response.packageDetails.redis = api.config.redis.tasks.args
}
}
middleware['ah-resque-ui-proxy-middleware'].postProcessor = async (data) => {
for (const i in api.config['ah-resque-ui'].middleware) {
const middlewareName = api.config['ah-resque-ui'].middleware[i]
const middleware = api.actions.middleware[middlewareName]
if (typeof middleware.postProcessor === 'function') {
await middleware.postProcessor(data)
}
}
}
}