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

This commit is contained in:
choelzl 2021-07-16 09:18:25 +02:00
parent 82b7fd846b
commit 4733baeecc
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
2 changed files with 2 additions and 37 deletions

View File

@ -15,16 +15,9 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"ejs": "^2.7.4", "fastify": "latest",
"fastify": "^2.10.0", "fastify-leveldb": "latest",
"fastify-cookie": "^3.2.0",
"fastify-jwt": "^1.2.0",
"fastify-leveldb": "^2.1.0",
"fastify-static": "^2.5.0", "fastify-static": "^2.5.0",
"fastify-websocket": "^1.0.0",
"node-pandoc": "^0.3.0",
"node-sass": "^6.0.0", "node-sass": "^6.0.0",
"point-of-view": "^3.7.0",
"ws": "^7.2.0"
} }
} }

View File

@ -8,36 +8,8 @@ const static_opts = {
root: path.join(__dirname, 'public'), root: path.join(__dirname, 'public'),
prefix: '/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-static'), static_opts);
fastify.register(require('fastify-cookie'));
fastify.register(require('point-of-view'), pov_opts);
fastify.register(require('fastify-leveldb'), { fastify.register(require('fastify-leveldb'), {
name: 'db' name: 'db'