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