From fd606996fd8b8a6b560c24d2319aebe08ee7042a Mon Sep 17 00:00:00 2001 From: Holly Date: Sat, 25 Jan 2025 12:21:55 +0000 Subject: [PATCH] send files properly --- bun.lockb | Bin 70383 -> 70082 bytes controllers/Controller.ts | 10 ++-------- index.ts | 24 ++++++++++++++++++------ package.json | 18 +++++++++--------- utilities/HeaderUtility.ts | 15 +++++++++++++++ 5 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 utilities/HeaderUtility.ts diff --git a/bun.lockb b/bun.lockb index 0b029f2c6d3345cbac53095b210f332a578f9e3d..93d7318d011bb90110e43694bcd1e99bb8cb6666 100755 GIT binary patch delta 9007 zcmeHNc~n$Kv%fupaFG!ZRE9-x!<8KbBr+H^5l5o94QO0Oc0nP43T|MOXiPMk(je}d z#RW;CxF#xwXarp2f`E{G#w;3_XkrrMb9ukIcg8I5``$V4|98(R>i)W`yQ`|Jx_fT( z)B9Fc?^-SQ>tSE}$%i#JFY3SPrw`C?&Fbt?_gu}sryW~XAL>YRw(KkjauO0hhgKN9 zG($gGk-xgI##)l>B&jGjdFqVh97#F=>;#;Xl9b4z+kqW`v(u+#F}`RcNm}6T;P&9P z;M_jijQ4`K1t#!z;Dz8W;A!CP!E>`S)ANEP$q0;b3X6u~r4=elF_0s;KL9I`n3a{0 zo-9erP|o%47>#*Oavtj;wE|}OMsOYYBUG}Yvmx&cZqr(lT)|UJxp}_RbJ8C{Yi@6v zGDB$}0AXjSR^)*f*3cq&RZD#}KAst7ed5jiHA1O25c?8bresa$!eR^~qof*~NA8VY z*cBbXF?dl*dS-HFdT!o7HcXh$|JoC?cfBDa~EJ}o`ll$+a(31*#2P|oiE=h(|o&hK|B#>ZKN?sBw|c6^S&aHm1N^hx(taKk<>{^NpbmVPgjM^( zVP2}My}ecSvrTzvz8T2{Jt57L{wvB^O;2EU)ztK<$?%%=W=FN$xsz&EZk{P`dTw&A zH84*>`n0s56-?vK5TC#tVh-Remz188!sP;(hd1SWivlv=KIZj z4LJNfqR79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^8!0*YOr(+D(`%C+~iS>=kieEv>GUZND!!!Co z>%HT;c-PMVOET4L2kmkAv{q2mu!Fu0W zReZ3dhC_8PUWC-tZAzb<)w@}*F=Nds4>u;7dRhAMrM73?@iC6ma}#}bRxb|F9{g1} z^!Ky%)Hj3m9#S7>uL-PPV2|d$-bfkjPSoz49zRSzJf}BUZ!wcbKfhViym2?AEGt4e z%{Uhz&QSTe08N!Ay*THux$jA>&bw)zc~YnI{%vGz*)qI2xzC|~T3GO8d*x5Y-Q#%b26*#+9Y{VG^dg3$ zF2oqRVApj)FIlrbJehb~Kht6$GDuk=L^2(@5Fk?N544y{`pN(?ief4k8Lao7OQ!6K zT=UxTOT?lLauZP!RPADbaH61#F$U{xYC^vUf4rKR@|)sge_qd`Y3W71=BzJ$chO(7 z+>ahzbTe4*Ol^|LopNhF;Q}|E*46UJR_atfLfqtryzX%T{HC{(&~=$v|b7^!C}8 z;Y&Q(RXF%Z*s6dU{p2e;Q`}Dt%`3z`Vo^Z9KEixP3!bTn2Upo;P*x z>O))njz0p%8M1KQ=|@X8_H7Zm*9NCcUV)C@y}Ez&AlxDXvln^}?AgbD(zgALfpKUo zG%sp<;m-b;FPBxRV@Px@9emkOi)+Hg*Spg1*JJFnbF%Uayi!tAb4t71@D&vKsJ31? z6nN(i8Z|I0XJkrFYFaA(7X~D}spNTmy7Z_{HEjAM?l-38k7`5LlSl8B4*&UxeQEv2 zH*AF8tf!xgfYKRHJ39!!ITyrrn)q9zIsJq@@467Rh2OmALUb1XJB=E#L(H4$EUNDe zwh==dZ20&z?@MP9fw$KF^X@tepLwX!*(y=(); @@ -53,6 +57,7 @@ fastify.addHook("preHandler", (req, res, done) => { (async () => { // @ts-ignore req.startTime = Date.now(); + HeaderUtility.AddHeaders(res); // * Take usual controller path if this path is registered. if (Controller.RegisteredPaths.includes(req.url)) { @@ -74,11 +79,18 @@ fastify.addHook("preHandler", (req, res, done) => { // @ts-ignore req.logType = cyan("IMAGE"); const fileStore = HashFS.GetHashFSInstance("images"); - res.header("content-type", media.MediaType); - res.sendFile(fileStore.GetRelativePath(media.Hash), fileStore.path, { contentType: false }); - //return done(); - return; - } + const { statusCode, headers, stream } = await FastifySend(req.raw, join(fileStore.path, fileStore.GetRelativePath(media.Hash)), {}); + headers["Content-Type"] = media.MediaType; + if (statusCode === 200) { + res.headers(headers); + HeaderUtility.AddHeaders(res); + stream.pipe(res.raw); + return; + } + + res.statusCode = statusCode; + return done(); + } } // @ts-ignore diff --git a/package.json b/package.json index e9be00e..30436f8 100644 --- a/package.json +++ b/package.json @@ -12,28 +12,28 @@ "type": "commonjs", "scripts": { "updateCheck": "check-outdated", - "dev:legacy_node": "nodemon --watch './**/*.ts' index.ts", + "dev:legacy_node": "nodemon --watch './**/*.ts' ts-node index.ts", "dev": "bun --watch index.ts", "build": "tsc --build" }, "devDependencies": { - "@types/bun": "^1.1.15", + "@types/bun": "^1.2.0", "@types/ejs": "^3.1.5", "@vercel/ncc": "^0.38.3", "check-outdated": "^2.12.0", "nodemon": "^3.1.9", "ts-node": "^10.9.2", - "typescript": "^5.7.2" + "typescript": "^5.7.3" }, "dependencies": { - "@fastify/cookie": "^11.0.1", - "@fastify/formbody": "^8.0.1", - "@fastify/multipart": "^9.0.1", - "@fastify/static": "^8.0.3", - "@fastify/view": "^10.0.1", + "@fastify/cookie": "^11.0.2", + "@fastify/formbody": "^8.0.2", + "@fastify/multipart": "^9.0.3", + "@fastify/static": "^8.0.4", + "@fastify/view": "^10.0.2", "dyetty": "^1.0.1", "ejs": "^3.1.10", - "fastify": "^5.2.0", + "fastify": "^5.2.1", "funky-array": "^1.0.0", "hsconsole": "^1.1.0", "mysql2": "^3.12.0" diff --git a/utilities/HeaderUtility.ts b/utilities/HeaderUtility.ts new file mode 100644 index 0000000..4851d48 --- /dev/null +++ b/utilities/HeaderUtility.ts @@ -0,0 +1,15 @@ +import type { FastifyReply } from "fastify"; + +export default abstract class HeaderUtility { + public static AddHeaders(res: FastifyReply) { + res.header("x-powered-by", "EUS"); + res.header("rel", "cute"); + res.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains"); + res.header("X-XSS-Protection", "1; mode=block"); + res.header("Permissions-Policy", "microphone=(), geolocation=(), magnetometer=(), camera=(), payment=(), usb=(), accelerometer=(), gyroscope=()"); + res.header("Referrer-Policy", "strict-origin-when-cross-origin"); + res.header("Content-Security-Policy", "block-all-mixed-content;frame-ancestors 'self'"); + res.header("X-Frame-Options", "SAMEORIGIN"); + res.header("X-Content-Type-Options", "nosniff"); + } +} \ No newline at end of file