<commit_before>var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var links = require('docker-links').parseLinks(process.env);
var fs = require('fs');
var AzureStorageAdapter = require('parse-server-azure-storage').AzureStorageAdapter;

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI

if (!databaseUri) {
    if (links.mongo) {
        databaseUri = 'mongodb://' + links.mongo.hostname + ':' + links.mongo.port + '/dev';
    }
}

if (!databaseUri) {
    console.log('DATABASE_URI not specified, falling back to localhost.');
}

var facebookAppIds = process.env.FACEBOOK_APP_IDS;

if (facebookAppIds) {
    facebookAppIds = facebookAppIds.split(",");
}

var gcmId = process.env.GCM_ID;
var gcmKey = process.env.GCM_KEY;

var iosPushConfigs = new Array();
var isFile = function(f) {
    var b = false;
    try {
        b = fs.statSync(f).isFile();
    } catch (e) {
    }
    return b;
}

var productionBundleId = process.env.PRODUCTION_BUNDLE_ID;
var productionPfx = process.env.PRODUCTION_PFX || '/certs/production-pfx.p12';
productionPfx = isFile(productionPfx) ? productionPfx : null;
var productionCert = process.env.PRODUCTION_CERT || '/certs/production-pfx-cert.pem';
productionCert = isFile(productionCert) ? productionCert : null;
var productionKey = process.env.PRODUCTION_KEY || '/certs/production-pfx-key.pem';
productionKey = isFile(productionKey) ? productionKey : null;
var productionPassphrase = process.env.PRODUCTION_PASSPHRASE || null;
var productionPushConfig;
if (productionBundleId && (productionPfx || (productionCert && productionKey))) {
    productionPushConfig = {
        pfx: productionPfx,
        cert: productionCert,
        key: productionKey,
        passphrase: <PASSWORD>,
        bundleId: productionBundleId,
        production: true
    };
    iosPushConfigs.push(productionPushConfig);
}

var devBundleId = process.env.DEV_BUNDLE_ID;
var devPfx = process.env.DEV_PFX || '/certs/dev-pfx.p12';
devPfx = isFile(devPfx) ? devPfx : null;
var devCert = process.env.DEV_CERT || '/certs/dev-pfx-cert.pem';
devCert = isFile(devCert) ? devCert : null;
var devKey = process.env.DEV_KEY || '/certs/dev-pfx-key.pem';
devKey = isFile(devKey) ? devKey : null;
var devPassphrase = process.env.DEV_PASSPHRASE || null;
var devPushConfig;
if (devBundleId && (devPfx || (devCert && devKey))) { // exsiting files if not null
    devPushConfig = {
        pfx: devPfx,
        cert: devCert,
        key: devKey,
        passphrase: <PASSWORD>,
        bundleId: devBundleId,
        production: false
    };
    iosPushConfigs.push(devPushConfig);
}

if(process.env.APNS_BUNDLES_ID && process.env.APNS_BUNDLES_P12 && process.env.APNS_BUNDLES_PROD) {
    var APNSBundlesId = process.env.APNS_BUNDLES_ID.split(',').map(function(entry) {
        return entry.trim();
    });
    var APNSBundlesP12 = process.env.APNS_BUNDLES_P12.split(',').map(function(entry) {
        return entry.trim();
    });
    var APNSBundlesProd = process.env.APNS_BUNDLES_PROD.split(',').map(function(entry) {
        return entry.trim();
    });
    if(APNSBundlesId.length === APNSBundlesP12.length && APNSBundlesP12.length === APNSBundlesProd.length) {
        for (var i = 0; i < APNSBundlesId.length; i++) {
            APNSpushConfig = {
                pfx: APNSBundlesP12[i],
                bundleId: APNSBundlesId[i],
                production: (APNSBundlesProd[i] === 'true' ? true : false)
            };
            iosPushConfigs.push(APNSpushConfig);
        }
    }
}



var pushConfig = {};
if (gcmId && gcmKey) {
    pushConfig.android = {
        senderId: gcmId,
        apiKey: gcmKey
    }
}
if (iosPushConfigs.length > 0) {
    pushConfig.ios = iosPushConfigs;
    //console.log('Multiple iOS push configurations.')
}
console.log(pushConfig);

var port = process.env.PORT || 1337;
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
var serverURL = process.env.SERVER_URL || 'http://localhost:' + port + mountPath; // Don't forget to change to https if needed

var S3Adapter = require('parse-server').S3Adapter;
var GCSAdapter = require('parse-server').GCSAdapter;
//var FileSystemAdapter = require('parse-server').FileSystemAdapter;
var filesAdapter;

if (process.env.S3_ACCESS_KEY &&
    process.env.S3_SECRET_KEY &&
    process.env.S3_BUCKET) {
    var directAccess = !!+(process.env.S3_DIRECT);

    filesAdapter = new S3Adapter(
        process.env.S3_ACCESS_KEY,
        process.env.S3_SECRET_KEY,
        process.env.S3_BUCKET,
        {directAccess: directAccess});
} else if (process.env.GCP_PROJECT_ID &&
    process.env.GCP_KEYFILE_PATH &&
    process.env.GCS_BUCKET) {
    var directAccess = !!+(process.env.GCS_DIRECT);

    filesAdapter = new GCSAdapter(
        process.env.GCP_PROJECT_ID,
        process.env.GCP_KEYFILE_PATH,
        process.env.GCS_BUCKET,
        {directAccess: directAccess});
} else if (process.env.AZURE_ACCOUNT &&
    process.env.AZURE_CONTAINER &&
    process.env.AZURE_ACCESS_KEY) {
    var directAccess = !!+(process.env.AZURE_DIRECT);

    filesAdapter = new AzureStorageAdapter(
        process.env.AZURE_ACCOUNT,
        process.env.AZURE_CONTAINER,
        {
            accessKey: process.env.AZURE_ACCESS_KEY,
            directAccess: directAccess
        });
}

var emailModule = process.env.EMAIL_MODULE;
var verifyUserEmails = !!+(process.env.VERIFY_USER_EMAILS);
var emailAdapter;
if (!emailModule) {
    verifyUserEmails = false;
} else {
    emailAdapter = {
        module: emailModule,
        options: {
            fromAddress: process.env.EMAIL_FROM,
            domain: process.env.EMAIL_DOMAIN,
            apiKey: process.env.EMAIL_API_KEY
        }
    };
}
console.log(verifyUserEmails);
console.log(emailModule);
console.log(emailAdapter);<commit_msg>Useful log informations<commit_after>var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var links = require('docker-links').parseLinks(process.env);
var fs = require('fs');
var AzureStorageAdapter = require('parse-server-azure-storage').AzureStorageAdapter;

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI

if (!databaseUri) {
    if (links.mongo) {
        databaseUri = 'mongodb://' + links.mongo.hostname + ':' + links.mongo.port + '/dev';
    }
}

if (!databaseUri) {
    console.log('DATABASE_URI not specified, falling back to localhost.');
}

var facebookAppIds = process.env.FACEBOOK_APP_IDS;

if (facebookAppIds) {
    facebookAppIds = facebookAppIds.split(",");
}

var gcmId = process.env.GCM_ID;
var gcmKey = process.env.GCM_KEY;

var iosPushConfigs = new Array();
var isFile = function(f) {
    var b = false;
    try {
        b = fs.statSync(f).isFile();
    } catch (e) {
    }
    return b;
}

var productionBundleId = process.env.PRODUCTION_BUNDLE_ID;
var productionPfx = process.env.PRODUCTION_PFX || '/certs/production-pfx.p12';
productionPfx = isFile(productionPfx) ? productionPfx : null;
var productionCert = process.env.PRODUCTION_CERT || '/certs/production-pfx-cert.pem';
productionCert = isFile(productionCert) ? productionCert : null;
var productionKey = process.env.PRODUCTION_KEY || '/certs/production-pfx-key.pem';
productionKey = isFile(productionKey) ? productionKey : null;
var productionPassphrase = process.env.PRODUCTION_PASSPHRASE || null;
var productionPushConfig;
if (productionBundleId && (productionPfx || (productionCert && productionKey))) {
    productionPushConfig = {
        pfx: productionPfx,
        cert: productionCert,
        key: productionKey,
        passphrase: <PASSWORD>Passphrase,
        bundleId: productionBundleId,
        production: true
    };
    iosPushConfigs.push(productionPushConfig);
}

var devBundleId = process.env.DEV_BUNDLE_ID;
var devPfx = process.env.DEV_PFX || '/certs/dev-pfx.p12';
devPfx = isFile(devPfx) ? devPfx : null;
var devCert = process.env.DEV_CERT || '/certs/dev-pfx-cert.pem';
devCert = isFile(devCert) ? devCert : null;
var devKey = process.env.DEV_KEY || '/certs/dev-pfx-key.pem';
devKey = isFile(devKey) ? devKey : null;
var devPassphrase = process.env.DEV_PASSPHRASE || null;
var devPushConfig;
if (devBundleId && (devPfx || (devCert && devKey))) { // exsiting files if not null
    devPushConfig = {
        pfx: devPfx,
        cert: devCert,
        key: devKey,
        passphrase: <PASSWORD>Passphrase,
        bundleId: devBundleId,
        production: false
    };
    iosPushConfigs.push(devPushConfig);
}

if(process.env.APNS_BUNDLES_ID && process.env.APNS_BUNDLES_P12 && process.env.APNS_BUNDLES_PROD) {
    var APNSBundlesId = process.env.APNS_BUNDLES_ID.split(',').map(function(entry) {
        return entry.trim();
    });
    var APNSBundlesP12 = process.env.APNS_BUNDLES_P12.split(',').map(function(entry) {
        return entry.trim();
    });
    var APNSBundlesProd = process.env.APNS_BUNDLES_PROD.split(',').map(function(entry) {
        return entry.trim();
    });
    if(APNSBundlesId.length === APNSBundlesP12.length && APNSBundlesP12.length === APNSBundlesProd.length) {
        for (var i = 0; i < APNSBundlesId.length; i++) {
            APNSpushConfig = {
                pfx: APNSBundlesP12[i],
                bundleId: APNSBundlesId[i],
                production: (APNSBundlesProd[i] === 'true' ? true : false)
            };
            iosPushConfigs.push(APNSpushConfig);
        }
    }
}



var pushConfig = {};
if (gcmId && gcmKey) {
    pushConfig.android = {
        senderId: gcmId,
        apiKey: gcmKey
    }
}
if (iosPushConfigs.length > 0) {
    pushConfig.ios = iosPushConfigs;
    //console.log('Multiple iOS push configurations.')
}
console.log('Push configuration: '+pushConfig);

var port = process.env.PORT || 1337;
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
var serverURL = process.env.SERVER_URL || 'http://localhost:' + port + mountPath; // Don't forget to change to https if needed

var S3Adapter = require('parse-server').S3Adapter;
var GCSAdapter = require('parse-server').GCSAdapter;
//var FileSystemAdapter = require('parse-server').FileSystemAdapter;
var filesAdapter;

if (process.env.S3_ACCESS_KEY &&
    process.env.S3_SECRET_KEY &&
    process.env.S3_BUCKET) {
    var directAccess = !!+(process.env.S3_DIRECT);

    filesAdapter = new S3Adapter(
        process.env.S3_ACCESS_KEY,
        process.env.S3_SECRET_KEY,
        process.env.S3_BUCKET,
        {directAccess: directAccess});
} else if (process.env.GCP_PROJECT_ID &&
    process.env.GCP_KEYFILE_PATH &&
    process.env.GCS_BUCKET) {
    var directAccess = !!+(process.env.GCS_DIRECT);

    filesAdapter = new GCSAdapter(
        process.env.GCP_PROJECT_ID,
        process.env.GCP_KEYFILE_PATH,
        process.env.GCS_BUCKET,
        {directAccess: directAccess});
} else if (process.env.AZURE_ACCOUNT &&
    process.env.AZURE_CONTAINER &&
    process.env.AZURE_ACCESS_KEY) {
    var directAccess = !!+(process.env.AZURE_DIRECT);

    filesAdapter = new AzureStorageAdapter(
        process.env.AZURE_ACCOUNT,
        process.env.AZURE_CONTAINER,
        {
            accessKey: process.env.AZURE_ACCESS_KEY,
            directAccess: directAccess
        });
}

var emailModule = process.env.EMAIL_MODULE;
var verifyUserEmails = !!+(process.env.VERIFY_USER_EMAILS);
var emailAdapter;
if (!emailModule) {
    verifyUserEmails = false;
} else {
    emailAdapter = {
        module: emailModule,
        options: {
            fromAddress: process.env.EMAIL_FROM,
            domain: process.env.EMAIL_DOMAIN,
            apiKey: process.env.EMAIL_API_KEY
        }
    };
}
console.log('Verify user emails: '+verifyUserEmails);
console.log('Email module: '+emailModule);
console.log('Email adapter: '+emailAdapter);
{'fraction_non_alphanumeric': 0.1294586122172329, 'fraction_numerical': 0.005422350249936457, 'mean_word_length': 3.3848439821693908, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5224924', 'n_tokens_mistral': 4040, 'n_tokens_neox': 3978, 'n_words': 714}