
const CONFIG = require('craftlabhttpserver/src/config.js');

const FILENAME = process.mainModule.path + "/config.json";
const fs = require('fs');
const path = require('path');

let configEntries = CONFIG;

(() => {
    CONFIG.Initialize({
            port: { value: 80, valid: CONFIG.validNumber },
            instanceHostname: { value: require('os').hostname(), valid: CONFIG.validNotEmptyString },
            ldapUrl: { value: "", valid: CONFIG.validNotEmptyString },
            ldapBindDN: { value: "", valid: CONFIG.validNotEmptyString },
            ldapBindPwd: { value: "", valid: CONFIG.validNotEmptyString },
            ldapBase: { value: "", valid: CONFIG.validNotEmptyString },
            database: { value: "", valid: CONFIG.validNotEmptyString }
        });

    configEntries.photoLibraries = [];
    let hasErrors = false;
    for (let i of CONFIG.getInitialContent().photoLibraries)
        if (CONFIG.validNotEmptyString(i))
            configEntries.photoLibraries.push(i);

    configEntries.ldapFilters = [];

    console.log(configEntries);
    if (hasErrors)
        throw "Errors found while parsing configuration";
})();

module.exports = configEntries;

