generated from azures04/Base-REST-API
Added requirements supports
- Added requirements support to make easier the installation of my softs
This commit is contained in:
parent
ac12432ebd
commit
677e23d755
@ -0,0 +1,12 @@
|
|||||||
|
const express = require("express")
|
||||||
|
const productsFileService = require("../../../../services/productsFileService")
|
||||||
|
const router = express.Router({ mergeParams: true })
|
||||||
|
|
||||||
|
router.get("/", async (req, res) => {
|
||||||
|
const { productName, productPlatform } = req.params
|
||||||
|
await productsFileService.canAccess(productName, productPlatform)
|
||||||
|
const files = await productsFileService.getRequirementsForPlatform(productName, productPlatform)
|
||||||
|
return res.status(200).json(files)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
@ -124,11 +124,24 @@ async function getProducts() {
|
|||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getRequirementsForPlatform(productName, platform) {
|
||||||
|
const fixedPath = path.join(productsDataPath, productName, "files", ".brikcfg")
|
||||||
|
if (!(await fs.promises.exists(fixedPath))) return []
|
||||||
|
|
||||||
|
const config = JSON.parse(await fs.promises.readFile(fixedPath, "utf8"))
|
||||||
|
|
||||||
|
const globalReqs = config.requirements?.global || []
|
||||||
|
const platformReqs = config.requirements?.[platform] || []
|
||||||
|
|
||||||
|
return [...globalReqs, ...platformReqs]
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getFile,
|
getFile,
|
||||||
canAccess,
|
canAccess,
|
||||||
getProduct,
|
getProduct,
|
||||||
getFileSha1,
|
getFileSha1,
|
||||||
getProducts,
|
getProducts,
|
||||||
getProductFiles
|
getProductFiles,
|
||||||
|
getRequirementsForPlatform
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user