beatstar_api/build/pack_api.js

32 lines
996 B
JavaScript
Raw Permalink Normal View History

2023-06-11 17:18:44 +02:00
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const pack_service_1 = __importDefault(require("./services/pack_service"));
const zip = require("express-zip");
class PackAPI {
}
exports.default = PackAPI;
_a = PackAPI;
PackAPI.getPacks = async (req, res, next) => {
return res.status(200).json({
packs: JSON.stringify(await pack_service_1.default.getPackList()),
});
};
PackAPI.downloadSinglePack = async (req, res, next) => {
if (!req.query.name) {
return res.status(500).json({
message: "pack name not specified",
});
}
const foundPack = pack_service_1.default.findByName(req.query.name.toString());
if (!foundPack) {
return res.status(500).json({
message: "Pack does not exist",
});
}
return res.zip(foundPack.files);
};