2017-03-28 03:25:36 -04:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
exports.isSQLite = function isSQLite (sequelize) {
|
|
|
|
return sequelize.options.dialect === 'sqlite'
|
|
|
|
}
|
2017-05-08 04:22:52 -04:00
|
|
|
|
2023-10-01 14:40:15 -04:00
|
|
|
exports.isMySQL = function isMySQL (sequelize) {
|
|
|
|
return ['mysql', 'mariadb'].includes(sequelize.options.dialect)
|
|
|
|
}
|
|
|
|
|
2017-05-08 04:22:52 -04:00
|
|
|
exports.getImageMimeType = function getImageMimeType (imagePath) {
|
2021-02-15 03:42:51 -05:00
|
|
|
const fileExtension = /[^.]+$/.exec(imagePath)
|
2017-05-08 04:22:52 -04:00
|
|
|
|
2020-09-29 13:12:29 -04:00
|
|
|
switch (fileExtension[0].toLowerCase()) {
|
2017-05-08 05:00:45 -04:00
|
|
|
case 'bmp':
|
|
|
|
return 'image/bmp'
|
|
|
|
case 'gif':
|
|
|
|
return 'image/gif'
|
|
|
|
case 'jpg':
|
|
|
|
case 'jpeg':
|
|
|
|
return 'image/jpeg'
|
|
|
|
case 'png':
|
|
|
|
return 'image/png'
|
|
|
|
case 'tiff':
|
|
|
|
return 'image/tiff'
|
2019-06-18 10:57:58 -04:00
|
|
|
case 'svg':
|
|
|
|
return 'image/svg+xml'
|
2017-05-08 04:22:52 -04:00
|
|
|
default:
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
}
|
2021-07-20 17:56:54 -04:00
|
|
|
|
|
|
|
exports.useUnless = function excludeRoute (paths, middleware) {
|
|
|
|
return function (req, res, next) {
|
|
|
|
if (paths.includes(req.path)) {
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
return middleware(req, res, next)
|
|
|
|
}
|
|
|
|
}
|