generated from azures04/Base-REST-API
Added installer resources to get app icon and eula
This commit is contained in:
parent
677e23d755
commit
706ddfb95a
@ -4,7 +4,7 @@ const router = express.Router({ mergeParams: true })
|
|||||||
|
|
||||||
router.get(/.*/, async (req, res, next) => {
|
router.get(/.*/, async (req, res, next) => {
|
||||||
const { productName, productPlatform } = req.params
|
const { productName, productPlatform } = req.params
|
||||||
await productsFileService.canAccess(productName, productPlatform)
|
await productsFileService.canAccess(productName)
|
||||||
const file = await productsFileService.getFile(req.url, productName, productPlatform)
|
const file = await productsFileService.getFile(req.url, productName, productPlatform)
|
||||||
return res.status(200).download(file.path)
|
return res.status(200).download(file.path)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const router = express.Router({ mergeParams: true })
|
|||||||
|
|
||||||
router.get("/", async (req, res) => {
|
router.get("/", async (req, res) => {
|
||||||
const { productName, productPlatform } = req.params
|
const { productName, productPlatform } = req.params
|
||||||
await productsFileService.canAccess(productName, productPlatform)
|
await productsFileService.canAccess(productName)
|
||||||
const files = await productsFileService.getProductFiles(productName, productPlatform)
|
const files = await productsFileService.getProductFiles(productName, productPlatform)
|
||||||
return res.status(200).json(files)
|
return res.status(200).json(files)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const router = express.Router({ mergeParams: true })
|
|||||||
|
|
||||||
router.get("/", async (req, res) => {
|
router.get("/", async (req, res) => {
|
||||||
const { productName, productPlatform } = req.params
|
const { productName, productPlatform } = req.params
|
||||||
await productsFileService.canAccess(productName, productPlatform)
|
await productsFileService.canAccess(productName)
|
||||||
const files = await productsFileService.getRequirementsForPlatform(productName, productPlatform)
|
const files = await productsFileService.getRequirementsForPlatform(productName, productPlatform)
|
||||||
return res.status(200).json(files)
|
return res.status(200).json(files)
|
||||||
})
|
})
|
||||||
|
|||||||
12
routes/products/[productName]/installerResource.js
Normal file
12
routes/products/[productName]/installerResource.js
Normal file
@ -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 } = req.params
|
||||||
|
await productsFileService.canAccess(productName)
|
||||||
|
const files = await productsFileService.getInstallerResources(productName)
|
||||||
|
return res.status(200).json(files)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
@ -124,18 +124,26 @@ async function getProducts() {
|
|||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRequirementsForPlatform(productName, platform) {
|
async function getRequirementsForPlatform(productName, productPlatform) {
|
||||||
const fixedPath = path.join(productsDataPath, productName, "files", ".brikcfg")
|
const fixedPath = path.join(productsDataPath, productName, "files", ".brikcfg")
|
||||||
if (!(await fs.promises.exists(fixedPath))) return []
|
if (!(await fs.promises.exists(fixedPath))) return []
|
||||||
|
|
||||||
const config = JSON.parse(await fs.promises.readFile(fixedPath, "utf8"))
|
const config = JSON.parse(await fs.promises.readFile(fixedPath, "utf8"))
|
||||||
|
|
||||||
const globalReqs = config.requirements?.global || []
|
const globalReqs = config.requirements?.global || []
|
||||||
const platformReqs = config.requirements?.[platform] || []
|
const platformReqs = config.requirements?.[productPlatform] || []
|
||||||
|
|
||||||
return [...globalReqs, ...platformReqs]
|
return [...globalReqs, ...platformReqs]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getInstallerResources(productName) {
|
||||||
|
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"))
|
||||||
|
return config["installerResources"]
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getFile,
|
getFile,
|
||||||
canAccess,
|
canAccess,
|
||||||
@ -143,5 +151,6 @@ module.exports = {
|
|||||||
getFileSha1,
|
getFileSha1,
|
||||||
getProducts,
|
getProducts,
|
||||||
getProductFiles,
|
getProductFiles,
|
||||||
|
getInstallerResources,
|
||||||
getRequirementsForPlatform
|
getRequirementsForPlatform
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user