wm-fontis-tibi-2023/api/hooks/config.js

34 lines
992 B
JavaScript
Raw Normal View History

2023-12-07 21:24:09 +01:00
const apiSsrBaseURL = "http://localhost:8080/api/v1/_/fontis_v2"
2023-07-13 13:12:19 +02:00
module.exports = {
2023-12-07 21:24:09 +01:00
apiSsrBaseURL,
2023-07-13 13:12:19 +02:00
ssrValidatePath: function (path) {
// 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-12-07 21:24:09 +01:00
// // / is de home
// if (path == "/") return 1
2023-07-13 13:12:19 +02:00
2023-12-07 21:24:09 +01:00
// // all other sites are in db
//path = path?.replace(/^\//, "")
console.log("PATH:", path)
2023-07-13 13:12:19 +02:00
// filter for path or alternativePaths
2023-12-07 21:24:09 +01:00
const resp = context.db.find("page", {
2023-07-13 13:12:19 +02:00
filter: {
2023-12-07 21:24:09 +01:00
$and: [{ path }],
2023-07-13 13:12:19 +02:00
},
2023-12-07 21:24:09 +01:00
2023-07-13 13:12:19 +02:00
selector: { _id: 1 },
})
2023-12-07 21:24:09 +01:00
console.log("RESP:", resp?.length)
2023-07-13 13:12:19 +02:00
if (resp && resp.length) {
return 1
}
// not found
return -1
},
2023-12-07 21:24:09 +01:00
ssrPublishCheckCollections: ["page"],
2023-12-26 14:19:56 +01:00
LIGHTHOUSE_TOKEN: "AIzaSyC0UxHp3-MpJiDL3ws7pEV6lj57bfIc7GQ",
2023-07-13 13:12:19 +02:00
}