mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-12-01 09:05:50 +00:00
Add content type for JSON
This commit is contained in:
@@ -34,30 +34,42 @@ if (!wss) {
|
|||||||
// return next()
|
// return next()
|
||||||
// })
|
// })
|
||||||
|
|
||||||
app.use('/', function renderHomepage(req, res, next) {
|
app.use('/',
|
||||||
res.setHeader('content-type', 'text/html');
|
(req, res, next) => {
|
||||||
if (req.url === '' || req.url === '/') {
|
if (req.url.split('?')?.[0].match(/\.json$/i)) {
|
||||||
res.render('public_html/index.html', {
|
res.setHeader('content-type', 'application/json')
|
||||||
config: {
|
}
|
||||||
networkid: process.env?.NETWORKID ?? null,
|
|
||||||
urlprefix: process.env?.URL_PREFIX ?? null,
|
|
||||||
nodes: process.env?.NODES ?? null,
|
|
||||||
fields: process.env?.FIELDSREQUIRED ?? null,
|
|
||||||
unlurl: process.env?.UNLURL ?? null,
|
|
||||||
unlkey: process.env?.UNLKEY ?? null,
|
|
||||||
},
|
|
||||||
stats: {
|
|
||||||
lastLedger: lastLedger ?? null,
|
|
||||||
lastLedgerTx: lastLedgerTx ?? null,
|
|
||||||
txCount: txCount ?? null,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
next()
|
next()
|
||||||
}
|
},
|
||||||
},express.static('./store/'))
|
function renderHomepage(req, res, next) {
|
||||||
|
// res.setHeader('content-type', 'text/html')
|
||||||
|
if (req.url === '' || req.url === '/') {
|
||||||
|
res.render('public_html/index.html', {
|
||||||
|
infraConfig: {
|
||||||
|
wssNodes: typeof process.env?.NODES === 'string' ? process.env.NODES.split(',') : null,
|
||||||
|
unlurl: process.env?.UNLURL ?? null,
|
||||||
|
unlkey: process.env?.UNLKEY ?? null,
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
networkid: process.env?.NETWORKID ?? null,
|
||||||
|
urlprefix: process.env?.URL_PREFIX ?? null,
|
||||||
|
requiredTxFields: typeof process.env?.FIELDSREQUIRED === 'string' ? process.env.FIELDSREQUIRED.split(',') : null,
|
||||||
|
},
|
||||||
|
stats: {
|
||||||
|
lastLedger: lastLedger ?? null,
|
||||||
|
lastLedgerTx: lastLedgerTx ?? null,
|
||||||
|
txCount: txCount ?? null,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
express.static('./store/'),
|
||||||
|
)
|
||||||
|
|
||||||
app.use('/health', (req, res) => {
|
app.use('/health', (req, res) => {
|
||||||
|
res.setHeader('content-type', 'application/json')
|
||||||
res.json({
|
res.json({
|
||||||
uptime: new Date() - startDate,
|
uptime: new Date() - startDate,
|
||||||
lastLedger: lastLedger ?? null,
|
lastLedger: lastLedger ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user