tibi-docs/api/hooks/config.js

32 lines
958 B
JavaScript
Raw Normal View History

2024-04-10 10:26:40 +02:00
const apiSsrBaseURL =
"http://localhost:" + context.config.server().api.port + "/api/v1/_/" + context.api().namespace + "/"
2023-11-15 08:00:12 +01:00
2023-02-21 14:00:56 +01:00
module.exports = {
2023-11-15 08:00:12 +01:00
apiSsrBaseURL,
2024-04-10 10:26:40 +02:00
ssrValidatePath: function (/** @type {string} */ path) {
2023-02-21 14:00:56 +01:00
// validate if path ssr rendering is ok, -1 = NOTFOUND, 0 = NO SSR, 1 = SSR
// pe. use context.readCollection("product", {filter: {path: path}}) ... to validate dynamic urls
2023-11-15 08:00:12 +01:00
// // / is de home
// if (path == "/") return 1
2023-02-21 14:00:56 +01:00
2023-11-15 08:00:12 +01:00
// // all other sites are in db
2024-01-27 19:58:35 +01:00
//path = path?.replace(/^\//, "")
2023-02-21 14:00:56 +01:00
const resp = context.db.find("content", {
filter: {
2024-01-27 19:58:35 +01:00
$and: [{ path }],
2023-02-21 14:00:56 +01:00
},
2023-11-15 08:00:12 +01:00
2023-02-21 14:00:56 +01:00
selector: { _id: 1 },
})
if (resp && resp.length) {
return 1
}
// not found
return -1
},
2023-11-15 08:00:12 +01:00
ssrPublishCheckCollections: ["content"],
2024-01-27 19:58:35 +01:00
LIGHTHOUSE_TOKEN: "AIzaSyC0UxHp3-MpJiDL3ws7pEV6lj57bfIc7GQ",
2023-02-21 14:00:56 +01:00
}