Skip to content

Commit 7cef485

Browse files
committed
Merge pull request #144 from impronunciable/feature-refactor-es6
Core: Partially moved to ES6.
2 parents 267b6d0 + c0e4dce commit 7cef485

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1953
-3446
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ node_modules
33
.sublime-project
44
.sublime-workspace
55
keys.json
6-
config.json
7-
config.test.json
6+
config/config.json
7+
config/config.test.json
88
public/uploads/*
99
npm-debug.log
1010

1111
public/styles/app.css
1212
public/styles/embed.css
1313
public/styles/landing.css
14-
15-
*.sample

Gruntfile.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

auth.js

Lines changed: 0 additions & 136 deletions
This file was deleted.

config.json.sample

Lines changed: 0 additions & 29 deletions
This file was deleted.

config/config.json.sample

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
db: {
3+
name: "hackdash",
4+
host: "localhost",
5+
url: null
6+
},
7+
host: "local.host",
8+
port: 3000,
9+
session: "wefewfef",
10+
disqus_shortname: null,
11+
title: "hackdash",
12+
live: true,
13+
mailer: null,
14+
prerender: {
15+
enabled: false,
16+
db: "mongodb://localhost/prerender"
17+
},
18+
team: [
19+
"516d1997b2951b02280000e1",
20+
"516d1997b2951b02280000e2",
21+
"516d1997b2951b02280000e3",
22+
"516d1997b2951b02280000e4",
23+
"516d1997b2951b02280000e5",
24+
"516d1997b2951b02280000e6"
25+
],
26+
maxQueryLimit: 30,
27+
googleAnalytics: "UA-XXXXXXXX-X",
28+
facebookAppId: "YYYYYYYYYYYY"
29+
}

config/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
/**
3+
* Expose the configuration. Uses the test config if NODE_ENV env setting
4+
* is set as 'test'. Otherwise it uses the default config file
5+
*/
6+
7+
import config from './config.json';
8+
import testConfig from './config.test.json';
9+
10+
export default process.env.NODE_ENV === 'test' ? testConfig : config;

index.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
require('babel/register');
6+
7+
var app = require('lib/server');
8+
var debug = require('debug')('hackdash:server');
9+
var http = require('http');
10+
var config = require('config');
11+
var live = require('lib/live');
12+
13+
/**
14+
* Get port from environment and store in Express.
15+
*/
16+
17+
var port = normalizePort(process.env.PORT || '3000');
18+
app.set('port', port);
19+
20+
/**
21+
* Create HTTP server.
22+
*/
23+
24+
var server = http.createServer(app);
25+
26+
/**
27+
* Listen on provided port, on all network interfaces.
28+
*/
29+
30+
server.listen(port);
31+
server.on('error', onError);
32+
server.on('listening', onListening);
33+
34+
/*
35+
* Live dashboard. It uses socketIO to provide cool `realtime` features
36+
* it's an opt-in from the config file.
37+
*/
38+
39+
if(config.live) {
40+
live(app, server);
41+
}
42+
43+
/**
44+
* Normalize a port into a number, string, or false.
45+
*/
46+
47+
function normalizePort(val) {
48+
var port = parseInt(val, 10);
49+
50+
if (isNaN(port)) {
51+
// named pipe
52+
return val;
53+
}
54+
55+
if (port >= 0) {
56+
// port number
57+
return port;
58+
}
59+
60+
return false;
61+
}
62+
63+
/**
64+
* Event listener for HTTP server "error" event.
65+
*/
66+
67+
function onError(error) {
68+
if (error.syscall !== 'listen') {
69+
throw error;
70+
}
71+
72+
var bind = typeof port === 'string'
73+
? 'Pipe ' + port
74+
: 'Port ' + port;
75+
76+
// handle specific listen errors with friendly messages
77+
switch (error.code) {
78+
case 'EACCES':
79+
console.error(bind + ' requires elevated privileges');
80+
process.exit(1);
81+
break;
82+
case 'EADDRINUSE':
83+
console.error(bind + ' is already in use');
84+
process.exit(1);
85+
break;
86+
default:
87+
throw error;
88+
}
89+
}
90+
91+
/**
92+
* Event listener for HTTP server "listening" event.
93+
*/
94+
95+
function onListening() {
96+
var addr = server.address();
97+
var bind = typeof addr === 'string'
98+
? 'pipe ' + addr
99+
: 'port ' + addr.port;
100+
debug('Listening on ' + bind);
101+
}

0 commit comments

Comments
 (0)