mirror of https://github.com/status-im/codimd.git
refactor: remove web folder
Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
parent
911bd773e1
commit
b4ec353fcd
10
app.js
10
app.js
|
@ -153,7 +153,7 @@ server.on('resumeSession', function (id, cb) {
|
|||
})
|
||||
|
||||
// middleware which blocks requests when we're too busy
|
||||
app.use(require('./lib/web/middleware/tooBusy'))
|
||||
app.use(require('./lib/middleware/tooBusy'))
|
||||
|
||||
app.use(flash())
|
||||
|
||||
|
@ -162,10 +162,10 @@ app.use(passport.initialize())
|
|||
app.use(passport.session())
|
||||
|
||||
// check uri is valid before going further
|
||||
app.use(require('./lib/web/middleware/checkURIValid'))
|
||||
app.use(require('./lib/middleware/checkURIValid'))
|
||||
// redirect url without trailing slashes
|
||||
app.use(require('./lib/web/middleware/redirectWithoutTrailingSlashes'))
|
||||
app.use(require('./lib/web/middleware/codiMDVersion'))
|
||||
app.use(require('./lib/middleware/redirectWithoutTrailingSlashes'))
|
||||
app.use(require('./lib/middleware/codiMDVersion'))
|
||||
|
||||
// routes need sessions
|
||||
// template files
|
||||
|
@ -206,7 +206,7 @@ app.locals.enableDropBoxSave = config.isDropboxEnable
|
|||
app.locals.enableGitHubGist = config.isGitHubEnable
|
||||
app.locals.enableGitlabSnippets = config.isGitlabSnippetsEnable
|
||||
|
||||
app.use(require('./lib/web/routes').router)
|
||||
app.use(require('./lib/routes').router)
|
||||
|
||||
// response not found if no any route matxches
|
||||
app.get('*', function (req, res) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const BitbucketStrategy = require('passport-bitbucket-oauth2').Strategy
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const bitbucketAuth = module.exports = Router()
|
|
@ -3,7 +3,7 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const dropboxAuth = module.exports = Router()
|
|
@ -4,12 +4,12 @@ const Router = require('express').Router
|
|||
const passport = require('passport')
|
||||
const validator = require('validator')
|
||||
const LocalStrategy = require('passport-local').Strategy
|
||||
const config = require('../../../config')
|
||||
const models = require('../../../models')
|
||||
const logger = require('../../../logger')
|
||||
const config = require('../../config')
|
||||
const models = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const { setReturnToFromReferer } = require('../utils')
|
||||
const { urlencodedParser } = require('../../utils')
|
||||
const response = require('../../../response')
|
||||
const response = require('../../response')
|
||||
|
||||
const emailAuth = module.exports = Router()
|
||||
|
|
@ -4,7 +4,7 @@ const Router = require('express').Router
|
|||
const passport = require('passport')
|
||||
const FacebookStrategy = require('passport-facebook').Strategy
|
||||
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const facebookAuth = module.exports = Router()
|
|
@ -3,8 +3,8 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const GithubStrategy = require('passport-github').Strategy
|
||||
const config = require('../../../config')
|
||||
const response = require('../../../response')
|
||||
const config = require('../../config')
|
||||
const response = require('../../response')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
const { URL } = require('url')
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const GitlabStrategy = require('passport-gitlab2').Strategy
|
||||
const config = require('../../../config')
|
||||
const response = require('../../../response')
|
||||
const config = require('../../config')
|
||||
const response = require('../../response')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
const HttpsProxyAgent = require('https-proxy-agent')
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
var GoogleStrategy = require('passport-google-oauth20').Strategy
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const googleAuth = module.exports = Router()
|
|
@ -3,9 +3,9 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const models = require('../../models')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
const models = require('../models')
|
||||
|
||||
const authRouter = module.exports = Router()
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const LDAPStrategy = require('passport-ldapauth')
|
||||
const config = require('../../../config')
|
||||
const models = require('../../../models')
|
||||
const logger = require('../../../logger')
|
||||
const config = require('../../config')
|
||||
const models = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const { setReturnToFromReferer } = require('../utils')
|
||||
const { urlencodedParser } = require('../../utils')
|
||||
const response = require('../../../response')
|
||||
const response = require('../../response')
|
||||
|
||||
const ldapAuth = module.exports = Router()
|
||||
|
|
@ -5,7 +5,7 @@ const Router = require('express').Router
|
|||
const passport = require('passport')
|
||||
const MattermostClient = require('mattermost-redux/client/client4').default
|
||||
const OAuthStrategy = require('passport-oauth2').Strategy
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const mattermostAuth = module.exports = Router()
|
|
@ -3,7 +3,7 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const { Strategy, InternalOAuthError } = require('passport-oauth2')
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const oauth2Auth = module.exports = Router()
|
|
@ -3,9 +3,9 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const OpenIDStrategy = require('@passport-next/passport-openid').Strategy
|
||||
const config = require('../../../config')
|
||||
const models = require('../../../models')
|
||||
const logger = require('../../../logger')
|
||||
const config = require('../../config')
|
||||
const models = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const { urlencodedParser } = require('../../utils')
|
||||
const { setReturnToFromReferer } = require('../utils')
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const SamlStrategy = require('passport-saml').Strategy
|
||||
const config = require('../../../config')
|
||||
const models = require('../../../models')
|
||||
const logger = require('../../../logger')
|
||||
const config = require('../../config')
|
||||
const models = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const { urlencodedParser } = require('../../utils')
|
||||
const fs = require('fs')
|
||||
const intersection = function (array1, array2) { return array1.filter((n) => array2.includes(n)) }
|
|
@ -4,7 +4,7 @@ const Router = require('express').Router
|
|||
const passport = require('passport')
|
||||
const TwitterStrategy = require('passport-twitter').Strategy
|
||||
|
||||
const config = require('../../../config')
|
||||
const config = require('../../config')
|
||||
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
|
||||
|
||||
const twitterAuth = module.exports = Router()
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
const models = require('../../models')
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const models = require('../models')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
|
||||
exports.setReturnToFromReferer = function setReturnToFromReferer (req) {
|
||||
var referer = req.get('referer')
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const config = require('../../config')
|
||||
const { responseError } = require('../../response')
|
||||
const config = require('../config')
|
||||
const { responseError } = require('../response')
|
||||
|
||||
exports.errorForbidden = (req, res) => {
|
||||
if (req.user) {
|
|
@ -4,10 +4,10 @@
|
|||
var LZString = require('@hackmd/lz-string')
|
||||
|
||||
// core
|
||||
var config = require('../../config')
|
||||
var logger = require('../../logger')
|
||||
var response = require('../../response')
|
||||
var models = require('../../models')
|
||||
var config = require('../config')
|
||||
var logger = require('../logger')
|
||||
var response = require('../response')
|
||||
var models = require('../models')
|
||||
|
||||
function getHistory (userid, callback) {
|
||||
models.User.findOne({
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const config = require('../../config')
|
||||
const { User } = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const { User } = require('../models')
|
||||
const logger = require('../logger')
|
||||
|
||||
exports.showIndex = async (req, res) => {
|
||||
const isLogin = req.isAuthenticated()
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
const path = require('path')
|
||||
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
|
||||
const azure = require('azure-storage')
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
const URL = require('url').URL
|
||||
const path = require('path')
|
||||
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
|
||||
exports.uploadImage = function (imagePath, callback) {
|
||||
if (!imagePath || typeof imagePath !== 'string') {
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
|
||||
const imgur = require('@hackmd/imgur')
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
const Router = require('express').Router
|
||||
const formidable = require('formidable')
|
||||
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const response = require('../../response')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
const response = require('../response')
|
||||
|
||||
const imageRouter = module.exports = Router()
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict'
|
||||
const config = require('../../config')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
|
||||
const lutim = require('lutim')
|
||||
const lutim = require('lib/imageRouter/lutim')
|
||||
|
||||
exports.uploadImage = function (imagePath, callback) {
|
||||
if (!imagePath || typeof imagePath !== 'string') {
|
|
@ -2,11 +2,11 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const config = require('../../config')
|
||||
const { getImageMimeType } = require('../../utils')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const { getImageMimeType } = require('../utils')
|
||||
const logger = require('../logger')
|
||||
|
||||
const Minio = require('minio')
|
||||
const Minio = require('lib/imageRouter/minio')
|
||||
const minioClient = new Minio.Client({
|
||||
endPoint: config.minio.endPoint,
|
||||
port: config.minio.port,
|
|
@ -2,9 +2,9 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const config = require('../../config')
|
||||
const { getImageMimeType } = require('../../utils')
|
||||
const logger = require('../../logger')
|
||||
const config = require('../config')
|
||||
const { getImageMimeType } = require('../utils')
|
||||
const logger = require('../logger')
|
||||
|
||||
const AWS = require('aws-sdk')
|
||||
const awsConfig = new AWS.Config(config.s3)
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const logger = require('../../logger')
|
||||
const response = require('../../response')
|
||||
const logger = require('../logger')
|
||||
const response = require('../response')
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
try {
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const config = require('../../config')
|
||||
const config = require('../config')
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
res.set({
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const config = require('../../config')
|
||||
const config = require('../config')
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
if (req.method === 'GET' && req.path.substr(-1) === '/' && req.path.length > 1) {
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
const toobusy = require('toobusy-js')
|
||||
|
||||
const config = require('../../config')
|
||||
const response = require('../../response')
|
||||
const config = require('../config')
|
||||
const response = require('../response')
|
||||
|
||||
toobusy.maxLag(config.responseMaxLag)
|
||||
|
|
@ -14,7 +14,7 @@ const get = require('lodash/get')
|
|||
// core
|
||||
const config = require('../config')
|
||||
const logger = require('../logger')
|
||||
const history = require('../web/history')
|
||||
const history = require('../history')
|
||||
const models = require('../models')
|
||||
|
||||
// ot
|
||||
|
|
|
@ -14,7 +14,7 @@ const config = require('./config')
|
|||
const logger = require('./logger')
|
||||
const models = require('./models')
|
||||
const utils = require('./utils')
|
||||
const history = require('./web/history')
|
||||
const history = require('./history')
|
||||
|
||||
// public
|
||||
exports.responseError = responseError
|
||||
|
|
|
@ -10,7 +10,7 @@ const errorPageController = require('./errorPage')
|
|||
const statusController = require('./status')
|
||||
const historyController = require('./history')
|
||||
const userController = require('./user')
|
||||
const response = require('../response')
|
||||
const response = require('./response')
|
||||
const appRouter = Router()
|
||||
|
||||
// register route
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const realtime = require('../../realtime/realtime')
|
||||
const config = require('../../config')
|
||||
const realtime = require('../realtime/realtime')
|
||||
const config = require('../config')
|
||||
|
||||
exports.getStatus = async (req, res) => {
|
||||
const data = await realtime.getStatus()
|
|
@ -3,11 +3,11 @@
|
|||
const archiver = require('archiver')
|
||||
const async = require('async')
|
||||
|
||||
const response = require('../../response')
|
||||
const config = require('../../config')
|
||||
const models = require('../../models')
|
||||
const logger = require('../../logger')
|
||||
const { generateAvatar } = require('../../letter-avatars')
|
||||
const response = require('../response')
|
||||
const config = require('../config')
|
||||
const models = require('../models')
|
||||
const logger = require('../logger')
|
||||
const { generateAvatar } = require('../letter-avatars')
|
||||
|
||||
exports.getMe = async (req, res) => {
|
||||
if (!req.isAuthenticated()) {
|
16
lib/utils.js
16
lib/utils.js
|
@ -1,6 +1,7 @@
|
|||
'use strict'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const bodyParser = require('body-parser')
|
||||
|
||||
exports.isSQLite = function isSQLite (sequelize) {
|
||||
return sequelize.options.dialect === 'sqlite'
|
||||
|
@ -32,3 +33,18 @@ exports.isRevealTheme = function isRevealTheme (theme) {
|
|||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
exports.wrap = innerHandler => (req, res, next) => innerHandler(req, res).catch(err => next(err))
|
||||
|
||||
// create application/x-www-form-urlencoded parser
|
||||
exports.urlencodedParser = bodyParser.urlencoded({
|
||||
extended: false,
|
||||
limit: 1024 * 1024 * 10 // 10 mb
|
||||
})
|
||||
|
||||
// create text/markdown parser
|
||||
exports.markdownParser = bodyParser.text({
|
||||
inflate: true,
|
||||
type: ['text/plain', 'text/markdown'],
|
||||
limit: 1024 * 1024 * 10 // 10 mb
|
||||
})
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const bodyParser = require('body-parser')
|
||||
|
||||
exports.wrap = innerHandler => (req, res, next) => innerHandler(req, res).catch(err => next(err))
|
||||
|
||||
// create application/x-www-form-urlencoded parser
|
||||
exports.urlencodedParser = bodyParser.urlencoded({
|
||||
extended: false,
|
||||
limit: 1024 * 1024 * 10 // 10 mb
|
||||
})
|
||||
|
||||
// create text/markdown parser
|
||||
exports.markdownParser = bodyParser.text({
|
||||
inflate: true,
|
||||
type: ['text/plain', 'text/markdown'],
|
||||
limit: 1024 * 1024 * 10 // 10 mb
|
||||
})
|
Loading…
Reference in New Issue