mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
This change installs and configures the `mod_zip` nginx module [1], which allows nginx to stream ZIP files directly. It includes a workaround needed to correctly calculate CRC-32 values for included files, by including a new `server` section listening at port 8081, only used for the file requests to be upstream subrequests that correctly trigger the CRC-32 calculation logic. Also, to be able to provide a `m3u` file generated on the fly, we add a `/decode` endpoint fully implemented in nginx using NJS, which receives a `value` URL param, and decodes it using base64. The decoded value is returned as the response. That way, the contents of the `m3u` file is base64-encoded, and set as part of the response, for `mod_zip` to include it in the ZIP file. [1] https://github.com/evanmiller/mod_zip
20 lines
476 B
JavaScript
20 lines
476 B
JavaScript
// Decode a Base64 encoded string received as a query parameter named 'value',
|
|
// and return the decoded value in the response body.
|
|
function decodeBase64(r) {
|
|
var encodedValue = r.args.value;
|
|
|
|
if (!encodedValue) {
|
|
r.return(400, "Missing 'value' query parameter");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
var decodedValue = atob(encodedValue);
|
|
r.return(200, decodedValue);
|
|
} catch (e) {
|
|
r.return(400, "Invalid Base64 encoding");
|
|
}
|
|
}
|
|
|
|
export default { decodeBase64 };
|