|
|
|
@ -5,14 +5,13 @@ var fs = require('fs')
|
|
|
|
|
, stack = require('stack')
|
|
|
|
|
, route = require('tiny-route')
|
|
|
|
|
, assets = require('ecstatic')
|
|
|
|
|
, join = require('path').join
|
|
|
|
|
, config = require('./config')
|
|
|
|
|
, db = require('level')(config.db_path, config.db_opts)
|
|
|
|
|
, port = process.env.PORT || config.port
|
|
|
|
|
|
|
|
|
|
// create the level db folder if it does not exists
|
|
|
|
|
if(!fs.existsSync('./db/squatconf')){
|
|
|
|
|
fs.mkdirSync('./db/squatconf', 0766, function(err){
|
|
|
|
|
if(!fs.existsSync(config.db_path)){
|
|
|
|
|
fs.mkdirSync(config.db_path, 0766, function(err){
|
|
|
|
|
if(err){
|
|
|
|
|
console.log(err);
|
|
|
|
|
}
|
|
|
|
@ -22,7 +21,7 @@ if(!fs.existsSync('./db/squatconf')){
|
|
|
|
|
var app = stack(
|
|
|
|
|
route('/email', require('./src/email-submit')(db))
|
|
|
|
|
, route('/confirm', require('./src/email-confirm')(db))
|
|
|
|
|
, assets(join(__dirname, 'html'))
|
|
|
|
|
, assets({ root: __dirname +'/html', handleError: false })
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
process.on('uncaughtException', function (err) {
|
|
|
|
@ -31,7 +30,7 @@ process.on('uncaughtException', function (err) {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
http.createServer(app).listen(port, function() {
|
|
|
|
|
console.log('['+ process.pid +'] server started on port '+ port)
|
|
|
|
|
console.log('[PID='+ process.pid +'] server started on port '+ port)
|
|
|
|
|
console.log('(use Ctrl+c to stop the server)')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|