This commit is contained in:
parent
f42e57a3b3
commit
dbf93d8d1f
36
auth_db.js
36
auth_db.js
@ -1,36 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const fp = require('fastify-plugin')
|
|
||||||
const levelup = require('levelup')
|
|
||||||
const leveldown = require('leveldown')
|
|
||||||
const encode = require('encoding-down')
|
|
||||||
|
|
||||||
// mostly from level-packager
|
|
||||||
const levelMore = (location) => {
|
|
||||||
;['destroy', 'repair'].forEach(function (m) {
|
|
||||||
if (typeof leveldown[m] === 'function') {
|
|
||||||
levelMore[m] = () => leveldown[m].apply(leveldown, arguments)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return levelup(encode(leveldown(location), { }), { })
|
|
||||||
}
|
|
||||||
|
|
||||||
levelMore.errors = levelup.errors
|
|
||||||
|
|
||||||
function levelPlugin (fastify, opt, next) {
|
|
||||||
fastify
|
|
||||||
.decorate('lauth', levelMore('auth'))
|
|
||||||
.addHook('onClose', close)
|
|
||||||
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
|
|
||||||
function close (fastify, done) {
|
|
||||||
fastify.level.close(done)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = fp(levelPlugin, {
|
|
||||||
fastify: '>=1.0.0',
|
|
||||||
name: 'level_auth'
|
|
||||||
});
|
|
@ -14,11 +14,11 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.1",
|
"axios": "latest",
|
||||||
"fastify": "latest",
|
"fastify": "latest",
|
||||||
"fastify-leveldb": "latest",
|
"fastify-leveldb": "latest",
|
||||||
"fastify-static": "^2.5.0",
|
"fastify-static": "latest",
|
||||||
"mkdirp": "^1.0.4",
|
"mkdirp": "latest",
|
||||||
"node-sass": "^6.0.0"
|
"node-sass": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,7 @@ fastify.register(require('fastify-leveldb'), {
|
|||||||
fastify.get('/', (req, reply) => {
|
fastify.get('/', (req, reply) => {
|
||||||
reply.sendFile('/template/home.html');
|
reply.sendFile('/template/home.html');
|
||||||
});
|
});
|
||||||
|
fastify.register(require('./router/api'), { prefix: '/api' });
|
||||||
fastify.get('/dbg', (req, reply) => {
|
|
||||||
reply.sendFile('/template/templates.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
fastify.get('/:id', (req, reply) => {
|
fastify.get('/:id', (req, reply) => {
|
||||||
try{
|
try{
|
||||||
@ -49,7 +46,6 @@ fastify.get('/:id', (req, reply) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
fastify.register(require('./router/api'), { prefix: '/api' });
|
|
||||||
|
|
||||||
|
|
||||||
fastify.listen(8080,'0.0.0.0' ,(err,address) => {
|
fastify.listen(8080,'0.0.0.0' ,(err,address) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user