chore: removed global eslint references
This commit is contained in:
@@ -26,7 +26,7 @@ global.winston = require('./libs/logger')(IS_DEBUG, 'AGENT')
|
||||
// Load global modules
|
||||
// ----------------------------------------
|
||||
|
||||
winston.info('Background Agent is initializing...')
|
||||
global.winston.info('Background Agent is initializing...')
|
||||
|
||||
global.db = require('./libs/db').init()
|
||||
global.upl = require('./libs/uploads-agent').init()
|
||||
@@ -53,7 +53,7 @@ const entryHelper = require('./helpers/entry')
|
||||
// Localization Engine
|
||||
// ----------------------------------------
|
||||
|
||||
lang
|
||||
global.lang
|
||||
.use(i18nextBackend)
|
||||
.use(i18nextMw.LanguageDetector)
|
||||
.init({
|
||||
@@ -77,8 +77,8 @@ let job
|
||||
let jobIsBusy = false
|
||||
let jobUplWatchStarted = false
|
||||
|
||||
db.onReady.then(() => {
|
||||
return db.Entry.remove({})
|
||||
global.db.onReady.then(() => {
|
||||
return global.db.Entry.remove({})
|
||||
}).then(() => {
|
||||
job = new Cron({
|
||||
cronTime: '0 */5 * * * *',
|
||||
@@ -86,10 +86,10 @@ db.onReady.then(() => {
|
||||
// Make sure we don't start two concurrent jobs
|
||||
|
||||
if (jobIsBusy) {
|
||||
winston.warn('Previous job has not completed gracefully or is still running! Skipping for now. (This is not normal, you should investigate)')
|
||||
global.winston.warn('Previous job has not completed gracefully or is still running! Skipping for now. (This is not normal, you should investigate)')
|
||||
return
|
||||
}
|
||||
winston.info('Running all jobs...')
|
||||
global.winston.info('Running all jobs...')
|
||||
jobIsBusy = true
|
||||
|
||||
// Prepare async job collector
|
||||
@@ -107,7 +107,7 @@ db.onReady.then(() => {
|
||||
// -> Sync with Git remote
|
||||
//* ****************************************
|
||||
|
||||
jobs.push(git.resync().then(() => {
|
||||
jobs.push(global.git.resync().then(() => {
|
||||
// -> Stream all documents
|
||||
|
||||
let cacheJobs = []
|
||||
@@ -140,7 +140,7 @@ db.onReady.then(() => {
|
||||
// -> Update cache and search index
|
||||
|
||||
if (fileStatus !== 'active') {
|
||||
return entries.updateCache(entryPath).then(entry => {
|
||||
return global.entries.updateCache(entryPath).then(entry => {
|
||||
process.send({
|
||||
action: 'searchAdd',
|
||||
content: entry
|
||||
@@ -187,18 +187,18 @@ db.onReady.then(() => {
|
||||
// ----------------------------------------
|
||||
|
||||
Promise.all(jobs).then(() => {
|
||||
winston.info('All jobs completed successfully! Going to sleep for now.')
|
||||
global.winston.info('All jobs completed successfully! Going to sleep for now.')
|
||||
|
||||
if (!jobUplWatchStarted) {
|
||||
jobUplWatchStarted = true
|
||||
upl.initialScan().then(() => {
|
||||
global.upl.initialScan().then(() => {
|
||||
job.start()
|
||||
})
|
||||
}
|
||||
|
||||
return true
|
||||
}).catch((err) => {
|
||||
winston.error('One or more jobs have failed: ', err)
|
||||
global.winston.error('One or more jobs have failed: ', err)
|
||||
}).finally(() => {
|
||||
jobIsBusy = false
|
||||
})
|
||||
@@ -214,7 +214,7 @@ db.onReady.then(() => {
|
||||
// ----------------------------------------
|
||||
|
||||
process.on('disconnect', () => {
|
||||
winston.warn('Lost connection to main server. Exiting...')
|
||||
global.winston.warn('Lost connection to main server. Exiting...')
|
||||
job.stop()
|
||||
process.exit()
|
||||
})
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, lang, rights, winston */
|
||||
|
||||
var express = require('express')
|
||||
var router = express.Router()
|
||||
const Promise = require('bluebird')
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, lang */
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global entries, lang, winston */
|
||||
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
const _ = require('lodash')
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global git, lang, lcdata, upl */
|
||||
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
/* global appconfig, rights */
|
||||
/* global appconfig, entries, rights, search, upl */
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
|
||||
const _ = require('lodash')
|
||||
|
@@ -25,7 +25,7 @@ global.appdata = appconf.data
|
||||
// ----------------------------------------
|
||||
|
||||
global.winston = require('./libs/logger')(IS_DEBUG, 'SERVER')
|
||||
winston.info('Wiki.js is initializing...')
|
||||
global.winston.info('Wiki.js is initializing...')
|
||||
|
||||
// ----------------------------------------
|
||||
// Load global modules
|
||||
@@ -53,8 +53,7 @@ const favicon = require('serve-favicon')
|
||||
const flash = require('connect-flash')
|
||||
const fork = require('child_process').fork
|
||||
const http = require('http')
|
||||
const i18nextBackend = require('i18next-node-fs-backend')
|
||||
const i18nextMw = require('i18next-express-middleware')
|
||||
const i18nBackend = require('i18next-node-fs-backend')
|
||||
const passport = require('passport')
|
||||
const passportSocketIo = require('passport.socketio')
|
||||
const session = require('express-session')
|
||||
@@ -68,7 +67,8 @@ var ctrl = autoload(path.join(SERVERPATH, '/controllers'))
|
||||
// Define Express App
|
||||
// ----------------------------------------
|
||||
|
||||
global.app = express()
|
||||
const app = express()
|
||||
global.app = app
|
||||
app.use(compression())
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -90,10 +90,10 @@ app.use(express.static(path.join(ROOTPATH, 'assets')))
|
||||
|
||||
require('./libs/auth')(passport)
|
||||
global.rights = require('./libs/rights')
|
||||
rights.init()
|
||||
global.rights.init()
|
||||
|
||||
let sessionStore = new SessionMongoStore({
|
||||
mongooseConnection: db.connection,
|
||||
mongooseConnection: global.db.connection,
|
||||
touchAfter: 15
|
||||
})
|
||||
|
||||
@@ -119,16 +119,15 @@ app.use(mw.seo)
|
||||
// Localization Engine
|
||||
// ----------------------------------------
|
||||
|
||||
lang
|
||||
.use(i18nextBackend)
|
||||
.use(i18nextMw.LanguageDetector)
|
||||
global.lang
|
||||
.use(i18nBackend)
|
||||
.init({
|
||||
load: 'languageOnly',
|
||||
ns: ['common', 'admin', 'auth', 'errors', 'git'],
|
||||
defaultNS: 'common',
|
||||
saveMissing: false,
|
||||
supportedLngs: ['en', 'fr'],
|
||||
preload: ['en', 'fr'],
|
||||
preload: [appconfig.lang],
|
||||
lng: appconfig.lang,
|
||||
fallbackLng: 'en',
|
||||
backend: {
|
||||
loadPath: path.join(SERVERPATH, 'locales/{{lng}}/{{ns}}.json')
|
||||
@@ -139,7 +138,6 @@ lang
|
||||
// View Engine Setup
|
||||
// ----------------------------------------
|
||||
|
||||
app.use(i18nextMw.handle(lang))
|
||||
app.set('views', path.join(SERVERPATH, 'views'))
|
||||
app.set('view engine', 'pug')
|
||||
|
||||
@@ -151,7 +149,9 @@ app.use(bodyParser.urlencoded({ extended: false, limit: '1mb' }))
|
||||
// ----------------------------------------
|
||||
|
||||
app.locals._ = require('lodash')
|
||||
app.locals.t = global.lang.t.bind(global.lang)
|
||||
app.locals.moment = require('moment')
|
||||
app.locals.moment.locale(appconfig.lang)
|
||||
app.locals.appconfig = appconfig
|
||||
app.use(mw.flash)
|
||||
|
||||
@@ -187,7 +187,7 @@ app.use(function (err, req, res, next) {
|
||||
// Start HTTP server
|
||||
// ----------------------------------------
|
||||
|
||||
winston.info('Starting HTTP/WS server on port ' + appconfig.port + '...')
|
||||
global.winston.info('Starting HTTP/WS server on port ' + appconfig.port + '...')
|
||||
|
||||
app.set('port', appconfig.port)
|
||||
var server = http.createServer(app)
|
||||
@@ -202,10 +202,10 @@ server.on('error', (error) => {
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
winston.error('Listening on port ' + appconfig.port + ' requires elevated privileges!')
|
||||
global.winston.error('Listening on port ' + appconfig.port + ' requires elevated privileges!')
|
||||
return process.exit(1)
|
||||
case 'EADDRINUSE':
|
||||
winston.error('Port ' + appconfig.port + ' is already in use!')
|
||||
global.winston.error('Port ' + appconfig.port + ' is already in use!')
|
||||
return process.exit(1)
|
||||
default:
|
||||
throw error
|
||||
@@ -213,7 +213,7 @@ server.on('error', (error) => {
|
||||
})
|
||||
|
||||
server.on('listening', () => {
|
||||
winston.info('HTTP/WS server started successfully! [RUNNING]')
|
||||
global.winston.info('HTTP/WS server started successfully! [RUNNING]')
|
||||
})
|
||||
|
||||
// ----------------------------------------
|
||||
@@ -248,7 +248,7 @@ bgAgent.on('message', m => {
|
||||
|
||||
switch (m.action) {
|
||||
case 'searchAdd':
|
||||
search.add(m.content)
|
||||
global.search.add(m.content)
|
||||
break
|
||||
}
|
||||
})
|
||||
|
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
/* global appconfig, appdata, db, winston */
|
||||
/* global appconfig, appdata, db, lang, winston */
|
||||
|
||||
const fs = require('fs')
|
||||
|
||||
|
@@ -21,7 +21,6 @@ module.exports = {
|
||||
*/
|
||||
init () {
|
||||
let self = this
|
||||
global.Mongoose = modb
|
||||
|
||||
let dbModelsPath = path.join(SERVERPATH, 'models')
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, git, lang, mark, rights, search, winston */
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const path = require('path')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global lang, winston */
|
||||
|
||||
const Git = require('git-wrapper2-promise')
|
||||
const Promise = require('bluebird')
|
||||
const path = require('path')
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global lang, winston */
|
||||
|
||||
const path = require('path')
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global winston */
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const _ = require('lodash')
|
||||
const searchIndex = require('./search-index')
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global winston */
|
||||
|
||||
const Promise = require('bluebird')
|
||||
const crypto = require('crypto')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, git, lang, upl */
|
||||
|
||||
const path = require('path')
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, lang, lcdata, upl, winston */
|
||||
|
||||
const path = require('path')
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
/* global appdata, rights */
|
||||
|
||||
const moment = require('moment-timezone')
|
||||
|
||||
/**
|
||||
* Authentication middleware
|
||||
*
|
||||
@@ -34,12 +32,6 @@ module.exports = (req, res, next) => {
|
||||
return res.render('error-forbidden')
|
||||
}
|
||||
|
||||
// Set i18n locale
|
||||
|
||||
req.i18n.changeLanguage(req.user.lang)
|
||||
res.locals.userMoment = moment
|
||||
res.locals.userMoment.locale(req.user.lang)
|
||||
|
||||
// Expose user data
|
||||
|
||||
res.locals.user = req.user
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const Mongoose = require('mongoose')
|
||||
|
||||
/**
|
||||
* BruteForce schema
|
||||
*
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const Mongoose = require('mongoose')
|
||||
|
||||
/**
|
||||
* Entry schema
|
||||
*
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const Mongoose = require('mongoose')
|
||||
|
||||
/**
|
||||
* Upload File schema
|
||||
*
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const Mongoose = require('mongoose')
|
||||
|
||||
/**
|
||||
* Upload Folder schema
|
||||
*
|
||||
|
@@ -1,5 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
/* global db, lang */
|
||||
|
||||
const Mongoose = require('mongoose')
|
||||
const Promise = require('bluebird')
|
||||
const bcrypt = require('bcryptjs-then')
|
||||
const _ = require('lodash')
|
||||
|
Reference in New Issue
Block a user