regenerate package-lock and fixed config references
This commit is contained in:
1 parent
18157ad2a0
commit
90bcb306f7
3 files changed
+30
-22
No files matched your search
Generated
+20
-12
@@ -515,9 +515,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "26.6.5",
|
"version": "26.6.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz",
|
||||||
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
|
"integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1080,12 +1080,16 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/encodeurl": {
|
"node_modules/encodeurl": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz",
|
||||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
"integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-define-property": {
|
"node_modules/es-define-property": {
|
||||||
@@ -1505,15 +1509,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/on-finished": {
|
"node_modules/on-finished": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
|
||||||
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ee-first": "1.1.1"
|
"ee-first": "1.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/once": {
|
"node_modules/once": {
|
||||||
@@ -1562,9 +1570,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.16.1",
|
"version": "6.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
|
||||||
"integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==",
|
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-define-property": "^1.0.1",
|
"es-define-property": "^1.0.1",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { execFileSync } from 'child_process';
|
import { execFileSync } from 'child_process';
|
||||||
import { THUMB_DIR, RESIZE_DIR } from '../config';
|
|
||||||
import { safeResolveIn } from '../utils/path.utils';
|
import { safeResolveIn } from '../utils/path.utils';
|
||||||
|
import {CONFIG} from "../config/config";
|
||||||
|
|
||||||
export class MediaService {
|
export class MediaService {
|
||||||
static getVideoDimensions(videoPath: string): { width: number; height: number } {
|
static getVideoDimensions(videoPath: string): { width: number; height: number } {
|
||||||
@@ -26,7 +26,7 @@ export class MediaService {
|
|||||||
try {
|
try {
|
||||||
const stat = fs.statSync(videoPath);
|
const stat = fs.statSync(videoPath);
|
||||||
const parsedRel = path.posix.parse(relVideoUrlPath);
|
const parsedRel = path.posix.parse(relVideoUrlPath);
|
||||||
const cacheThumbPath = safeResolveIn(THUMB_DIR, path.posix.join(parsedRel.dir, `${parsedRel.name}.webp`));
|
const cacheThumbPath = safeResolveIn(CONFIG.THUMB_DIR, path.posix.join(parsedRel.dir, `${parsedRel.name}.webp`));
|
||||||
|
|
||||||
if (!cacheThumbPath) return null;
|
if (!cacheThumbPath) return null;
|
||||||
|
|
||||||
@@ -71,11 +71,11 @@ export class MediaService {
|
|||||||
.createHash('sha1')
|
.createHash('sha1')
|
||||||
.update(`${reqPath}:${fileMtime}:${width}`)
|
.update(`${reqPath}:${fileMtime}:${width}`)
|
||||||
.digest('hex');
|
.digest('hex');
|
||||||
const cachedFile = path.join(RESIZE_DIR, `${cacheKey}${ext}`);
|
const cachedFile = path.join(CONFIG.RESIZE_DIR, `${cacheKey}${ext}`);
|
||||||
|
|
||||||
if (!fs.existsSync(cachedFile)) {
|
if (!fs.existsSync(cachedFile)) {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(RESIZE_DIR, { recursive: true });
|
fs.mkdirSync(CONFIG.RESIZE_DIR, { recursive: true });
|
||||||
execFileSync('/usr/bin/convert', [
|
execFileSync('/usr/bin/convert', [
|
||||||
filePath,
|
filePath,
|
||||||
'-coalesce',
|
'-coalesce',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import { STORAGE_DIR, ROOT_DOMAIN, SUPPORTED_VIDEOS, SUPPORTED_IMAGES } from '../config';
|
import { CONFIG } from '../config/config';
|
||||||
import { safeResolveIn } from '../utils/path.utils';
|
import { safeResolveIn } from '../utils/path.utils';
|
||||||
import { MediaService } from './media.service';
|
import { MediaService } from './media.service';
|
||||||
import { EmbedService } from './embed.service';
|
import { EmbedService } from './embed.service';
|
||||||
@@ -9,7 +9,7 @@ import { send403, send404, renderVideoEmbed } from '../views/templates';
|
|||||||
|
|
||||||
export class CdnResolver {
|
export class CdnResolver {
|
||||||
static handleRequest(reqPath: string, query: any, res: Response) {
|
static handleRequest(reqPath: string, query: any, res: Response) {
|
||||||
let filePath = safeResolveIn(STORAGE_DIR, reqPath);
|
let filePath = safeResolveIn(CONFIG.STORAGE_DIR, reqPath);
|
||||||
|
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
return send403(res);
|
return send403(res);
|
||||||
@@ -27,10 +27,10 @@ export class CdnResolver {
|
|||||||
const ext = path.extname(filePath).toLowerCase();
|
const ext = path.extname(filePath).toLowerCase();
|
||||||
const filename = path.basename(filePath);
|
const filename = path.basename(filePath);
|
||||||
const encodedPath = reqPath.split('/').map(encodeURIComponent).join('/');
|
const encodedPath = reqPath.split('/').map(encodeURIComponent).join('/');
|
||||||
const displayUrl = `${ROOT_DOMAIN}${encodedPath}`;
|
const displayUrl = `${CONFIG.ROOT_DOMAIN}${encodedPath}`;
|
||||||
|
|
||||||
// --- A. IMAGES: Raw inline passthrough or dynamic resize ---
|
// --- A. IMAGES: Raw inline passthrough or dynamic resize ---
|
||||||
if (SUPPORTED_IMAGES.has(ext)) {
|
if (CONFIG.SUPPORTED_IMAGES.has(ext)) {
|
||||||
const rawWidth = (query.w || query.width) as string | undefined;
|
const rawWidth = (query.w || query.width) as string | undefined;
|
||||||
if (rawWidth) {
|
if (rawWidth) {
|
||||||
const cachedFile = MediaService.getResizedImage(filePath, reqPath, rawWidth, stat.mtimeMs, ext);
|
const cachedFile = MediaService.getResizedImage(filePath, reqPath, rawWidth, stat.mtimeMs, ext);
|
||||||
@@ -43,7 +43,7 @@ export class CdnResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- B. VIDEOS: Existing video web player / raw handling ---
|
// --- B. VIDEOS: Existing video web player / raw handling ---
|
||||||
if (SUPPORTED_VIDEOS.has(ext)) {
|
if (CONFIG.SUPPORTED_VIDEOS.has(ext)) {
|
||||||
if (query.raw === '1') {
|
if (query.raw === '1') {
|
||||||
return res.sendFile(filePath);
|
return res.sendFile(filePath);
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ export class CdnResolver {
|
|||||||
|
|
||||||
const parsedUrl = path.posix.parse(reqPath);
|
const parsedUrl = path.posix.parse(reqPath);
|
||||||
const webpUrlPath = path.posix.join(parsedUrl.dir, `${parsedUrl.name}.webp`);
|
const webpUrlPath = path.posix.join(parsedUrl.dir, `${parsedUrl.name}.webp`);
|
||||||
const imageUrl = `${ROOT_DOMAIN}${webpUrlPath.split('/').map(encodeURIComponent).join('/')}`;
|
const imageUrl = `${CONFIG.ROOT_DOMAIN}${webpUrlPath.split('/').map(encodeURIComponent).join('/')}`;
|
||||||
const rawVideoUrl = `${displayUrl}?raw=1`;
|
const rawVideoUrl = `${displayUrl}?raw=1`;
|
||||||
const mimeType = ext === '.webm' ? 'video/webm' : 'video/mp4';
|
const mimeType = ext === '.webm' ? 'video/webm' : 'video/mp4';
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user