Configuration

const packageJson = require('../package.json');

module.exports = {
  // Application version
  'appVersion': packageJson.version,
  // Application name
  'appName': packageJson.name,
  // Port to run the application on
  'port': process.env.PORT || 8000,
  // Whether or not to allow remote hotloading in dev
  'remoteHotload': false,
  // Where webpack hosts its hotloading
  'hotReloadPort': process.env.HOT_RELOAD_PORT || 8080,
  // Where thunderball modules are kept (default: '/src/ions')
  'ionsDir': '/src/ions',
  // Where assets like css & js are hosted
  'staticAssets': {
    path: '/static',
    maxAge: '200d'
  },
  // Ability to overwrite the webpack config generated by thunderball
  'configureWebPack': (config) => {
    return config;
  },
  // Define your own winston logging config, or use the default logger and control with env variables
  'configureLogger': (config) => {
    // logging options
    return config;
  },
  // Internationalization support
  'i18n': {
    'locales': ['es', 'en', 'fr'],
    'defaultLocale': 'en'
  },
  // Create express proxy routes
  'proxyRoutes': [{
    path: 'api/',
    proxyUrl: 'https://member.angieslist.com'
  }],
  // Keys passed from this file to client
  'clientConfigKeys': [
    'appVersion', 'appName'
  ],
  // How to configure server side rendering (can be overwritten or merged values with ssr config in a modules manifest.js)
  'ssr': {
    // Whether or not to render the body (default: true)
    renderBody: true,
    // Whether or not to use http steaming (default: false)
    useStreaming: false,
    // Define caching during server side rendering
    caching: {
      // Whether or not to memoize objects such as redux store, default state, etc (default: true)
      memoize: true,
      // Function to determine the cache key for rapscallion caching the entire page body (default: '(req) => url.parse(req.url).pathname')
      // Return 'undefined' to use no caching
      // If you have custom initial state, you may want a more complex cache key
      getCacheKey: (req) => url.parse(req.url).pathname
      // Function to set the rapscallion cache strategy (default: an in memory cache)
      // Implement this method to use redis, file system, etc
      getCacheStrategy() {
        return {
          get: (key) => { // function to get a value }
          set: (key, value) => { // function to set a value }
        }
      }
    },
    // Define an object containing the http headers to use when getting the page
    // This is merged with header config from the client
    // Most useful for setting headers such as 'cache-control'
    headers: {
      'cache-control': 'public, max-age: 7000'
    },
    // An array of strings or functions producing strings to inject before the page body
    // Useful for defining <script> tags
    beforeBody: [],
    // An array of strings or functions producing strings to inject after the page body
    // Useful for defining <script> tags
    afterBody: [],
    // Implement this function to determine initial state to store in redux for every page
    // Be sure to cache or memoize values
    // This function must return a Promise that resolves into a javascript object that is merged into the redux state
    getInitialState: async ((req, appConfig = {}) => {
      const port = appConfig.port || 8000;

      // We need absolute url since this is running the the server and has no idea where express routes are
      const result = await fetch(`http://127.0.0.1:${port}/foo/bar`, { allowOnServer: true, timeout: 500 });
      const bar = await result.json();
      return {
        foo: {
          bar
        }
      };
    })
  }
  // Define instrumentation details
  'instrumentation': {
    providers: [{
      // This tracer will wrap all instrumentation trace functions 
      // with a stopwatch and log to the console
      createTracer: (name, func) => {
        return () => {
          const hrstart = process.hrtime();
          func(name, func);
          const endTime = process.hrtime(hrstart)[1] / 1000000;
          console.log(`Tracer '${name}': ${endTime}ms`);
        };
      }
    }]
  }

  // ...Additional config values that can be read by server side modules
};

results matching ""

    No results matching ""