From a788d2954d1805d4601155b44198172d2a8d9b7b Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 16 Jun 2015 14:53:18 -0700 Subject: [PATCH 1/4] add hacked loopback version this version avoids cheking indexOf on falsey values --- gulpfile.js | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 46c6cbd82d..e5cd405528 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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']); }); diff --git a/package.json b/package.json index 97277d8279..d156bb0873 100644 --- a/package.json +++ b/package.json @@ -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", From 63641a141b72d40827987ab5a4c10b5298201f8d Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Wed, 17 Jun 2015 12:43:30 -0400 Subject: [PATCH 2/4] Update .gitignore to ignore .remote-sync.json file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 112d64591e..60d9092f91 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ bower_components main.css bundle.js coverage +.remote-sync.json From b88f862cd6f379919bd4b998ccae132b60210620 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Wed, 17 Jun 2015 13:25:34 -0400 Subject: [PATCH 3/4] Update readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a7e0e9151..9770de3ebc 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ 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. +Free Code Camp is an open-source community of busy people who learn to code, then build projects for nonprofits. Our campers (students) start by working through our free, self-paced, browser-based curriculum. Next, they build several practice projects. Finally, we pair two campers together with a stakeholder from a nonprofit organization, and help them build the solution the nonprofit has requested. @@ -17,7 +17,7 @@ Our campers (students) start by working through our free, self-paced, browser-ba 80% of our campers are over 25, and nearly a fifth of our campers are women. -This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp). +This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp). [Join our community](http://www.freecodecamp.com/signin)! @@ -28,7 +28,7 @@ We welcome pull requests from Free Code Camp campers (our students) and seasoned 1. Check our [public Waffle Board](https://waffle.io/freecodecamp/freecodecamp). 2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Slack](http://freecodecamp.slack.com). -3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy. +3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy. 4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches)) 5. Name the branch something like `user-xxx` where user is your username and xxx is the issue number you are addressing. 6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [AirBnB's JavaScript Style Guide](https://github.com/airbnb/javascript). Please do not ignore any linting errors, as they are meant to **help** you. Make sure none of your JavaScript is longer than 80 characters per line. From fbb7d0b06552c4cd9e137dd1283b41e817b99d80 Mon Sep 17 00:00:00 2001 From: terakilobyte Date: Wed, 17 Jun 2015 15:40:44 -0400 Subject: [PATCH 4/4] Remove ssl on node servers --- server/server.js | 67 +++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/server/server.js b/server/server.js index cc69e11ae3..343e417b44 100755 --- a/server/server.js +++ b/server/server.js @@ -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,10 +52,12 @@ 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) { + matchRegex: function(param, regex) { return regex.test(param); } } @@ -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' @@ -180,14 +179,16 @@ app.use(helmet.csp({ passportConfigurator.init(); -app.use(function (req, res, next) { +app.use(function(req, res, next) { // Make user object available in templates. res.locals.user = req.user; next(); }); app.use( - loopback.static(path.join(__dirname, '../public'), { maxAge: 86400000 }) + loopback.static(path.join(__dirname, '../public'), { + maxAge: 86400000 + }) ); boot(app, { @@ -195,7 +196,7 @@ boot(app, { dev: process.env.NODE_ENV }); -app.use(function (req, res, next) { +app.use(function(req, res, next) { // Remember original destination before login. var path = req.path.split('/')[1]; if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) { @@ -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,31 +305,14 @@ 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', - app.get('port'), - app.get('env') - ); - }); -} +app.listen(app.get('port'), function() { + console.log( + 'FreeCodeCamp server listening on port %d in %s mode', + app.get('port'), + app.get('env') + ); +}); // start the server if `$ node server.js`