Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const loadMiscMiddlewares = function (app, callback)
{
if (process.env.NODE_ENV !== "production")
{
app.use(errorHandler({ dumpExceptions: true, showStack: true }));
}
const busboy = require("connect-busboy");
app.use(busboy());
// all environments
app.set("port", process.env.PORT || Config.port);
app.set("views", rlequire.absPathInApp("dendro", "src/views"));
app.set("view engine", "ejs");
app.set("etag", "strong");
app.use(favicon(rlequire.absPathInApp("dendro", "public/images/logo_micro.png")));
// app.use(express.logger('dev'));
app.use(bodyParser.urlencoded({limit: "5mb", extended: true}));
app.use(bodyParser.json({limit: "5mb"}));
app.use(function (error, req, res, next)
{
if (error instanceof SyntaxError)
{
res.status(400).json({
const checkDatabaseConnectionViaJDBC = function (callback)
{
if (!jinst.isJvmCreated())
{
jinst.addOption("-Xrs");
jinst.setupClasspath([
rlequire.absPathInApp("dendro", "conf/virtuoso-jdbc/jdbc-4.2/virtjdbc4_2.jar")
]);
}
// Working config in Dendro PRD, 22-12-2017
// const timeoutSecs = 10;
// const config = {
// // Required
// url: `jdbc:virtuoso://${self.host}:${self.port_isql}/UID=${self.username}/PWD=${self.password}/PWDTYPE=cleartext/CHARSET=UTF-8/TIMEOUT=${timeoutSecs}`,
// drivername: "virtuoso.jdbc4.Driver",
// maxpoolsize: Math.ceil(self.maxSimultaneousConnections / 2),
// minpoolsize: 1,
// // 10 seconds idle time
// maxidle: 1000 * timeoutSecs,
// properties: {}
// };
result: "error",
message: "Error parsing request!",
error: error
});
}
else
{
next();
}
});
app.use(methodOverride());
app.use(flash());
app.use(require("stylus").middleware(rlequire.absPathInApp("dendro", "public/")));
app.use("/docs", express.static(rlequire.absPathInApp("dendro", "docs/")));
app.use(express.static(rlequire.absPathInApp("dendro", "public/")));
app.set("title", "Dendro");
app.set("theme", Config.theme);
// app.use(session({
// secret: appSecret,
// resave: true,
// saveUninitialized: true
// }));
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument, {
docExpansion: "list"
}));
Config.mySQLDBName = getConfigParameter("mySQLDBName");
// file uploads and downloads
// 1000MB®
Config.maxUploadSize = getConfigParameter("maxUploadSize");
// 10000MB®
Config.maxProjectSize = getConfigParameter("maxProjectSize");
if (path.isAbsolute(getConfigParameter("tempFilesDir")))
{
Config.tempFilesDir = getConfigParameter("tempFilesDir");
}
else
{
Config.tempFilesDir = rlequire.absPathInApp("dendro", getConfigParameter("tempFilesDir"));
}
if (path.isAbsolute(getConfigParameter("tempUploadsDir")))
{
Config.tempUploadsDir = getConfigParameter("tempUploadsDir");
}
else
{
Config.tempUploadsDir = rlequire.absPathInApp("dendro", getConfigParameter("tempUploadsDir"));
}
Config.tempFilesCreationMode = getConfigParameter("tempFilesCreationMode");
Config.administrators = getConfigParameter("administrators");
// load debug and startup settings
{
startTime = new Date();
}
}
const moment = require("moment");
const fileNameDateSection = moment(startTime).format("YYYY_MM_DD");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
// Setup logging
if (!isNull(Config.logging))
{
const loggerLevel = (Config.logging.level) ? Config.logging.level : "debug";
if (!isNull(Config.logging.app_logs_folder))
{
const absPath = rlequire.absPathInApp("dendro", Config.logging.app_logs_folder);
const exists = fs.existsSync(absPath);
if (!exists)
{
try
{
mkdirp.sync(absPath);
}
catch (e)
{
const msg = "[FATAL] Unable to create folder for logs at " + absPath + "\n" + JSON.stringify(e);
throw new Error(msg);
}
}
let logger;
const recordQueryConclusionInLog = function (query, queryStartTime)
{
const logParentFolder = rlequire.absPathInApp("dendro", "profiling");
const queryProfileLogFilePath = path.join(logParentFolder, "database_profiling_" + bootStartTimestamp + ".csv");
if (Config.debug.database.log_query_times)
{
const msec = new Date().getTime() - queryStartTime.getTime();
let fd;
if (!fs.existsSync(logParentFolder))
{
mkdirp.sync(logParentFolder);
// truncate / create blank file
fd = fs.openSync(queryProfileLogFilePath, "a");
fs.appendFileSync(queryProfileLogFilePath, "query" + profilingLogFileSeparator + "time_msecs\n");
fs.closeSync(fd);
}
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/Electricalandopticalproperties.pdf")),
name: "BusPerformance.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/Electricalandopticalproperties.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc10.pdf")),
name: "BusPerformance.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc10.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/optical.pdf")),
name: "BusPerformance.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/optical.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");
module.exports = {
md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/Electricalandopticalproperties.pdf")),
name: "BusPerformance.pdf",
extension: "pdf",
location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/Photovoltaic/Electricalandopticalproperties.pdf"),
metadata: [{
prefix: "nie",
shortName: "plainTextContent",
value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
},
{
prefix: "dcterms",
shortName: "abstract",
value: "This is a pdf file."
},
{
prefix: "dcterms",
shortName: "title",
value: "pdf file."
}]
};