text: 'use strict';
  
  const Dotenv = require('dotenv');
  const Confidence = require('confidence');
  const Schwifty = require('schwifty');
  const Toys = require('toys');
  
  // Pull .env into process.env
  Dotenv.config({ path: `${__dirname}/.env` });
  
  // Glue manifest as a confidence store
  module.exports = new Confidence.Store({
      server: {
          host: 'localhost',
          port: {
              $filter: { $env: 'NODE_ENV' },
              $default: {
                  $env: 'PORT',
                  $coerce: 'number',
                  $default: 3000
              },
              test: { $value: undefined }         // Let the server find an open port
          },
          debug: {
              $filter: { $env: 'NODE_ENV' },
              $default: {
                  log: ['error'],
                  request: ['error']
              },
              production: {
                  request: ['implementation']
              }
          }
      },
      register: {
          plugins: [
              {
                  plugin: '../lib', // Main plugin
                  routes: {
                      prefix: '/api'
                  },
                  options: {
                      jwtKey: {
                          $filter: { $env: 'NODE_ENV' },
                          $default: {
                              $env: 'APP_SECRET',
                              $default: 'app-secret'
                          },
                          production: {           // In production do not default to "app-secret"
                              $env: 'APP_SECRET'
                          }
                      }
                  }
              },
              {
                  plugin: {
                      $filter: { $env: 'NODE_ENV' },
                      $default: 'hpal-debug',
                      production: Toys.noop
                  }
              },
              {
                  plugin: 'schwifty',
                  options: {
                      $filter: { $env: 'NODE_ENV' },
                      $default: {},
                      $base: {
                          migrateOnStart: true,
                          knex: {
                              client: 'sqlite3',
                              useNullAsDefault: true,         // Suggested for sqlite3
                              connection: {
                                  filename: `.${process.env.NODE_ENV || 'tmp'}.db`
                              },
                              migrations: {
                                  stub: Schwifty.migrationsStubPath
                              }
                          }
                      },
                      production: {
                          migrateOnStart: false
                      }
                  }
              }
          ]
      }
  });
  