This commit is contained in:
2026-04-07 14:50:23 +09:00
commit b4e485502b
4778 changed files with 2017091 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
var express = require("express");
var router = express.Router();
var util = require("util");
var utils = require("../../../src/utils");
var crossCtl = require("../../../src/crossCtl");
var path = require("path");
const fs = require("fs");
// operation
const FileType = require("file-type");
router.use(function (req, res, next) {
// console.log("huk ck!!!, req.headers.referer=", req.headers.referer);
// console.log("huk ck!!!, req.headers=", req.headers);
// console.log("huk ck!!!, req.url=", req.url);
var passcard =
req.headers["user-agent"] != undefined ? req.headers["user-agent"] : "";
if (
req.isAuthenticated() ||
(passcard.startsWith("Dart/") && passcard.endsWith(" (dart:io)")) ||
passcard == "usm"
) {
var ckRootPath = crossCtl.sConfig.contentKeeperPath
? path.join(crossCtl.sConfig.contentKeeperPath, req.url)
: path.join(
__dirname,
"../../../",
"modules",
crossCtl.sConfig.type,
"contents",
req.url
);
var targetPath = ckRootPath;
// console.log("in ck, targetPath=", targetPath);
let mimeType = utils.getMimeFromPath(targetPath);
// console.log("in ck, mimeType=", mimeType);
fs.access(targetPath, fs.constants.F_OK, function (error) {
if (error) {
next();
} else {
req.workTag.res().status(200).type(mimeType).sendFile(targetPath);
}
});
} else {
req.workTag.res().status(401).send("401 Unauthorized");
}
});
module.exports = router;