Fix checkUploadType after upgrade to file-type 17

This package is now ESM-only, so we need to `import()` it and
raise the oldest supported Node version.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-12-02 17:30:47 +01:00
parent b6a2a618bb
commit 6acb23f26d
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
2 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,6 @@
const Router = require('express').Router
const formidable = require('formidable')
const path = require('path')
const FileType = require('file-type')
const fs = require('fs')
const os = require('os')
const rimraf = require('rimraf')
@ -17,7 +16,8 @@ const imageRouter = (module.exports = Router())
async function checkUploadType (filePath) {
const extension = path.extname(filePath).toLowerCase()
let typeFromMagic = await FileType.fromFile(filePath)
const FileType = await import('file-type')
let typeFromMagic = await FileType.fileTypeFromFile(filePath)
if (extension === '.svg' && (typeFromMagic === undefined || typeFromMagic.mime === 'application/xml')) {
const fileContent = fs.readFileSync(filePath)
if (isSvg(fileContent)) {

View file

@ -110,7 +110,7 @@
"**/request": "^2.88.0"
},
"engines": {
"node": "12.x || 14.x || 16.x"
"node": "^12.20.0 || ^14.13.1 || 16.x"
},
"bugs": "https://github.com/hedgedoc/hedgedoc/issues",
"keywords": [