This commit is contained in:
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'
|
||||
|
Reference in New Issue
Block a user