Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) => {
if (err) {
console.error('Failed to load plugin:', err);
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 = '';
let assignScope;
permissions.push({
name: model.collectionName,
gulp.task('seed', [], function () {
RestHapi.config = restHapiConfig
RestHapi.config.absoluteModelPath = true
RestHapi.config.modelPath = __dirname + '/../server/models'
return RestHapi.generateModels(Mongoose)
.then(function (result) {
models = result
return Composer((err, server) => {
if (err) {
throw err
}
return server.start((err) => {
RestHapi.config.loglevel = 'DEBUG'
const Log = RestHapi.getLogger('seed')
faker.seed(4997)
const password = 'root'
;(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'
let roles = []