init
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-07-16 09:18:25 +02:00
parent 82b7fd846b
commit 4733baeecc
2 changed files with 2 additions and 37 deletions

View File

@@ -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'