forked from cms/tibi-svelte-starter
fixed ssr
This commit is contained in:
parent
71fd86b376
commit
46c8119548
@ -7,7 +7,7 @@ var utils = require("../lib/utils")
|
||||
var url = request.query("url")
|
||||
var noCache = request.query("noCache")
|
||||
|
||||
var trace_id = context.sentryTraceId()
|
||||
var trace_id = context.debug.sentryTraceId()
|
||||
function addSentryTrace(content) {
|
||||
return content.replace(
|
||||
"</head>",
|
||||
@ -15,7 +15,7 @@ var utils = require("../lib/utils")
|
||||
)
|
||||
}
|
||||
|
||||
context.header("sentry-trace", trace_id)
|
||||
context.response.header("sentry-trace", trace_id)
|
||||
|
||||
if (url) {
|
||||
var comment = ""
|
||||
@ -32,7 +32,7 @@ var utils = require("../lib/utils")
|
||||
|
||||
var cache =
|
||||
!noCache &&
|
||||
context.readCollection("ssr", {
|
||||
context.db.find("ssr", {
|
||||
filter: {
|
||||
path: url,
|
||||
},
|
||||
@ -96,7 +96,7 @@ var utils = require("../lib/utils")
|
||||
endpoint,
|
||||
JSON.stringify(_options)
|
||||
)*/
|
||||
var goSlice = context.readCollection(
|
||||
var goSlice = context.db.find(
|
||||
endpoint,
|
||||
_options || {}
|
||||
)
|
||||
@ -114,10 +114,7 @@ var utils = require("../lib/utils")
|
||||
var count = (data && data.length) || 0
|
||||
if (options && count == options.limit) {
|
||||
// read count from db
|
||||
count = context.readCollectionCount(
|
||||
endpoint,
|
||||
_options || {}
|
||||
)
|
||||
count = context.db.count(endpoint, _options || {})
|
||||
}
|
||||
var r = { data: data, count: count }
|
||||
|
||||
@ -147,15 +144,13 @@ var utils = require("../lib/utils")
|
||||
|
||||
cacheIt = true
|
||||
} catch (e) {
|
||||
utils.log(e)
|
||||
for (var property in e) {
|
||||
utils.log(property + ": " + e[property])
|
||||
}
|
||||
error = JSON.stringify(e)
|
||||
utils.log(e.message)
|
||||
utils.log(e.stack)
|
||||
error = "error: " + e.message + "\n\n" + e.stack
|
||||
}
|
||||
}
|
||||
|
||||
var tpl = context.file("templates/spa.html")
|
||||
var tpl = context.fs.readFile("templates/spa.html")
|
||||
tpl = tpl.replace("<!--HEAD-->", head)
|
||||
tpl = tpl.replace("<!--HTML-->", html)
|
||||
tpl = tpl.replace(
|
||||
@ -169,7 +164,7 @@ var utils = require("../lib/utils")
|
||||
|
||||
if (cacheIt && !noCache) {
|
||||
// save cache
|
||||
context.createDocument("ssr", {
|
||||
context.db.create("ssr", {
|
||||
path: url,
|
||||
content: tpl,
|
||||
})
|
||||
@ -185,7 +180,7 @@ var utils = require("../lib/utils")
|
||||
html: addSentryTrace(tpl),
|
||||
}
|
||||
} else {
|
||||
var auth = context.auth()
|
||||
var auth = context.user.auth()
|
||||
if (!auth || auth.role !== 0) {
|
||||
// only admins are allowed
|
||||
throw {
|
||||
|
Loading…
Reference in New Issue
Block a user