generated from azures04/Base-REST-API
Compare commits
3 Commits
1ddcf1eaf2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 71fa04272c | |||
| 7e9496b35d | |||
| 5eaca1e948 |
@@ -3,8 +3,12 @@ const metaService = require("../services/metaService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get(/.*/, async (req, res, next) => {
|
||||
const file = metaService.serveStaticFile(req.originalUrl)
|
||||
return res.status(200).sendFile(file)
|
||||
try {
|
||||
const file = metaService.serveStaticFile(req.originalUrl)
|
||||
return res.status(200).sendFile(file)
|
||||
} catch (error) {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,12 @@
|
||||
const express = require("express")
|
||||
const productsService = require("../../../../services/productsService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const { productName, productPlatform } = req.params
|
||||
await productsService.canAccess(productName)
|
||||
const configs = await productsService.getInstallerConfig(productName, productPlatform)
|
||||
return res.status(200).json(configs)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -1,11 +1,11 @@
|
||||
const express = require("express")
|
||||
const productsFileService = require("../../../../services/productsFileService")
|
||||
const productsService = require("../../../../services/productsService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get(/.*/, async (req, res, next) => {
|
||||
const { productName, productPlatform } = req.params
|
||||
await productsFileService.canAccess(productName)
|
||||
const file = await productsFileService.getFile(req.url, productName, productPlatform)
|
||||
await productsService.canAccess(productName)
|
||||
const file = await productsService.getFile(req.url, productName, productPlatform)
|
||||
return res.status(200).download(file.path)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const express = require("express")
|
||||
const productsFileService = require("../../../../services/productsFileService")
|
||||
const productsService = require("../../../../services/productsService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const { productName, productPlatform } = req.params
|
||||
await productsFileService.canAccess(productName)
|
||||
const files = await productsFileService.getProductFiles(productName, productPlatform)
|
||||
await productsService.canAccess(productName)
|
||||
const files = await productsService.getProductFiles(productName, productPlatform)
|
||||
return res.status(200).json(files)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const express = require("express")
|
||||
const productsFileService = require("../../../../services/productsFileService")
|
||||
const productsService = require("../../../../services/productsService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const { productName, productPlatform } = req.params
|
||||
await productsFileService.canAccess(productName)
|
||||
const files = await productsFileService.getRequirementsForPlatform(productName, productPlatform)
|
||||
return res.status(200).json(files)
|
||||
await productsService.canAccess(productName)
|
||||
const requirements = await productsService.getRequirementsForPlatform(productName, productPlatform)
|
||||
return res.status(200).json(requirements)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -1,11 +1,11 @@
|
||||
const express = require("express")
|
||||
const productsFileService = require("../../../services/productsFileService")
|
||||
const productsService = require("../../../services/productsService")
|
||||
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)
|
||||
await productsService.canAccess(productName)
|
||||
const files = await productsService.getInstallerResources(productName)
|
||||
return res.status(200).json(files)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const express = require("express")
|
||||
const router = express.Router({ mergeParams: false })
|
||||
const productsFileService = require("../../services/productsFileService")
|
||||
const productsService = require("../../services/productsService")
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
const products = await productsFileService.getProducts()
|
||||
const products = await productsService.getProducts()
|
||||
return res.status(200).json(products)
|
||||
})
|
||||
|
||||
router.get("/product/:productName", async (req, res) => {
|
||||
const product = await productsFileService.getProduct(req.params.productName)
|
||||
const product = await productsService.getProduct(req.params.productName)
|
||||
return res.status(200).json(product)
|
||||
})
|
||||
|
||||
|
||||
@@ -144,6 +144,18 @@ async function getInstallerResources(productName) {
|
||||
return config["installerResources"]
|
||||
}
|
||||
|
||||
async function getInstallerConfig(productName, productPlatform) {
|
||||
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.configurations?.global || []
|
||||
const platformReqs = config.configurations?.[productPlatform] || []
|
||||
|
||||
return { ...globalReqs, ...platformReqs }
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getFile,
|
||||
canAccess,
|
||||
@@ -151,6 +163,7 @@ module.exports = {
|
||||
getFileSha1,
|
||||
getProducts,
|
||||
getProductFiles,
|
||||
getInstallerConfig,
|
||||
getInstallerResources,
|
||||
getRequirementsForPlatform
|
||||
}
|
||||
Reference in New Issue
Block a user