You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

import { resolveActionClass, resolveSchema } from './../helper/resolver.js'
import FlowStore from './../store/flow.js'
import logger from './../helper/logger.js'
/**
*
* handle parser
*
*
* @author Björn Hase <me@herr-hase.wtf>
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
* @link https://git.node001.net/HerrHase/signpost.git
*
*/
async function flowHandler(request, response) {
// get single flow
const flowStore = new FlowStore(this.db())
const flow = await flowStore.findOneByUuid(request.params.uuid)
if (!flow) {
return response
.code(404)
.send()
}
// add to locals
response.locals = {
'flow' : flow
}
// getting action class
try {
response.locals.action = await import(resolveActionClass(flow.action))
} catch(error) {
logger(flow.uuid).error('flowHandler / resolve class / ' + error)
return response
.code(500)
.send()
}
// check for schema
if (flow.schema) {
try {
response.locals.schema = await import(resolveSchema(flow.schema))
} catch(error) {
logger(flow.uuid).error('flowHandler / resolve schema / ' + error)
}
}
}
export default flowHandler