cube.js 配置自定义basePath 扩展cube.js 多租户处理

cube.js 默认的basePath是cubejs-api 我们可以通过配置自定义的basePath提升多租户的处理能力

参考配置

module.exports = {
    basePath:"/oneservice/:projectid",
    schemaVersion: ({ securityContext }) => {
        console.log(securityContext)
    },
    // 基于extendContext 扩展securityContext 可以扩展请求
    extendContext:(req)=>{
        console.log("projectid:",req.params.projectid)
        if (req.securityContext){
            req.securityContext.projectid=req.params.projectid
        }
    }
};

参考请求格式

curl --location --request GET 'http://localhost:4000/oneservice/002/v1/load?query=%7B%22measures%22%3A%5B%22Demoapps.count%22%5D%2C%22timeDimensions%22%3A%5B%5D%2C%22order%22%3A%7B%22Demoapps.count%22%3A%22desc%22%7D%2C%22dimensions%22%3A%5B%22Demoapps.name%22%5D%7D&queryType=multi' \
--header 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MTgxNDUxODEsImV4cCI6MTYxODIzMTU4MX0.mHfHkmdQ3HMjaVrjMjbSq0eOPlnrQKQwllQ_BYlsU_E'

运行参考格式

 

 

说明

因为cube.js 的basePath 也是使用了express 框架的能力,所以我们可以方便的进行扩展,这样我们系统的多租户能力就更加方便了

参考资料

https://expressjs.com/en/guide/routing.html
https://cube.dev/docs/config#options-reference-base-path

posted on   荣锋亮  阅读(131)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-04-11 几款不错的java规则引擎
2019-04-11 Announcing the Operate Preview Release: Monitoring and Managing Cross-Microservice Workflows
2019-04-11 goaccess iis w3c 自定义log 格式参考
2019-04-11 goaccess 通过jsonpath 转换为prometheus metrics
2018-04-11 ffmpeg && nginx hls
2017-04-11 jenkins api 使用
2017-04-11 Thumbnailator 图像处理

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示