Skip to content

Commit

Permalink
Merge pull request #144 from impronunciable/feature-refactor-es6
Browse files Browse the repository at this point in the history
Core: Partially moved to ES6.
  • Loading branch information
pjnovas committed Oct 5, 2015
2 parents 267b6d0 + c0e4dce commit 7cef485
Show file tree
Hide file tree
Showing 64 changed files with 1,953 additions and 3,446 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ node_modules
.sublime-project
.sublime-workspace
keys.json
config.json
config.test.json
config/config.json
config/config.test.json
public/uploads/*
npm-debug.log

public/styles/app.css
public/styles/embed.css
public/styles/landing.css

*.sample
48 changes: 0 additions & 48 deletions Gruntfile.js

This file was deleted.

136 changes: 0 additions & 136 deletions auth.js

This file was deleted.

29 changes: 0 additions & 29 deletions config.json.sample

This file was deleted.

29 changes: 29 additions & 0 deletions config/config.json.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
db: {
name: "hackdash",
host: "localhost",
url: null
},
host: "local.host",
port: 3000,
session: "wefewfef",
disqus_shortname: null,
title: "hackdash",
live: true,
mailer: null,
prerender: {
enabled: false,
db: "mongodb://localhost/prerender"
},
team: [
"516d1997b2951b02280000e1",
"516d1997b2951b02280000e2",
"516d1997b2951b02280000e3",
"516d1997b2951b02280000e4",
"516d1997b2951b02280000e5",
"516d1997b2951b02280000e6"
],
maxQueryLimit: 30,
googleAnalytics: "UA-XXXXXXXX-X",
facebookAppId: "YYYYYYYYYYYY"
}
10 changes: 10 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

/**
* Expose the configuration. Uses the test config if NODE_ENV env setting
* is set as 'test'. Otherwise it uses the default config file
*/

import config from './config.json';
import testConfig from './config.test.json';

export default process.env.NODE_ENV === 'test' ? testConfig : config;
101 changes: 101 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Module dependencies.
*/

require('babel/register');

var app = require('lib/server');
var debug = require('debug')('hackdash:server');
var http = require('http');
var config = require('config');
var live = require('lib/live');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/*
* Live dashboard. It uses socketIO to provide cool `realtime` features
* it's an opt-in from the config file.
*/

if(config.live) {
live(app, server);
}

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
Loading

0 comments on commit 7cef485

Please sign in to comment.