Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) => {
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();
});
};
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 = '';
;(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'
;(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()
;(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)
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)
;(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'
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 = []