Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,3 +27,4 @@ bower_components
|
||||
main.css
|
||||
bundle.js
|
||||
coverage
|
||||
.remote-sync.json
|
||||
|
@ -7,7 +7,7 @@ Welcome to Free Code Camp's open source codebase!
|
||||
=======================
|
||||
|
||||
#Note
|
||||
We're currently very close to moving from express to loopback. As such, please keep in mind that the instructions here for setting up and running the project do not directly translate to the staging branch. Additionally, the file structure is quite a bit different. As always, the staging branch is the appropriate place to branch off of to fix/add something!
|
||||
We're currently very close to moving from Express to Loopback. As such, please keep in mind that the instructions here for setting up and running the project do not directly translate to the staging branch. Additionally, the file structure is quite a bit different. As always, the staging branch is the appropriate place to branch off of to fix/add something!
|
||||
|
||||
Free Code Camp is an open-source community of busy people who learn to code, then build projects for nonprofits.
|
||||
|
||||
|
@ -78,6 +78,8 @@ gulp.task('less', function() {
|
||||
.pipe(gulp.dest('./public/css/'));
|
||||
});
|
||||
|
||||
gulp.task('build', ['less']);
|
||||
|
||||
gulp.task('watch', ['less', 'serve', 'sync'], function() {
|
||||
gulp.watch('./public/css/*.less', ['less']);
|
||||
});
|
||||
|
@ -59,7 +59,7 @@
|
||||
"less": "~1.7.5",
|
||||
"less-middleware": "~2.0.1",
|
||||
"lodash": "^3.9.3",
|
||||
"loopback": "^2.18.0",
|
||||
"loopback": "https://github.com/FreeCodeCamp/loopback.git#fix/no-password",
|
||||
"loopback-boot": "^2.8.0",
|
||||
"loopback-component-passport": "git://github.com/FreeCodeCamp/loopback-component-passport.git#feature/emailOptional",
|
||||
"loopback-connector-mongodb": "^1.10.0",
|
||||
|
@ -2,9 +2,7 @@ require('dotenv').load();
|
||||
require('pmx').init();
|
||||
// handle uncaught exceptions. Forever will restart process on shutdown
|
||||
|
||||
var https = require('https'),
|
||||
sslConfig = require('./ssl-config'),
|
||||
R = require('ramda'),
|
||||
var R = require('ramda'),
|
||||
assign = require('lodash').assign,
|
||||
loopback = require('loopback'),
|
||||
boot = require('loopback-boot'),
|
||||
@ -54,7 +52,9 @@ app.use(compress());
|
||||
app.use(lessMiddleware(path.join(__dirname, '/public')));
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: true
|
||||
}));
|
||||
app.use(expressValidator({
|
||||
customValidators: {
|
||||
matchRegex: function(param, regex) {
|
||||
@ -145,8 +145,7 @@ app.use(helmet.csp({
|
||||
'https://cdn.inspectlet.com/inspectlet.js',
|
||||
'http://cdn.inspectlet.com/inspectlet.js'
|
||||
].concat(trusted),
|
||||
'connect-src': [
|
||||
].concat(trusted),
|
||||
'connect-src': [].concat(trusted),
|
||||
styleSrc: [
|
||||
'*.googleapis.com',
|
||||
'*.gstatic.com'
|
||||
@ -187,7 +186,9 @@ app.use(function (req, res, next) {
|
||||
});
|
||||
|
||||
app.use(
|
||||
loopback.static(path.join(__dirname, '../public'), { maxAge: 86400000 })
|
||||
loopback.static(path.join(__dirname, '../public'), {
|
||||
maxAge: 86400000
|
||||
})
|
||||
);
|
||||
|
||||
boot(app, {
|
||||
@ -224,7 +225,8 @@ var passportOptions = {
|
||||
null;
|
||||
|
||||
var username = (profile.username || profile.id);
|
||||
username = typeof username === 'string' ? username.toLowerCase() : username;
|
||||
username = typeof username === 'string' ? username.toLowerCase() :
|
||||
username;
|
||||
var password = generateKey('password');
|
||||
var userObj = {
|
||||
username: username,
|
||||
@ -256,7 +258,9 @@ R.keys(passportProviders).map(function(strategy) {
|
||||
*/
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
app.use(errorHandler({ log: true }));
|
||||
app.use(errorHandler({
|
||||
log: true
|
||||
}));
|
||||
} else {
|
||||
app.use(pmx.expressErrorHandler());
|
||||
// error handling in production disabling eslint due to express parity rules
|
||||
@ -279,12 +283,16 @@ if (process.env.NODE_ENV === 'development') {
|
||||
|
||||
var message = 'opps! Something went wrong. Please try again later';
|
||||
if (type === 'html') {
|
||||
req.flash('errors', { msg: message });
|
||||
req.flash('errors', {
|
||||
msg: message
|
||||
});
|
||||
return res.redirect('/');
|
||||
// json
|
||||
} else if (type === 'json') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return res.send({ message: message });
|
||||
return res.send({
|
||||
message: message
|
||||
});
|
||||
// plain text
|
||||
} else {
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
@ -297,23 +305,7 @@ if (process.env.NODE_ENV === 'development') {
|
||||
* Start Express server.
|
||||
*/
|
||||
|
||||
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() {
|
||||
console.log(
|
||||
'FreeCodeCamp server listening on port %d in %s mode',
|
||||
@ -321,7 +313,6 @@ if (process.env.NODE_ENV === 'production') {
|
||||
app.get('env')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// start the server if `$ node server.js`
|
||||
|
||||
|
Reference in New Issue
Block a user