Skip to content

Modular logistics and supply chain operating system (LSOS)

4.6 KB
Raw Blame
'use strict';
const toBoolean = require('./utils/to-boolean');
const getenv = require('./utils/getenv');
const fixApiHost = require('./utils/fix-api-host');
const asArray = require('./utils/as-array');
const inlinePlaceholder = require('./utils/inline-placeholder');
const { version } = require('../package');

module.exports = function (environment) {
    const ENV = {
        modulePrefix: '@fleetbase/console',
        version,
        environment,
        rootURL: '/',
        locationType: 'history',
        EmberENV: {
            EXTEND_PROTOTYPES: true,
            FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
            },
        },

        APP: {
            autoboot: true,
            extensions: asArray(getenv('EXTENSIONS')),
            disableRuntimeConfig: toBoolean(getenv('DISABLE_RUNTIME_CONFIG', environment === 'production')),
            disableFleetbaseAttribution: toBoolean(getenv('DISABLE_FLEETBASE_ATTRIBUTION', false)),
        },

        API: {
            host: fixApiHost(getenv('API_HOST'), toBoolean(getenv('API_SECURE'))),
            namespace: getenv('API_NAMESPACE', 'int/v1'),
        },

        osrm: {
            host: getenv('OSRM_HOST', 'https://router.project-osrm.org'),
            servers: {},
        },

        socket: {
            path: getenv('SOCKETCLUSTER_PATH', '/socketcluster/'),
            hostname: getenv('SOCKETCLUSTER_HOST'),
            secure: toBoolean(getenv('SOCKETCLUSTER_SECURE', false)),
            port: getenv('SOCKETCLUSTER_PORT', 38000),
        },

        stripe: {
            publishableKey: getenv('STRIPE_KEY'),
        },

        defaultValues: {
            categoryImage: getenv('DEFAULT_CATEGORY_IMAGE', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/images/fallback-placeholder-1.png'),
            placeholderImage: getenv('DEFAULT_PLACEHOLDER_IMAGE', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/image-file-icon.png'),
            placeholderImageOld: getenv('DEFAULT_PLACEHOLDER_IMAGE_OLD', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/images/fallback-placeholder-2.png'),
            driverImage: getenv('DEFAULT_DRIVER_IMAGE', inlinePlaceholder('driver')),
            userImage: getenv('DEFAULT_USER_IMAGE', inlinePlaceholder('contact')),
            contactImage: getenv('DEFAULT_CONTACT_IMAGE', inlinePlaceholder('contact')),
            customerImage: getenv('DEFAULT_CUSTOMER_IMAGE', inlinePlaceholder('customer')),
            entityImage: getenv('DEFAULT_ENTITY_IMAGE', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/parcels/medium.png'),
            vendorImage: getenv('DEFAULT_VENDOR_IMAGE', inlinePlaceholder('vendor')),
            vehicleImage: getenv('DEFAULT_VEHICLE_IMAGE', inlinePlaceholder('vehicle')),
            trailerImage: getenv('DEFAULT_TRAILER_IMAGE', inlinePlaceholder('trailer')),
            fleetImage: getenv('DEFAULT_FLEET_IMAGE', inlinePlaceholder('fleet')),
            vehicleAvatar: getenv('DEFAULT_VEHICLE_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/vehicle-icons/mini_bus.svg'),
            driverAvatar: getenv('DEFAULT_DRIVER_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/driver-icons/moto-driver.png'),
            placeAvatar: getenv('DEFAULT_PLACE_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/place-icons/basic-building.png'),
            extensionIcon: getenv('DEFAULT_EXTENSION_ICON', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/default-extension-icon.svg'),
        },

        'ember-simple-auth': {
            routeAfterAuthentication: 'console',
        },

        'ember-local-storage': {
            namespace: '@fleetbase',
            keyDelimiter: '/',
            includeEmberDataSupport: true,
        },

        'ember-cli-notifications': {
            autoClear: true,
            clearDuration: 1000 * 3.5,
        },
    };

    if (environment === 'development') {
        // ENV.APP.LOG_RESOLVER = true;
        // ENV.APP.LOG_ACTIVE_GENERATION = true;
        // ENV.APP.LOG_TRANSITIONS = true;
        // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
        // ENV.APP.LOG_VIEW_LOOKUPS = true;
    }

    if (environment === 'test') {
        // Testem prefers this...
        ENV.locationType = 'none';

        // keep test console output quieter
        ENV.APP.LOG_ACTIVE_GENERATION = false;
        ENV.APP.LOG_VIEW_LOOKUPS = false;

        ENV.APP.rootElement = '#ember-testing';
        ENV.APP.autoboot = false;
    }

    if (environment === 'production') {
        // here you can enable a production-specific feature
    }

    return ENV;
};