This commit is contained in:
parent
82b7fd846b
commit
4733baeecc
11
package.json
11
package.json
@ -15,16 +15,9 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"ejs": "^2.7.4",
|
||||
"fastify": "^2.10.0",
|
||||
"fastify-cookie": "^3.2.0",
|
||||
"fastify-jwt": "^1.2.0",
|
||||
"fastify-leveldb": "^2.1.0",
|
||||
"fastify": "latest",
|
||||
"fastify-leveldb": "latest",
|
||||
"fastify-static": "^2.5.0",
|
||||
"fastify-websocket": "^1.0.0",
|
||||
"node-pandoc": "^0.3.0",
|
||||
"node-sass": "^6.0.0",
|
||||
"point-of-view": "^3.7.0",
|
||||
"ws": "^7.2.0"
|
||||
}
|
||||
}
|
||||
|
28
server.js
28
server.js
@ -8,36 +8,8 @@ const static_opts = {
|
||||
root: path.join(__dirname, 'public'),
|
||||
prefix: '/public/',
|
||||
};
|
||||
const pov_opts = {
|
||||
engine: {
|
||||
ejs: require('ejs')
|
||||
}
|
||||
};
|
||||
|
||||
fastify.hashgen = (str)=>{
|
||||
return crypto.createHash('md5').update('CHELCEL_PRE_SALT_##'+str+'##_SALT_POST_CHELCEL').digest('hex');
|
||||
};
|
||||
|
||||
fastify.cookiegen = (request, type, file_hash)=>{
|
||||
let tk = {};
|
||||
if(request.cookies.token ){
|
||||
tk = fastify.jwt.decode(request.cookies.token);
|
||||
}
|
||||
|
||||
if(tk[type]== undefined){
|
||||
tk[type]=[];
|
||||
}
|
||||
if(tk[type].indexOf(file_hash)== -1){
|
||||
tk[type].push(file_hash);
|
||||
}
|
||||
const token = fastify.jwt.sign(tk)
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
fastify.register(require('fastify-static'), static_opts);
|
||||
fastify.register(require('fastify-cookie'));
|
||||
fastify.register(require('point-of-view'), pov_opts);
|
||||
|
||||
fastify.register(require('fastify-leveldb'), {
|
||||
name: 'db'
|
||||
|
Loading…
x
Reference in New Issue
Block a user