diff --git a/config.template.yaml b/config.template.yaml index 19d95654..6796f134 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -15,6 +15,8 @@ http: host: '' port: 8080 domain: 'http://localhost' + # Use express-minify to minify CSS and Javascript + minify: false # HTTPS server details https: diff --git a/lib/config.js b/lib/config.js index d809068e..10d45fa7 100644 --- a/lib/config.js +++ b/lib/config.js @@ -25,7 +25,8 @@ var defaults = { http: { host: "", port: 8080, - domain: "http://localhost" + domain: "http://localhost", + minify: false }, https: { enabled: false, diff --git a/lib/web/webserver.js b/lib/web/webserver.js index 66b2f386..fcaa2bbc 100644 --- a/lib/web/webserver.js +++ b/lib/web/webserver.js @@ -184,6 +184,11 @@ module.exports = { app.use(express.json()); app.use(express.urlencoded()); app.use(express.cookieParser()); + + if (Config.get("http.minify")) { + app.use(require("express-minify")()); + Logger.syslog.log("Enabled express-minify for CSS and JS"); + } /* Order here is important * Since I placed /r/:channel above *, the function will * not apply to the /r/:channel route. This prevents diff --git a/package.json b/package.json index 8a634f69..8f0997e3 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "socket.io": "~0.9.16", "nodemailer": "~0.6.0", "cookie": "~0.1.0", - "yamljs": "~0.1.4" + "yamljs": "~0.1.4", + "express-minify": "0.0.7" } } diff --git a/test-database.js b/test-database.js new file mode 100644 index 00000000..cb0b5c04 --- /dev/null +++ b/test-database.js @@ -0,0 +1,39 @@ +var cfg = { + "mysql-server": "localhost", + "mysql-user": "syncdevel", + "mysql-db": "syncdevel", + "mysql-pw": "tacky", + "debug": true +}; + +var Database = require("./database"); + +var db = new Database(cfg); +var assert = require('assert'); +db.init(); + +setTimeout(function () { + db.channelExists("adsjnfgjdsg", function (err, res) { + assert(!err && !res); + }); + + db.channelExists("xchan", function (err, res) { + assert(!err && res); + }); + + db.removeFromLibrary("xchan", "xxx2364", function (err, res) { + assert(!err); + console.log(res); + }); + + db.getLibraryItem("xchan", "xxx23456", function (err, media) { + assert(!err); + assert(media === null); + }); + + db.getLibraryItem("xchan", "G7X5s5vacIU", function (err, media) { + assert(!err); + assert(media !== null); + assert(media.id === "G7X5s5vacIU"); + }); +}, 1000);