cleaning old info, rework main text of the website, begin removing the old db system
parent
f38f3baf92
commit
ce9282f04b
@ -1,43 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var fs = require('fs')
|
||||
, http = require('http')
|
||||
, stack = require('stack')
|
||||
, route = require('tiny-route')
|
||||
, assets = require('ecstatic')
|
||||
, 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(config.db_path)){
|
||||
fs.mkdirSync(config.db_path, 0766, function(err){
|
||||
if(err){
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
stack.errorHandler = function error(req, res, err) {
|
||||
res.statusCode = 302
|
||||
res.setHeader('Location', '/')
|
||||
res.end()
|
||||
}
|
||||
|
||||
var app = stack(
|
||||
route('/email', require('./src/email-submit')(db))
|
||||
, route('/confirm', require('./src/email-confirm')(db))
|
||||
, assets({ root: __dirname +'/html', handleError: false })
|
||||
)
|
||||
var ecstatic = require('ecstatic')
|
||||
, app = require('http').createServer(
|
||||
ecstatic({ root: __dirname + '/public' })
|
||||
).listen(8000)
|
||||
;
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
console.error('Error at:', new Date)
|
||||
console.error(err.stack)
|
||||
})
|
||||
|
||||
http.createServer(app).listen(port, function() {
|
||||
console.log('[PID='+ process.pid +'] server started on port '+ port)
|
||||
console.log('(use Ctrl+c to stop the server)')
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue