How to use the rest-hapi.getLogger 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 / server / plugins / auth.plugin.js View on Github external
const Mongoose = require('mongoose')
const Boom = require('boom')
const RestHapi = require('rest-hapi')
const errorHelper = require('../utilities/error-helper')

const Config = require('../../config')
const Token = require('../utilities/create-token')

const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES')
const socialPassword = Config.get('/socialPassword')
const socialIds = Config.get('/socialIds')
const socialSecrets = Config.get('/socialSecrets')
const EXPIRATION_PERIOD = Config.get('/constants/EXPIRATION_PERIOD')
const isSecure = Config.get('/socialSecure')

const logger = RestHapi.getLogger('appy')

const internals = {}

module.exports = {
  plugin: {
    name: 'auth',
    register
  }
}

internals.applyTokenStrategy = function(server) {
  // const Log = logger.bind('auth/standard-jwt')

  server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
    key: Config.get('/jwtSecret'),
    verifyOptions: { algorithms: ['HS256'] },
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
gulp.task('update-permissions', [], function () {
  RestHapi.config.loglevel = 'DEBUG'
  const Log = RestHapi.getLogger('update-permissions')

  return updatePermissions()
    .then(function (result) {

      return gulp.src('')
        .pipe(exit())
    })
    .catch(function (error) {
      Log.error(error)
    })
})
github JKHeadley / appy-backend / api / api.js View on Github external
'use strict';

const Hapi = require('hapi');
const config = require('../config').get('/restHapiConfig');
const Auth = require('./utilities/auth');
const mongoose = require('mongoose');
const restHapi = require('rest-hapi');
const Log = restHapi.getLogger('appy');

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;
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
return server.start((err) => {
          RestHapi.config.loglevel = 'DEBUG'
          const Log = RestHapi.getLogger('seed')

          faker.seed(4997)

          const password = 'root'
          const pin = '1234'

          let roles = []
          let users = []
          let groups = []
          let visitors = []
          let permissions = []
          let adminPermissions = []

          let permissionNames = []

          let request = {}
github JKHeadley / appy-backend / backend / server / auth.js View on Github external
const Mongoose = require('mongoose');
const Boom = require('boom');
const RestHapi = require('rest-hapi');

const Config = require('../config');
const Token = require('./token');

const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES');
const socialPassword = Config.get('/socialPassword');
const socialIds = Config.get('/socialIds');
const socialSecrets = Config.get('/socialSecrets');
const expirationPeriod = Config.get('/expirationPeriod');
const isSecure = Config.get('/socialSecure')

const logger = RestHapi.getLogger('appy');

const internals = {};


internals.applyTokenStrategy = function (server, next) {
  const Log = logger.bind("auth/standard-jwt");

  server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
    key: Config.get('/jwtSecret'),
    verifyOptions: { algorithms: ['HS256'] },

    validateFunc: function (decodedToken, request, callback) {

      let user = decodedToken.user;

      callback(null, Boolean(user), { user, scope: decodedToken.scope });
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 / 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)
github JKHeadley / appy-backend / server / auth.js View on Github external
'use strict';

const Mongoose = require('mongoose');
const Boom = require('boom');
const RestHapi = require('rest-hapi');

const Config = require('../config');
const Token = require('./token');

const AUTH_STRATEGIES = Config.get('/constants/AUTH_STRATEGIES');
const socialPassword = Config.get('/socialPassword');
const socialIds = Config.get('/socialIds');
const socialSecrets = Config.get('/socialSecrets');
const expirationPeriod = Config.get('/expirationPeriod');

const logger = RestHapi.getLogger('appy');

const internals = {};


internals.applyTokenStrategy = function (server, next) {
  const Log = logger.bind("auth/standard-jwt");

  server.auth.strategy(AUTH_STRATEGIES.TOKEN, 'jwt', {
    key: Config.get('/jwtSecret'),
    verifyOptions: { algorithms: ['HS256'] },

    validateFunc: function (decodedToken, request, callback) {

      let user = decodedToken.user;

      callback(null, Boolean(user), { user, scope: decodedToken.scope });
github JKHeadley / appy-backend / backend / gulp / seed.js View on Github external
function dropCollections (models) {
  const mongoose = require('mongoose')
  RestHapi.config.loglevel = 'LOG'
  const Log = RestHapi.getLogger('unseed')

  Log.log('removing users')
  return models.user.remove({})
    .then(function () {
      Log.log('removing roles')
      return models.role.remove({})
    })
    .then(function () {
      Log.log('removing groups')
      return models.group.remove({})
    })
    .then(function () {
      Log.log('removing permissions')
      return models.permission.remove({})
    })
    .then(function () {