|
@@ -1,14 +1,22 @@
|
|
|
-const debug = require('debug')('growi:crowi');
|
|
|
|
|
-const logger = require('@alias/logger')('growi:crowi');
|
|
|
|
|
-const pkg = require('@root/package.json');
|
|
|
|
|
-const InterceptorManager = require('@commons/service/interceptor-manager');
|
|
|
|
|
-const CdnResourcesService = require('@commons/service/cdn-resources-service');
|
|
|
|
|
-const Xss = require('~/services/xss');
|
|
|
|
|
-const { getMongoUri, mongoOptions } = require('@commons/util/mongoose-utils');
|
|
|
|
|
|
|
+/* eslint-disable @typescript-eslint/no-this-alias */
|
|
|
|
|
|
|
|
-const path = require('path');
|
|
|
|
|
|
|
+import path from 'path';
|
|
|
|
|
+import mongoose from 'mongoose';
|
|
|
|
|
|
|
|
-const mongoose = require('mongoose');
|
|
|
|
|
|
|
+import pkg from '^/package.json';
|
|
|
|
|
+
|
|
|
|
|
+import InterceptorManager from '~/services/interceptor-manager';
|
|
|
|
|
+import Xss from '~/services/xss';
|
|
|
|
|
+import loggerFactory from '~/utils/logger';
|
|
|
|
|
+import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
|
|
|
|
|
+import { projectRoot } from '~/utils/project-dir-utils';
|
|
|
|
|
+
|
|
|
|
|
+import ConfigManager from '../service/config-manager';
|
|
|
|
|
+import AclService from '../service/acl';
|
|
|
|
|
+import AttachmentService from '../service/attachment';
|
|
|
|
|
+
|
|
|
|
|
+const logger = loggerFactory('growi:crowi');
|
|
|
|
|
+const httpErrorHandler = require('../middlewares/http-error-handler');
|
|
|
|
|
|
|
|
const models = require('../models');
|
|
const models = require('../models');
|
|
|
|
|
|
|
@@ -17,7 +25,7 @@ const httpErrorHandler = require('../middlewares/http-error-handler');
|
|
|
|
|
|
|
|
const sep = path.sep;
|
|
const sep = path.sep;
|
|
|
|
|
|
|
|
-function Crowi(rootdir) {
|
|
|
|
|
|
|
+function Crowi() {
|
|
|
const self = this;
|
|
const self = this;
|
|
|
|
|
|
|
|
this.version = pkg.version;
|
|
this.version = pkg.version;
|
|
@@ -266,7 +274,6 @@ Crowi.prototype.setupSessionConfig = async function() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Crowi.prototype.setupConfigManager = async function() {
|
|
Crowi.prototype.setupConfigManager = async function() {
|
|
|
- const ConfigManager = require('../service/config-manager');
|
|
|
|
|
this.configManager = new ConfigManager(this.model('Config'));
|
|
this.configManager = new ConfigManager(this.model('Config'));
|
|
|
return this.configManager.loadConfigs();
|
|
return this.configManager.loadConfigs();
|
|
|
};
|
|
};
|
|
@@ -336,7 +343,7 @@ Crowi.prototype.getRestQiitaAPIService = function() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Crowi.prototype.setupPassport = async function() {
|
|
Crowi.prototype.setupPassport = async function() {
|
|
|
- debug('Passport is enabled');
|
|
|
|
|
|
|
+ logger.debug('Passport is enabled');
|
|
|
|
|
|
|
|
// initialize service
|
|
// initialize service
|
|
|
const PassportService = require('../service/passport');
|
|
const PassportService = require('../service/passport');
|
|
@@ -368,12 +375,12 @@ Crowi.prototype.setupPassport = async function() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Crowi.prototype.setupSearcher = async function() {
|
|
Crowi.prototype.setupSearcher = async function() {
|
|
|
- const SearchService = require('@server/service/search');
|
|
|
|
|
|
|
+ const SearchService = require('~/server/service/search');
|
|
|
this.searchService = new SearchService(this);
|
|
this.searchService = new SearchService(this);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Crowi.prototype.setupMailer = async function() {
|
|
Crowi.prototype.setupMailer = async function() {
|
|
|
- const MailService = require('@server/service/mail');
|
|
|
|
|
|
|
+ const MailService = require('~/server/service/mail');
|
|
|
this.mailService = new MailService(this);
|
|
this.mailService = new MailService(this);
|
|
|
|
|
|
|
|
// add as a message handler
|
|
// add as a message handler
|
|
@@ -467,7 +474,7 @@ Crowi.prototype.buildServer = async function() {
|
|
|
// use bunyan
|
|
// use bunyan
|
|
|
if (env === 'production') {
|
|
if (env === 'production') {
|
|
|
const expressBunyanLogger = require('express-bunyan-logger');
|
|
const expressBunyanLogger = require('express-bunyan-logger');
|
|
|
- const logger = require('@alias/logger')('express');
|
|
|
|
|
|
|
+ const logger = loggerFactory('express');
|
|
|
express.use(expressBunyanLogger({
|
|
express.use(expressBunyanLogger({
|
|
|
logger,
|
|
logger,
|
|
|
excludes: ['*'],
|
|
excludes: ['*'],
|
|
@@ -554,7 +561,6 @@ Crowi.prototype.setUpXss = async function() {
|
|
|
* setup AclService
|
|
* setup AclService
|
|
|
*/
|
|
*/
|
|
|
Crowi.prototype.setUpAcl = async function() {
|
|
Crowi.prototype.setUpAcl = async function() {
|
|
|
- const AclService = require('../service/acl');
|
|
|
|
|
if (this.aclService == null) {
|
|
if (this.aclService == null) {
|
|
|
this.aclService = new AclService(this.configManager);
|
|
this.aclService = new AclService(this.configManager);
|
|
|
}
|
|
}
|
|
@@ -618,7 +624,6 @@ Crowi.prototype.setUpFileUploaderSwitchService = async function() {
|
|
|
* setup AttachmentService
|
|
* setup AttachmentService
|
|
|
*/
|
|
*/
|
|
|
Crowi.prototype.setupAttachmentService = async function() {
|
|
Crowi.prototype.setupAttachmentService = async function() {
|
|
|
- const AttachmentService = require('../service/attachment');
|
|
|
|
|
if (this.attachmentService == null) {
|
|
if (this.attachmentService == null) {
|
|
|
this.attachmentService = new AttachmentService(this);
|
|
this.attachmentService = new AttachmentService(this);
|
|
|
}
|
|
}
|