regenerate package-lock and fixed config references
CDN Resolver CI/CD / test-and-build (push) Failing after 12s
CDN Resolver CI/CD / deploy (push) Skipped

This commit is contained in:
itzMiney committed 2026-11-09 01:07:08 +01:00
1 parent 18157ad2a0
commit 90bcb306f7
3 files changed
+30 -22

No files matched your search

+20 -12
View File
@@ -515,9 +515,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "26.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
"version": "26.6.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz",
"integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1080,12 +1080,16 @@
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz",
"integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/es-define-property": {
@@ -1505,15 +1509,19 @@
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/once": {
@@ -1562,9 +1570,9 @@
}
},
"node_modules/qs": {
"version": "6.16.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz",
"integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==",
"version": "6.17.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
+4 -4
View File
@@ -2,8 +2,8 @@ import fs from 'fs';
import path from 'path';
import crypto from 'crypto';
import { execFileSync } from 'child_process';
import { THUMB_DIR, RESIZE_DIR } from '../config';
import { safeResolveIn } from '../utils/path.utils';
import {CONFIG} from "../config/config";
export class MediaService {
static getVideoDimensions(videoPath: string): { width: number; height: number } {
@@ -26,7 +26,7 @@ export class MediaService {
try {
const stat = fs.statSync(videoPath);
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;
@@ -71,11 +71,11 @@ export class MediaService {
.createHash('sha1')
.update(`${reqPath}:${fileMtime}:${width}`)
.digest('hex');
const cachedFile = path.join(RESIZE_DIR, `${cacheKey}${ext}`);
const cachedFile = path.join(CONFIG.RESIZE_DIR, `${cacheKey}${ext}`);
if (!fs.existsSync(cachedFile)) {
try {
fs.mkdirSync(RESIZE_DIR, { recursive: true });
fs.mkdirSync(CONFIG.RESIZE_DIR, { recursive: true });
execFileSync('/usr/bin/convert', [
filePath,
'-coalesce',
+6 -6
View File
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
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 { MediaService } from './media.service';
import { EmbedService } from './embed.service';
@@ -9,7 +9,7 @@ import { send403, send404, renderVideoEmbed } from '../views/templates';
export class CdnResolver {
static handleRequest(reqPath: string, query: any, res: Response) {
let filePath = safeResolveIn(STORAGE_DIR, reqPath);
let filePath = safeResolveIn(CONFIG.STORAGE_DIR, reqPath);
if (!filePath) {
return send403(res);
@@ -27,10 +27,10 @@ export class CdnResolver {
const ext = path.extname(filePath).toLowerCase();
const filename = path.basename(filePath);
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 ---
if (SUPPORTED_IMAGES.has(ext)) {
if (CONFIG.SUPPORTED_IMAGES.has(ext)) {
const rawWidth = (query.w || query.width) as string | undefined;
if (rawWidth) {
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 ---
if (SUPPORTED_VIDEOS.has(ext)) {
if (CONFIG.SUPPORTED_VIDEOS.has(ext)) {
if (query.raw === '1') {
return res.sendFile(filePath);
}
@@ -53,7 +53,7 @@ export class CdnResolver {
const parsedUrl = path.posix.parse(reqPath);
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 mimeType = ext === '.webm' ? 'video/webm' : 'video/mp4';