How to use the rest-hapi.config function in rest-hapi

To help you get started, we’ve selected a few rest-hapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JKHeadley / appy-backend / api / api.js View on Github external
function apiInit() {

  const server = new Hapi.Server();

  server.connection({
    port: config.server.port,
    routes: {
      cors: {
        additionalHeaders: ['X-Total-Count'],
        additionalExposedHeaders: ['X-Total-Count']
      }
    }
  });

  restHapi.config = config;

  restHapi.generateModels(mongoose)
    .then(function () {
      server.register(require('hapi-auth-jwt2'), (err) => {
        if (err) {
          console.error('Failed to load plugin:', err);
        }

        server.register(require('hapi-auth-basic'), (err) => {
          if (err) {
            console.error('Failed to load plugin:', err);
          }

          Auth.getCurrentStrategy(server, Log);

          server.register(require('./utilities/mailer'), (err) => {
github JKHeadley / appy-backend / backend / server / api.js View on Github external
exports.register = function (server, options, next) {
  RestHapi.config = Config.get('/restHapiConfig');

  server.register({
    register: RestHapi,
    options: {
      mongoose: Mongoose
    }
  }, function (err) {
    if (err) {
      console.error('Failed to load plugin:', err);
    }

    next();
  });

};
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
function updatePermissions () {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('update-permissions')

  let promise = {}

  if (models) {
    promise = Q.when(models)
  }
  else {
    Mongoose.Promise = Q.Promise

    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = __dirname + '/../server/models'

    Mongoose.connect(restHapiConfig.mongo.URI)

    promise = RestHapi.generateModels(Mongoose)
  }
  return promise
    .then(function (result) {
      models = result

      let promises = []

      for (const modelKey in models) {
        const model = models[modelKey]
        const modelName = model.collectionName[0].toUpperCase() + model.collectionName.slice(1)
        const permissions = []
        let name = '';
github JKHeadley / appy-backend / scripts / seed.js View on Github external
;(async function seed() {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('seed')
  try {
    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = path.join(__dirname, '/../server/models')

    let models = await RestHapi.generateModels(Mongoose)

    const composeOptions = {
      relativeTo: path.join(__dirname, '/../')
    }

    const manifest = Manifest.get('/')
    const server = await Glue.compose(manifest, composeOptions)

    await server.start()

    faker.seed(4997)

    const password = 'root'
github JKHeadley / appy-backend / scripts / seed.js View on Github external
;(async function seed() {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('seed')
  try {
    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = path.join(__dirname, '/../server/models')

    let models = await RestHapi.generateModels(Mongoose)

    const composeOptions = {
      relativeTo: path.join(__dirname, '/../')
    }

    const manifest = Manifest.get('/')
    const server = await Glue.compose(manifest, composeOptions)

    await server.start()
github JKHeadley / appy-backend / scripts / seed.js View on Github external
;(async function seed() {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('seed')
  try {
    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = path.join(__dirname, '/../server/models')

    let models = await RestHapi.generateModels(Mongoose)

    const composeOptions = {
      relativeTo: path.join(__dirname, '/../')
    }

    const manifest = Manifest.get('/')
    const server = await Glue.compose(manifest, composeOptions)

    await server.start()

    faker.seed(4997)
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
function updatePermissions () {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('update-permissions')

  let promise = {}

  if (models) {
    promise = Q.when(models)
  }
  else {
    Mongoose.Promise = Q.Promise

    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = __dirname + '/../server/models'

    Mongoose.connect(restHapiConfig.mongo.URI)

    promise = RestHapi.generateModels(Mongoose)
  }
  return promise
    .then(function (result) {
      models = result

      let promises = []

      for (const modelKey in models) {
        const model = models[modelKey]
        const modelName = model.collectionName[0].toUpperCase() + model.collectionName.slice(1)
github JKHeadley / appy-backend / scripts / seed.js View on Github external
;(async function seed() {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('seed')
  try {
    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = path.join(__dirname, '/../server/models')

    let models = await RestHapi.generateModels(Mongoose)

    const composeOptions = {
      relativeTo: path.join(__dirname, '/../')
    }

    const manifest = Manifest.get('/')
    const server = await Glue.compose(manifest, composeOptions)

    await server.start()

    faker.seed(4997)

    const password = 'root'
    const pin = '1234'
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
function updatePermissions () {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('update-permissions')

  let promise = {}

  if (models) {
    promise = Q.when(models)
  }
  else {
    Mongoose.Promise = Q.Promise

    RestHapi.config = restHapiConfig
    RestHapi.config.absoluteModelPath = true
    RestHapi.config.modelPath = __dirname + '/../server/models'

    Mongoose.connect(restHapiConfig.mongo.URI)

    promise = RestHapi.generateModels(Mongoose)
  }
  return promise
    .then(function (result) {
      models = result

      let promises = []

      for (const modelKey in models) {
        const model = models[modelKey]
        const modelName = model.collectionName[0].toUpperCase() + model.collectionName.slice(1)
        const permissions = []