Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!dlvrToken && !mgmtToken) {
return res.json({ error: 'Missing auth token' })
}
let contentTypes
try {
contentTypes = mgmtToken
? await convertApi.getContentTypesFromManagementApi(spaceId, mgmtToken)
: await convertApi.getContentTypesFromDistributionApi(spaceId, dlvrToken)
} catch (err) {
return res.json({ error: err })
}
const modelsMap = convertApi.contentTypesToModelMap(contentTypes);
const dotStr = convertApi.modelsMapToDot(modelsMap, {dev: devMode, hideEntityFields: hideFields});
const fileName = `${spaceId}-${Date.now()}`
if (dotStr && dotStr.length > 1) {
// wait for the png
await generateGraph(outFile(fileName, 'png'), dotStr, 'png')
// but those are fine to be finished later
setImmediate(() => generateGraph(outFile(fileName, 'svg'), dotStr, 'svg'))
setImmediate(() => generateGraph(outFile(fileName, 'pdf'), dotStr, 'pdf'))
}
res.json({
modelsMap: modelsMap,
dot: dotStr,
rendered: {