qortal-ui/qortal-ui-core/server/routes/createCommonRoutes.js

107 lines
2.4 KiB
JavaScript
Raw Normal View History

2021-12-25 14:39:47 +01:00
const path = require('path')
const routesOptions = {
security: {
hsts: {
maxAge: 15768000,
includeSubDomains: true,
preload: true
},
xframe: 'sameorigin'
}
}
const createRoutes = config => [
{
method: 'GET',
path: '/img/{param*}',
handler: {
directory: {
path: config.build.options.imgDir,
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
2022-04-09 11:33:59 -07:00
{
method: 'GET',
path: '/language/{param*}',
handler: {
directory: {
path: path.join(__dirname, '../../language'),
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
2021-12-25 14:39:47 +01:00
{
method: 'GET',
path: '/font/{param*}',
handler: {
directory: {
path: path.join(__dirname, '../../font'),
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
{
method: 'GET',
path: '/sound/{param*}',
handler: {
directory: {
path: path.join(__dirname, '../../sound/'),
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
{
method: 'GET',
path: '/emoji/{param*}',
handler: {
directory: {
path: path.join(__dirname, '../../emoji/'),
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
{
method: 'GET',
path: '/memory-pow/{param*}',
handler: {
directory: {
path: path.join(__dirname, '../../memory-pow/'),
redirectToSlash: true,
index: true
}
},
options: routesOptions
},
{
method: 'GET',
path: '/getConfig',
handler: (request, h) => {
const response = {
config: {
...config
}
}
delete response.config.user.tls
delete response.config.build
return JSON.stringify(response)
},
options: routesOptions
}
]
module.exports = createRoutes