Skip to content

Commit

Permalink
server: fix stupid esm mime dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Koushik Dutta authored and Koushik Dutta committed Jan 13, 2024
1 parent bd7c7de commit f0357d4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
25 changes: 9 additions & 16 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
"linkfs": "^2.1.0",
"lodash": "^4.17.21",
"memfs": "^4.6.0",
"mime": "^3.0.0",
"mime-db": "^1.52.0",
"nan": "^2.18.0",
"node-dijkstra": "^2.5.0",
"node-forge": "^1.3.1",
"node-gyp": "^10.0.1",
"router": "^1.3.8",
"semver": "^7.5.4",
"send": "^0.18.0",
"sharp": "^0.33.2",
"source-map-support": "^0.5.21",
"tar": "^6.2.0",
Expand All @@ -43,7 +44,7 @@
"@types/http-auth": "^4.1.4",
"@types/ip": "^1.1.3",
"@types/lodash": "^4.14.202",
"@types/mime": "^3.0.4",
"@types/mime-db": "^1.43.5",
"@types/node-dijkstra": "^2.5.6",
"@types/node-forge": "^1.3.11",
"@types/pem": "^1.14.4",
Expand Down
8 changes: 0 additions & 8 deletions server/src/http-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import net from 'net';
import { join as pathJoin } from 'path';
import { RpcPeer } from "./rpc";

const mime = require('mime/lite');
export class HttpResponseImpl implements HttpResponse {
constructor(public res: Response, public unzippedDir: string, public filesPath: string) {
}
Expand Down Expand Up @@ -49,13 +48,6 @@ export class HttpResponseImpl implements HttpResponse {
this.res.status(options.code);
this.#setHeaders(options);

if (!this.res.getHeader('Content-Type')) {
const type = mime.getType(path);
if (type) {
this.res.contentType(mime.getExtension(type));
}
}

let filePath = pathJoin(this.unzippedDir, 'fs', path);
if (!fs.existsSync(filePath)) {
filePath = pathJoin(this.filesPath, path);
Expand Down
6 changes: 3 additions & 3 deletions server/src/plugin/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { BufferConverter, DeviceManager, FFmpegInput, MediaManager, MediaObject
import pathToFfmpeg from 'ffmpeg-static';
import fs from 'fs';
import https from 'https';
import mimeType from 'mime';
import Graph from 'node-dijkstra';
import os from 'os';
import path from 'path';
import MimeType from 'whatwg-mimetype';
import { MediaObject } from "./mediaobject";
import { MediaObjectRemote } from "./plugin-api";
import send from 'send';

function typeMatches(target: string, candidate: string): boolean {
// candidate will accept anything
Expand Down Expand Up @@ -78,7 +78,7 @@ export abstract class MediaManagerBase implements MediaManager {
}

const ab = await fs.promises.readFile(filename);
const mt = mimeType.getType(data.toString());
const mt = send.mime.lookup(filename);
const mo = this.createMediaObject(ab, mt);
return mo;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ export abstract class MediaManagerBase implements MediaManager {

ensureMediaObjectRemote(mediaObject: string | MediaObjectInterface): MediaObjectRemote {
if (typeof mediaObject === 'string') {
const mime = mimeType.getType(mediaObject);
const mime = send.mime.lookup(mediaObject);
return this.createMediaObjectRemote(mediaObject, mime);
}
return mediaObject as MediaObjectRemote;
Expand Down

0 comments on commit f0357d4

Please # to comment.