Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@ -78,6 +78,7 @@
|
|||||||
"passport-local": "^1.0.0",
|
"passport-local": "^1.0.0",
|
||||||
"passport-oauth": "^1.0.0",
|
"passport-oauth": "^1.0.0",
|
||||||
"passport-twitter": "^1.0.3",
|
"passport-twitter": "^1.0.3",
|
||||||
|
"pmx": "^0.3.16",
|
||||||
"ramda": "~0.10.0",
|
"ramda": "~0.10.0",
|
||||||
"request": "~2.53.0",
|
"request": "~2.53.0",
|
||||||
"rx": "^2.5.3",
|
"rx": "^2.5.3",
|
||||||
|
@ -12,7 +12,7 @@ var __jailed__path__ = scripts[scripts.length-1].src
|
|||||||
.split('?')[0]
|
.split('?')[0]
|
||||||
.split('/')
|
.split('/')
|
||||||
.slice(0, -1)
|
.slice(0, -1)
|
||||||
.join('/')+'/';
|
.join('/') + '/';
|
||||||
|
|
||||||
// creating worker as a blob enables import of local files
|
// creating worker as a blob enables import of local files
|
||||||
var blobCode = [
|
var blobCode = [
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
require('dotenv').load();
|
require('dotenv').load();
|
||||||
|
require('pmx').init();
|
||||||
// handle uncaught exceptions. Forever will restart process on shutdown
|
// handle uncaught exceptions. Forever will restart process on shutdown
|
||||||
process.on('uncaughtException', function (err) {
|
|
||||||
console.error(
|
|
||||||
(new Date()).toUTCString() + ' uncaughtException:',
|
|
||||||
err.message
|
|
||||||
);
|
|
||||||
console.error(err.stack);
|
|
||||||
process.exit(1); // eslint-disable-line
|
|
||||||
});
|
|
||||||
|
|
||||||
var R = require('ramda'),
|
var https = require('https'),
|
||||||
|
sslConfig = require('./ssl-config'),
|
||||||
|
R = require('ramda'),
|
||||||
assign = require('lodash').assign,
|
assign = require('lodash').assign,
|
||||||
loopback = require('loopback'),
|
loopback = require('loopback'),
|
||||||
boot = require('loopback-boot'),
|
boot = require('loopback-boot'),
|
||||||
@ -26,8 +21,8 @@ var R = require('ramda'),
|
|||||||
flash = require('express-flash'),
|
flash = require('express-flash'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
expressValidator = require('express-validator'),
|
expressValidator = require('express-validator'),
|
||||||
forceDomain = require('forcedomain'),
|
|
||||||
lessMiddleware = require('less-middleware'),
|
lessMiddleware = require('less-middleware'),
|
||||||
|
pmx = require('pmx'),
|
||||||
|
|
||||||
passportProviders = require('./passport-providers'),
|
passportProviders = require('./passport-providers'),
|
||||||
/**
|
/**
|
||||||
@ -99,6 +94,10 @@ var trusted = [
|
|||||||
'104.236.218.15',
|
'104.236.218.15',
|
||||||
'*.freecodecamp.com',
|
'*.freecodecamp.com',
|
||||||
'http://www.freecodecamp.com',
|
'http://www.freecodecamp.com',
|
||||||
|
'https://www.freecodecamp.com',
|
||||||
|
'https://freecodecamp.com',
|
||||||
|
'https://freecodecamp.org',
|
||||||
|
'*.freecodecamp.org',
|
||||||
'ws://freecodecamp.com/',
|
'ws://freecodecamp.com/',
|
||||||
'ws://www.freecodecamp.com/',
|
'ws://www.freecodecamp.com/',
|
||||||
'*.gstatic.com',
|
'*.gstatic.com',
|
||||||
@ -129,8 +128,12 @@ var trusted = [
|
|||||||
'*.ytimg.com',
|
'*.ytimg.com',
|
||||||
'*.bitly.com',
|
'*.bitly.com',
|
||||||
'http://cdn.inspectlet.com/',
|
'http://cdn.inspectlet.com/',
|
||||||
|
'https://cdn.inspeclet.com/',
|
||||||
'wss://inspectletws.herokuapp.com/',
|
'wss://inspectletws.herokuapp.com/',
|
||||||
'http://hn.inspectlet.com/'
|
'http://hn.inspectlet.com/',
|
||||||
|
'*.googleapis.com',
|
||||||
|
'*.gstatic.com',
|
||||||
|
'https://hn.inspectlet.com/'
|
||||||
];
|
];
|
||||||
|
|
||||||
app.use(helmet.csp({
|
app.use(helmet.csp({
|
||||||
@ -138,22 +141,29 @@ app.use(helmet.csp({
|
|||||||
scriptSrc: [
|
scriptSrc: [
|
||||||
'*.optimizely.com',
|
'*.optimizely.com',
|
||||||
'*.aspnetcdn.com',
|
'*.aspnetcdn.com',
|
||||||
'*.d3js.org'
|
'*.d3js.org',
|
||||||
|
'https://cdn.inspectlet.com/inspectlet.js',
|
||||||
|
'http://cdn.inspectlet.com/inspectlet.js'
|
||||||
].concat(trusted),
|
].concat(trusted),
|
||||||
'connect-src': [
|
'connect-src': [
|
||||||
].concat(trusted),
|
].concat(trusted),
|
||||||
styleSrc: trusted,
|
styleSrc: [
|
||||||
|
'*.googleapis.com',
|
||||||
|
'*.gstatic.com'
|
||||||
|
].concat(trusted),
|
||||||
imgSrc: [
|
imgSrc: [
|
||||||
/* allow all input since we have user submitted images for public profile*/
|
/* allow all input since we have user submitted images for public profile*/
|
||||||
'*'
|
'*'
|
||||||
].concat(trusted),
|
].concat(trusted),
|
||||||
fontSrc: ['*.googleapis.com'].concat(trusted),
|
fontSrc: [
|
||||||
|
'*.googleapis.com',
|
||||||
|
'*.gstatic.com'
|
||||||
|
].concat(trusted),
|
||||||
mediaSrc: [
|
mediaSrc: [
|
||||||
'*.amazonaws.com',
|
'*.amazonaws.com',
|
||||||
'*.twitter.com'
|
'*.twitter.com'
|
||||||
].concat(trusted),
|
].concat(trusted),
|
||||||
frameSrc: [
|
frameSrc: [
|
||||||
|
|
||||||
'*.gitter.im',
|
'*.gitter.im',
|
||||||
'*.gitter.im https:',
|
'*.gitter.im https:',
|
||||||
'*.vimeo.com',
|
'*.vimeo.com',
|
||||||
@ -244,9 +254,11 @@ R.keys(passportProviders).map(function(strategy) {
|
|||||||
/**
|
/**
|
||||||
* 500 Error Handler.
|
* 500 Error Handler.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
app.use(errorHandler({ log: true }));
|
app.use(errorHandler({ log: true }));
|
||||||
} else {
|
} else {
|
||||||
|
app.use(pmx.expressErrorHandler());
|
||||||
// error handling in production disabling eslint due to express parity rules
|
// error handling in production disabling eslint due to express parity rules
|
||||||
// for error handlers
|
// for error handlers
|
||||||
app.use(function(err, req, res, next) { // eslint-disable-line
|
app.use(function(err, req, res, next) { // eslint-disable-line
|
||||||
@ -285,7 +297,23 @@ if (process.env.NODE_ENV === 'development') {
|
|||||||
* Start Express server.
|
* Start Express server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.start = function() {
|
var options = {
|
||||||
|
key: sslConfig.privateKey,
|
||||||
|
cert: sslConfig.certificate
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
var server = https.createServer(options, app);
|
||||||
|
console.log('https://' + process.env.HOST + ':' + process.env.PORT);
|
||||||
|
server.listen(app.get('port'), function () {
|
||||||
|
console.log(
|
||||||
|
'FreeCodeCamp server listening on port %d in %s mode',
|
||||||
|
app.get('port'),
|
||||||
|
app.get('env')
|
||||||
|
);
|
||||||
|
app.emit('started', 'https://' + process.env.HOST + ':' + app.get('port'));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
app.listen(app.get('port'), function () {
|
app.listen(app.get('port'), function () {
|
||||||
console.log(
|
console.log(
|
||||||
'FreeCodeCamp server listening on port %d in %s mode',
|
'FreeCodeCamp server listening on port %d in %s mode',
|
||||||
@ -293,11 +321,9 @@ app.start = function() {
|
|||||||
app.get('env')
|
app.get('env')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
// start the server if `$ node server.js`
|
|
||||||
if (require.main === module) {
|
|
||||||
app.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start the server if `$ node server.js`
|
||||||
|
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
16
server/ssl-config.js
Normal file
16
server/ssl-config.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Created by nathanleniz on 6/16/15.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
exports.privateKey =
|
||||||
|
fs.readFileSync(path.join(__dirname,
|
||||||
|
'../../private/privatekey.pem'));
|
||||||
|
exports.certificate =
|
||||||
|
fs.readFileSync(path.join(__dirname,
|
||||||
|
'../../private/certificate.pem'));
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,7 @@ block content
|
|||||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
||||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
link(rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||||
script(type='text/javascript', src='/js/lib/codemirror/mode/javascript/javascript.js')
|
script(type='text/javascript', src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||||
script(type='text/javascript', src='/js/lib/jailed/jailed.js')
|
script(type='text/javascript', src='/js/lib/jailed/jailed.js')
|
||||||
script(type='text/javascript', src='/js/lib/coursewares/sandbox.js')
|
script(type='text/javascript', src='/js/lib/coursewares/sandbox.js')
|
||||||
|
@ -10,7 +10,7 @@ block content
|
|||||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
||||||
link(rel="stylesheet", href="http://fonts.googleapis.com/css?family=Ubuntu+Mono")
|
link(rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono")
|
||||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||||
script(src='/js/lib/jailed/jailed.js')
|
script(src='/js/lib/jailed/jailed.js')
|
||||||
script(src='/js/lib/coursewares/sandbox.js')
|
script(src='/js/lib/coursewares/sandbox.js')
|
||||||
|
@ -38,7 +38,7 @@ script(src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js")
|
|||||||
|
|
||||||
script(src="/bower_components/ramda/dist/ramda.min.js")
|
script(src="/bower_components/ramda/dist/ramda.min.js")
|
||||||
|
|
||||||
link(rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Lato:400|Inconsolata")
|
link(rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Lato:400|Inconsolata")
|
||||||
|
|
||||||
link(rel="stylesheet" type="text/css" href="/bower_components/cal-heatmap/cal-heatmap.css")
|
link(rel="stylesheet" type="text/css" href="/bower_components/cal-heatmap/cal-heatmap.css")
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ script#inspectletjs(type='text/javascript').
|
|||||||
insp.type = 'text/javascript';
|
insp.type = 'text/javascript';
|
||||||
insp.async = true;
|
insp.async = true;
|
||||||
insp.id = "inspsync";
|
insp.id = "inspsync";
|
||||||
insp.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://cdn.inspectlet.com/inspectlet.js';
|
insp.src = '//cdn.inspectlet.com/inspectlet.js';
|
||||||
var x = document.getElementsByTagName('script')[0];
|
var x = document.getElementsByTagName('script')[0];
|
||||||
x.parentNode.insertBefore(insp, x);
|
x.parentNode.insertBefore(insp, x);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user