mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08: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 Inert = require('inert')
|
||||
const Gun = require('..')
|
||||
|
||||
const server = new Hapi.Server
|
||||
server.connection({ port: 8080 })
|
||||
server.connections.forEach(c => Gun({ web: c.listener, file: 'data.json' }))
|
||||
|
||||
server.register(Inert, () => {});
|
||||
|
||||
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
|
||||
const server = new Hapi.Server({
|
||||
port: 8080,
|
||||
host: 'localhost',
|
||||
routes: {
|
||||
files: {
|
||||
relativeTo: require('path').join(__dirname, '..')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
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",
|
||||
"express": ">=4.15.2",
|
||||
"fake-indexeddb": "^2.0.3",
|
||||
"hapi": "^16.1.1",
|
||||
"inert": "^4.2.0",
|
||||
"hapi": "^17.2.0",
|
||||
"inert": "^5.1.0",
|
||||
"ip": "^1.1.5",
|
||||
"mocha": ">=3.2.0",
|
||||
"node-localstorage": "^1.3.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user