diff --git a/config/default.js b/config/default.js new file mode 100644 index 0000000..abda2e4 --- /dev/null +++ b/config/default.js @@ -0,0 +1,36 @@ +module.exports = { + host: process.env.HOST || 'localhost', + port: process.env.PORT || 7777, + + keyLength: 10, + + maxLength: 400000, + + staticMaxAge: 86400, + + recompressStaticAssets: true, + + logging: [ + { + level: "verbose", + type: "Console", + colorize: true + } + ], + + keyGenerator: { + type: "phonetic" + }, + + storage: { + type: "redis", + host: process.env.REDIS_HOST || 'localhost', + port: process.env.REDIS_PORT || 6379, + db: process.env.REDIS_DB || 2, + expire: process.env.REDIS_EXPIRE || 2592000 + }, + + documents: { + about: "./about.md" + } +}; diff --git a/config/docker.js b/config/docker.js new file mode 100644 index 0000000..eb9b7b1 --- /dev/null +++ b/config/docker.js @@ -0,0 +1,36 @@ +module.exports = { + host: "0.0.0.0", + port: 7777, + + keyLength: 10, + + maxLength: 400000, + + staticMaxAge: 86400, + + recompressStaticAssets: true, + + logging: [ + { + level: "verbose", + type: "Console", + colorize: true + } + ], + + keyGenerator: { + type: "phonetic" + }, + + storage: { + type: "redis", + host: process.env.REDIS_PORT_6379_TCP_ADDR || process.env.REDIS_HOST || 'localhost', + port: process.env.REDIS_PORT_6379_TCP_PORT || process.env.REDIS_PORT || 6379, + db: process.env.REDIS_DB || 2, + expire: process.env.REDIS_EXPIRE || 2592000 + }, + + documents: { + about: "./about.md" + } +}; diff --git a/package.json b/package.json index 8ba9dea..7b70564 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "connect": "1.9.2", "redis-url": "0.1.0", "redis": "0.8.1", - "uglify-js": "1.3.3" + "uglify-js": "1.3.3", + "config": "0.4.35" }, "devDependencies": { "mocha": "*", diff --git a/server.js b/server.js index aaf1583..fa1d656 100644 --- a/server.js +++ b/server.js @@ -1,17 +1,13 @@ var http = require('http'); var url = require('url'); var fs = require('fs'); +var config = require('config'); var winston = require('winston'); var connect = require('connect'); var DocumentHandler = require('./lib/document_handler'); -// Load the configuration and set some defaults -var config = JSON.parse(fs.readFileSync('./config.js', 'utf8')); -config.port = process.env.PORT || config.port || 7777; -config.host = process.env.HOST || config.host || 'localhost'; - // Set up the logger if (config.logging) { try {