From 4733baeecc47c89b02fb4ead5f18c78ca81492c5 Mon Sep 17 00:00:00 2001 From: choelzl Date: Fri, 16 Jul 2021 09:18:25 +0200 Subject: [PATCH] init --- package.json | 11 ++--------- server.js | 28 ---------------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 655280f..22dc25e 100644 --- a/package.json +++ b/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" } } diff --git a/server.js b/server.js index ef063c2..88fadde 100644 --- a/server.js +++ b/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'