Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Mongoose from "mongoose";
import Component from "./models/component";
import axios from "axios";
import { markdown } from "markdown";
import Octokit from "@octokit/rest";
import Logger from 'logdna';
const DELAY = 2000;
const AV_URL = "https://raw.githubusercontent.com/vuejs/awesome-vue/master/README.md";
let logger = console;
if (process.env.ENV === 'prod' && process.env.LOGDNA_KEY) {
logger = Logger.setupDefaultLogger(process.env.LOGDNA_KEY, {
app: 'org.vuelib.parser'
});
}
if (!process.env.OCTOKIT_KEY) {
logger.log('OCTOKIT_KEY is not defined.');
process.exit(1);
}
async function connectMongo() {
try {
await Mongoose.connect(process.env.MONGODB_URL || 'mongodb://mongo:27017/vuelibs');
logger.log('Connected to mongo');
} catch (err) {
logger.log('Could not connect to mongo');
}
let levels = new Levels(namespace)
this._fatal = levels.fatal
this._error = levels.error
this._warn = levels.warn
this._info = levels.info
this._debug = levels.debug
this._trace = levels.trace
this.namespace = namespace
if (logDNAKey && logDNAKey.length > 0) {
if (!logDNAOptions) {
logDNAOptions = {}
}
if (!logDNAOptions.hasOwnProperty('hostname')) {
logDNAOptions = { ...logDNAOptions, hostname: '' }
}
this.loggerDNA = LogDNA.setupDefaultLogger(logDNAKey, logDNAOptions)
}
}
},
],
});
let logzIoLogger;
if (process.env.logzIoAccessToken) {
logzIoLogger = logzIo.createLogger({
token: process.env.logzIoAccessToken,
type: 'api',
});
}
let logdnaLogger;
if (process.env.logdnaApiKey) {
logdnaLogger = logdna.createLogger(process.env.logdnaApiKey, {
env,
hostname: os.hostname(),
ip: ip.address(),
});
}
function setLevel(level) {
switch (level) {
case 'all':
logLevel = 1;
break;
case 'warnings':
logLevel = 2;
break;