From f42e57a3b3730e1b44e95e0b85a59779aefa36e8 Mon Sep 17 00:00:00 2001 From: choelzl Date: Fri, 16 Jul 2021 11:58:43 +0200 Subject: [PATCH] fixes --- compile_sass.js | 20 ++++++-------------- package.json | 1 + router/api.js | 9 +++------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/compile_sass.js b/compile_sass.js index 624e269..6dd153b 100644 --- a/compile_sass.js +++ b/compile_sass.js @@ -40,17 +40,9 @@ function compileSassProduction(sassFile) { const cssPath = path.join(__dirname, 'public/css/'); const fullCssPath = path.join(cssPath, cssFile); - return compileSass(fullSassPath).then(css => { - return new Promise((resolve, reject) => { - mkdirp(cssPath, error => { - if (error) { - return reject(error); - } - - resolve(); - }); - }).then(() => { - return new Promise((resolve, reject) => { + return compileSass(fullSassPath).then(css => + mkdirp(cssPath).then(() => + new Promise((resolve, reject) => { fs.writeFile(fullCssPath, css, error => { if (error) { return reject(error); @@ -58,9 +50,9 @@ function compileSassProduction(sassFile) { resolve(cssFile); }); - }); - }).catch(console.error); - }); + }) + ) + ).catch(console.error);; } function compileSassMain() { diff --git a/package.json b/package.json index 11be5dc..20da110 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "fastify": "latest", "fastify-leveldb": "latest", "fastify-static": "^2.5.0", + "mkdirp": "^1.0.4", "node-sass": "^6.0.0" } } diff --git a/router/api.js b/router/api.js index 7e6bc8c..fd3927b 100644 --- a/router/api.js +++ b/router/api.js @@ -24,8 +24,7 @@ module.exports = (fastify, opts, done) => { if(req.params.id == undefined){ reply.code(400).send({error:"No ID query parameter"}); } else { - const { level } = fastify - level.get(req.params.id, (err, val) => { + fastify.level.get(req.params.id, (err, val) => { if(err){ console.warn(err); reply.send({name:"New Journey", main:[]}); @@ -40,8 +39,7 @@ module.exports = (fastify, opts, done) => { if(req.params.id == undefined){ reply.code(400).send({error:"No ID query parameter"}); } else { - const { level } = fastify - level.put(req.params.id, JSON.stringify(req.body), (err) => { + fastify.level.put(req.params.id, JSON.stringify(req.body), (err) => { if(err){ console.warn(err); reply.code(500).send({error:"Error with DB"}); @@ -56,8 +54,7 @@ module.exports = (fastify, opts, done) => { if(req.params.id == undefined){ reply.code(400).send({error:"No ID query parameter"}); } else { - const { level } = fastify - level.delete(req.params.id,(err) => { + fastify.level.delete(req.params.id,(err) => { if(err){ console.warn(err); reply.code(500).send({error:"Error with DB"});