2017-03-28 07:25:36 +00:00
|
|
|
'use strict'
|
2017-06-01 08:47:52 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
2020-01-04 22:30:23 +00:00
|
|
|
const bodyParser = require('body-parser')
|
2020-12-23 07:43:14 +00:00
|
|
|
const mime = require('mime-types')
|
2017-03-28 07:25:36 +00:00
|
|
|
|
|
|
|
exports.isSQLite = function isSQLite (sequelize) {
|
|
|
|
return sequelize.options.dialect === 'sqlite'
|
|
|
|
}
|
2017-05-08 08:22:52 +00:00
|
|
|
|
|
|
|
exports.getImageMimeType = function getImageMimeType (imagePath) {
|
2020-12-23 14:16:28 +00:00
|
|
|
return mime.lookup(path.extname(imagePath))
|
2017-05-08 08:22:52 +00:00
|
|
|
}
|
2017-06-01 08:47:52 +00:00
|
|
|
|
|
|
|
exports.isRevealTheme = function isRevealTheme (theme) {
|
2017-06-02 10:34:35 +00:00
|
|
|
if (fs.existsSync(path.join(__dirname, '..', 'public', 'build', 'reveal.js', 'css', 'theme', theme + '.css'))) {
|
2017-06-01 08:47:52 +00:00
|
|
|
return theme
|
|
|
|
}
|
|
|
|
return undefined
|
|
|
|
}
|
2020-01-04 22:30:23 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
})
|