mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-20 11:45:51 +00:00
Add autoindex JSON
This commit is contained in:
@@ -65,5 +65,9 @@ On the HTTP port a file listing is also provided & xPOPs can be downloaded at `/
|
|||||||
|
|
||||||
Original source files to reconstruct the xPOP locally can be downloaded at `/{networkid}/`.
|
Original source files to reconstruct the xPOP locally can be downloaded at `/{networkid}/`.
|
||||||
|
|
||||||
|
When visiting the `/{networkid}/` route, you'll be presented a dirlisting. When visiting with the HTTP
|
||||||
|
header `Accept: application/json` you will be presented a dirlisting & file browser in JSON format
|
||||||
|
for automation.
|
||||||
|
|
||||||
This file browser is for development and test purposes only, for production, put a static webserver
|
This file browser is for development and test purposes only, for production, put a static webserver
|
||||||
in front of this application & reverse proxy only the WebSocket (HTTP Upgrade) server.
|
in front of this application & reverse proxy only the WebSocket (HTTP Upgrade) server.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { WebSocket } from 'ws'
|
|||||||
import morgan from 'morgan'
|
import morgan from 'morgan'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import expressWs from 'express-ws'
|
import expressWs from 'express-ws'
|
||||||
import serveIndex from 'serve-index'
|
import autoindex from 'express-autoindex/dist/index.cjs.js'
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
let wss // WebSocket Server
|
let wss // WebSocket Server
|
||||||
@@ -13,7 +13,10 @@ if (!wss) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
app.enable('trust proxy')
|
app.enable('trust proxy')
|
||||||
|
app.disable('x-powered-by')
|
||||||
|
app.use(express.json())
|
||||||
app.use(morgan('combined', { }))
|
app.use(morgan('combined', { }))
|
||||||
|
|
||||||
wss = expressWs(app)
|
wss = expressWs(app)
|
||||||
@@ -25,7 +28,7 @@ if (!wss) {
|
|||||||
app.use('/', express.static('./store/'))
|
app.use('/', express.static('./store/'))
|
||||||
|
|
||||||
app.use('/:networkId([0-9]{1,})', (req, res, next) => {
|
app.use('/:networkId([0-9]{1,})', (req, res, next) => {
|
||||||
return serveIndex('./store/' + req.params.networkId + '/', { icons: false })(req, res, next)
|
return autoindex('./store/' + req.params.networkId + '/', { json: /application\/json/.test(req.get('accept')) })(req, res, next)
|
||||||
})
|
})
|
||||||
|
|
||||||
// app.get('/', function route (req, res, next){
|
// app.get('/', function route (req, res, next){
|
||||||
|
|||||||
26
package-lock.json
generated
26
package-lock.json
generated
@@ -13,6 +13,7 @@
|
|||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"ed25519": "^0.0.5",
|
"ed25519": "^0.0.5",
|
||||||
"elliptic": "^6.5.4",
|
"elliptic": "^6.5.4",
|
||||||
|
"express-autoindex": "^1.4.2",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
@@ -479,6 +480,11 @@
|
|||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/chardet": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chardet/-/chardet-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-+QOTw3otC4+FxdjK9RopGpNOglADbr4WPFi0SonkO99JbpkTPbMxmdm4NenhF5Zs+4gPXLI1+y2uazws5TMe8w=="
|
||||||
|
},
|
||||||
"node_modules/cipher-base": {
|
"node_modules/cipher-base": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
|
||||||
@@ -918,6 +924,26 @@
|
|||||||
"node": ">= 0.10.0"
|
"node": ">= 0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/express-autoindex": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-autoindex/-/express-autoindex-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-ZWORN76nyIUvK0kycB8JXYnr0gQFjpbWu5vWq1u7E0xHxHtmzhjLMgJO5iHc8f9zQCOxTQNdw4B53OVI4SClsw==",
|
||||||
|
"dependencies": {
|
||||||
|
"chardet": "^1.6.0",
|
||||||
|
"mime": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/express-autoindex/node_modules/mime": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==",
|
||||||
|
"bin": {
|
||||||
|
"mime": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/express-ws": {
|
"node_modules/express-ws": {
|
||||||
"version": "5.0.2",
|
"version": "5.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-5.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-5.0.2.tgz",
|
||||||
|
|||||||
@@ -20,12 +20,12 @@
|
|||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"ed25519": "^0.0.5",
|
"ed25519": "^0.0.5",
|
||||||
"elliptic": "^6.5.4",
|
"elliptic": "^6.5.4",
|
||||||
|
"express-autoindex": "^1.4.2",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"ripple-address-codec": "^4.3.0",
|
"ripple-address-codec": "^4.3.0",
|
||||||
"ripple-binary-codec": "^1.10.0",
|
"ripple-binary-codec": "^1.10.0",
|
||||||
"serve-index": "^1.9.1",
|
|
||||||
"ws": "^8.14.2",
|
"ws": "^8.14.2",
|
||||||
"xrpl-client": "^2.2.0"
|
"xrpl-client": "^2.2.0"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user