|
|
|
@ -10,7 +10,7 @@ const server = fastify()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add liquidjs
|
|
|
|
|
* add liquidjs
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
@ -33,9 +33,10 @@ server.register(view, {
|
|
|
|
|
/**
|
|
|
|
|
* adding preHandler
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import SettingsStore from './stores/settings.js'
|
|
|
|
|
import SettingsStore from './stores/Settings.js'
|
|
|
|
|
|
|
|
|
|
// getting options from directus add to all views
|
|
|
|
|
server.addHook('preHandler', async function (request, response) {
|
|
|
|
@ -48,21 +49,35 @@ server.addHook('preHandler', async function (request, response) {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// check url for paged
|
|
|
|
|
server.addHook('preHandler', async function (request, response) {
|
|
|
|
|
server.addHook('onRequest', async function (request, response) {
|
|
|
|
|
|
|
|
|
|
const url = new URL(request.params.url)
|
|
|
|
|
const pathname = url.pathname.split('/')
|
|
|
|
|
const url = request.url
|
|
|
|
|
|
|
|
|
|
let pathname = url.split('/')
|
|
|
|
|
pathname.shift()
|
|
|
|
|
|
|
|
|
|
// default value for paged
|
|
|
|
|
let paged = 1
|
|
|
|
|
|
|
|
|
|
// check if pathname has values
|
|
|
|
|
if (pathname.length > 0) {
|
|
|
|
|
const result = pathname[pathname.length - 1]
|
|
|
|
|
|
|
|
|
|
// try to get number
|
|
|
|
|
const result = Number(pathname[pathname.length - 1])
|
|
|
|
|
|
|
|
|
|
// is result is integer
|
|
|
|
|
if (Number.isInteger(result)) {
|
|
|
|
|
paged = result
|
|
|
|
|
|
|
|
|
|
// remove last element
|
|
|
|
|
pathname.pop()
|
|
|
|
|
|
|
|
|
|
// @TODO change, thats looks strange
|
|
|
|
|
if (pathname.length > 0) {
|
|
|
|
|
request.raw.url = pathname.join('/')
|
|
|
|
|
} else {
|
|
|
|
|
request.raw.url = '/'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -72,7 +87,12 @@ server.addHook('preHandler', async function (request, response) {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// routing
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* routing
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import commentHttp from './http/api/comment.js'
|
|
|
|
|
|
|
|
|
|