mirror of
https://github.com/amark/gun.git
synced 2025-06-24 15:02:33 +00:00
Merge pull request #494 from BrockAtkinson/hapifix
Update to hapi v17.2.0
This commit is contained in:
commit
43a14c9528
@ -1,30 +1,58 @@
|
|||||||
console.log("If module not found, install hapi globally `npm i hapi inert -g`!");
|
console.log("If module not found, install hapi globally `npm i hapi inert -g`!")
|
||||||
|
|
||||||
const Hapi = require('hapi')
|
const Hapi = require('hapi')
|
||||||
const Inert = require('inert')
|
const Inert = require('inert')
|
||||||
const Gun = require('..')
|
const Gun = require('..')
|
||||||
|
|
||||||
const server = new Hapi.Server
|
const server = new Hapi.Server({
|
||||||
server.connection({ port: 8080 })
|
port: 8080,
|
||||||
server.connections.forEach(c => Gun({ web: c.listener, file: 'data.json' }))
|
host: 'localhost',
|
||||||
|
routes: {
|
||||||
server.register(Inert, () => {});
|
files: {
|
||||||
|
relativeTo: require('path').join(__dirname, '..')
|
||||||
server.route({
|
|
||||||
method: 'GET',
|
|
||||||
path: '/gun.js',
|
|
||||||
handler: (request, reply) => reply.file('../gun.js', { confine: false })
|
|
||||||
})
|
|
||||||
|
|
||||||
server.route({
|
|
||||||
method: 'GET',
|
|
||||||
path: '/{param*}',
|
|
||||||
handler: {
|
|
||||||
directory: {
|
|
||||||
path: __dirname,
|
|
||||||
redirectToSlash: true,
|
|
||||||
index: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
server.start()
|
async function runtime() {
|
||||||
|
|
||||||
|
const db = new Gun({
|
||||||
|
web: server.listener,
|
||||||
|
file: 'data.json'
|
||||||
|
})
|
||||||
|
|
||||||
|
await server.register(Inert)
|
||||||
|
|
||||||
|
server.route({
|
||||||
|
method: 'GET',
|
||||||
|
path: '/gun.js',
|
||||||
|
handler: {
|
||||||
|
file: 'gun.min.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
server.route({
|
||||||
|
method: 'GET',
|
||||||
|
path: '/gun/nts.js',
|
||||||
|
handler: {
|
||||||
|
file: 'nts.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
server.route({
|
||||||
|
method: 'GET',
|
||||||
|
path: '/{param*}',
|
||||||
|
handler: {
|
||||||
|
directory: {
|
||||||
|
path: __dirname,
|
||||||
|
redirectToSlash: true,
|
||||||
|
index: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await server.start()
|
||||||
|
console.log('Server running at:', server.info.uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
runtime()
|
||||||
|
1046
package-lock.json
generated
1046
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -56,8 +56,8 @@
|
|||||||
"@trust/webcrypto": "^0.7.1",
|
"@trust/webcrypto": "^0.7.1",
|
||||||
"express": ">=4.15.2",
|
"express": ">=4.15.2",
|
||||||
"fake-indexeddb": "^2.0.3",
|
"fake-indexeddb": "^2.0.3",
|
||||||
"hapi": "^16.1.1",
|
"hapi": "^17.2.0",
|
||||||
"inert": "^4.2.0",
|
"inert": "^5.1.0",
|
||||||
"ip": "^1.1.5",
|
"ip": "^1.1.5",
|
||||||
"mocha": ">=3.2.0",
|
"mocha": ">=3.2.0",
|
||||||
"node-localstorage": "^1.3.0",
|
"node-localstorage": "^1.3.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user