From 78082f7152204158a1b7548bdb0dfb1ba49c097d Mon Sep 17 00:00:00 2001 From: Priansh Shah Date: Mon, 9 Apr 2018 20:22:41 +0000 Subject: [PATCH] fix jsep import, add fillin for HTTPS server, remove debug flag --- app/views/form.server.view.pug | 1 + app/views/index.server.view.pug | 2 +- app/views/redoc.server.view.pug | 1 - config/express.js | 11 +- gruntfile.js | 2 +- gruntfile.js.save | 354 ++++++++++++++++++++++++++++++++ package-lock.json | 212 +------------------ package.json | 1 + server.js | 18 +- test.js | 11 + 10 files changed, 399 insertions(+), 214 deletions(-) create mode 100755 gruntfile.js.save create mode 100644 test.js diff --git a/app/views/form.server.view.pug b/app/views/form.server.view.pug index 366a0242..df092a05 100644 --- a/app/views/form.server.view.pug +++ b/app/views/form.server.view.pug @@ -59,6 +59,7 @@ html(lang='en', xmlns='http://www.w3.org/1999/xhtml') script(type='text/javascript'). socketUrl = "!{socketUrl}" + script(src='https://cdn.jsdelivr.net/npm/jsep@0.3.4/build/jsep.min.js', type='text/javascript') script(src='/static/lib/jquery/dist/jquery.min.js', type='text/javascript') link(rel='stylesheet', href='/static/lib/font-awesome/css/font-awesome.min.css') link(rel='stylesheet', href='/static/lib/bootstrap/dist/css/bootstrap.min.css') diff --git a/app/views/index.server.view.pug b/app/views/index.server.view.pug index 10c29935..c26cdc99 100644 --- a/app/views/index.server.view.pug +++ b/app/views/index.server.view.pug @@ -52,4 +52,4 @@ block content script(src='https://cdn.ravenjs.com/2.3.0/angular/raven.min.js') - script Raven.config('https://825fefd6b4ed4a4da199c1b832ca845c@sentry.tellform.com/2').install(); \ No newline at end of file + script Raven.config('https://825fefd6b4ed4a4da199c1b832ca845c@sentry.tellform.com/2').install(); diff --git a/app/views/redoc.server.view.pug b/app/views/redoc.server.view.pug index c850dc96..dde17ad1 100644 --- a/app/views/redoc.server.view.pug +++ b/app/views/redoc.server.view.pug @@ -32,7 +32,6 @@ html(lang='en', xmlns='http://www.w3.org/1999/xhtml') // Fav Icon link(href='/static/modules/core/img/brand/favicon.ico', rel='shortcut icon', type='image/x-icon') link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,900') - //Application CSS Files each cssFile in cssFiles link(rel='stylesheet', href='#{cssFile}') diff --git a/config/express.js b/config/express.js index 902beb6f..05fe2881 100755 --- a/config/express.js +++ b/config/express.js @@ -48,9 +48,18 @@ function containsAnySupportedLanguages(preferredLanguages){ return null; } +var fs = require('fs') +var https = require('https') +var pkey = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/privkey.pem') +var cert = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/fullchain.pem') + module.exports = function(db) { + // Initialize express app var app = express(); + var serv = https.createServer({key: pkey, cert: cert}, app) + serv.listen(443) + app.get('/form', (q, s) => s.redirect('https://register.earlybird.camp/view/#!/forms/5acb2d8e541901c14fa0d907')) var url = require('url'); // Globbing model files @@ -356,5 +365,5 @@ module.exports = function(db) { app = configureSocketIO(app, db); // Return Express server instance - return app; + return app }; diff --git a/gruntfile.js b/gruntfile.js index 0b5539b9..eeb2c7ff 100755 --- a/gruntfile.js +++ b/gruntfile.js @@ -138,7 +138,7 @@ module.exports = function(grunt) { dev: { script: 'server.js', options: { - nodeArgs: ['--debug'], + //nodeArgs: ['--debug'], ext: 'js,html', watch: watchFiles.serverViews.concat(watchFiles.serverJS) } diff --git a/gruntfile.js.save b/gruntfile.js.save new file mode 100755 index 00000000..79585c25 --- /dev/null +++ b/gruntfile.js.save @@ -0,0 +1,354 @@ +'use strict'; + +var bowerArray = ['public/lib/angular/angular.min.js', + 'public/lib/angular-scroll/angular-scroll.min.js', + 'public/lib/angular-ui-select/dist/select.min.js', + 'public/lib/v-button/dist/v-button.min.js', + 'public/lib/angular-resource/angular-resource.min.js', + 'public/lib/angular-ui-router/release/angular-ui-router.min.js', + 'public/lib/angular-bootstrap/ui-bootstrap-tpls.js', + 'public/lib/angular-translate/angular-translate.min.js', + 'public/lib/ng-file-upload/ng-file-upload-all.min.js', + 'public/lib/angular-ui-date/src/date.js', + 'public/lib/angular-input-stars/angular-input-stars.js', + 'public/lib/jsep/build/jsep.min.js', + 'public/lib/raven-js/dist/raven.min.js', + 'public/lib/lodash/lodash.min.js', + 'public/lib/mobile-detect/mobile-detect.js', + 'public/lib/js-yaml/dist/js-yaml.js', + 'public/lib/angular-sanitize/angular-sanitize.min.js']; + +module.exports = function(grunt) { + require('jit-grunt')(grunt); + + // Unified Watch Object + var watchFiles = { + serverViews: ['app/views/**/*.pug'], + serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js', '!app/tests/'], + + clientViews: ['public/modules/**/*.html', 'public/form_modules/forms/base/**/*.html', '!public/modules/forms/base/**/*.html',], + clientJS: ['public/form_modules/**/*.js', 'public/modules/**/*.js'], + clientCSS: ['public/modules/**/*.css'], + + serverTests: ['app/tests/**/*.js'], + clientTests: ['public/modules/**/tests/*.js'] + }; + + watchFiles.allTests = watchFiles.serverTests.concat(watchFiles.clientTests); + + // Project Configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + watch: { + serverViews: { + files: watchFiles.serverViews, + options: { + livereload: true, + spawn: false + } + }, + serverJS: { + files: watchFiles.serverJS, + tasks: ['newer:jshint'], + options: { + livereload: true, + spawn: false + } + }, + clientViews: { + files: watchFiles.clientViews, + tasks: ['html2js:main'], + options: { + livereload: true, + spawn: false + } + }, + clientJS: { + files: watchFiles.clientJS, + tasks: ['newer:jshint'], + options: { + livereload: true, + spawn: false + } + }, + clientCSS: { + files: watchFiles.clientCSS, + tasks: ['newer:csslint'], + options: { + livereload: true, + spawn: false + } + }, + mochaTests: { + files: watchFiles.serverTests, + tasks: ['test:server'] + } + }, + jshint: { + all: { + src: watchFiles.clientJS.concat(watchFiles.serverJS), + options: { + jshintrc: true + } + }, + allTests: { + src: watchFiles.allTests, + options: { + jshintrc: true + } + } + }, + csslint: { + options: { + csslintrc: '.csslintrc' + }, + all: { + src: watchFiles.clientCSS + } + }, + uglify: { + productionAdmin: { + options: { + compress: true, + mangled: true + }, + files: { + 'public/dist/application.min.js': 'public/dist/application.js', + 'public/dist/form-application.min.js': 'public/dist/form-application.js' + } + }, + productionForms: { + options: { + mangled: true, + compress: true + }, + files: { + 'public/dist/form-vendor.min.js': bowerArray + } + } + }, + cssmin: { + combine: { + files: { + 'public/dist/application.min.css': '<%= applicationCSSFiles %>' + } + } + }, + nodemon: { + dev: { + script: 'server.js', + options: { + + ext: 'js,html', + watch: watchFiles.serverViews.concat(watchFiles.serverJS) + } + } + }, + ngAnnotate: { + options:{ + add: true, + remove: true + }, + production: { + files: { + 'public/dist/application.js': '<%= applicationJavaScriptFiles %>', + 'public/dist/form-application.js': '<%= formApplicationJavaScriptFiles %>' + } + } + }, + concurrent: { + default: ['nodemon', 'watch'], + debug: ['nodemon', 'watch'], + options: { + logConcurrentOutput: true, + limit: 10 + } + }, + env: { + src: '.env', + + test: { + NODE_ENV: 'test', + }, + secure: { + NODE_ENV: 'secure', + }, + production: { + NODE_ENV: 'production', + }, + dev: { + NODE_ENV: 'development', + } + }, + mochaTest: { + src: watchFiles.serverTests, + options: { + reporter: 'spec', + quiet: false, + require: 'server.js', + ui: 'bdd', + debug: false + } + }, + karma: { + unit: { + configFile: 'karma.conf.js', + singleRun: true + }, + debug: { + configFile: 'karma.conf.js', + browserConsoleLogOptions: { + level: 'log', + terminal: true + }, + singleRun: true + } + }, + protractor: { + options: { + configFile: 'protractor.conf.js', + keepAlive: true, + noColor: false + }, + e2e: { + options: { + args: {} // Target-specific arguments + } + } + }, + mocha_istanbul: { + coverage: { + src: watchFiles.allTests, // a folder works nicely + options: { + mask: '*.test.js', + require: ['server.js'] + } + }, + coverageClient: { + src: watchFiles.clientTests, // specifying file patterns works as well + options: { + coverageFolder: 'coverageClient', + mask: '*.test.js', + require: ['server.js'] + } + }, + coverageServer: { + src: watchFiles.serverTests, + options: { + coverageFolder: 'coverageServer', + mask: '*.test.js', + require: ['server.js'] + } + }, + coveralls: { + src: watchFiles.allTests, // multiple folders also works + options: { + require: ['server.js'], + coverage: true, // this will make the grunt.event.on('coverage') event listener to be triggered + root: './lib', // define where the cover task should consider the root of libraries that are covered by tests + reportFormats: ['cobertura','lcovonly'] + } + } + }, + istanbul_check_coverage: { + default: { + options: { + coverageFolder: 'coverage*', // will check both coverage folders and merge the coverage results + check: { + lines: 80, + statements: 80 + } + } + } + }, + html2js: { + options: { + base: 'public', + watch: true, + singleModule: true, + useStrict: true, + htmlmin: { + collapseBooleanAttributes: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, + removeEmptyAttributes: true, + removeRedundantAttributes: true + } + }, + forms: { + options: { + module: 'TellForm-Form.form_templates' + }, + src: ['public/form_modules/**/views/**.html', 'public/form_modules/**/views/**/*.html'], + dest: 'public/dist/form_populate_template_cache.js' + }, + main: { + options: { + module: 'TellForm.templates' + }, + src: ['public/modules/**/views/**.html', 'public/modules/**/views/**/*.html', 'public/form_modules/forms/base/**/*.html', '!public/modules/forms/base/**/*.html'], + dest: 'public/dist/populate_template_cache.js' + } + }, + execute: { + target: { + src: ['./scripts/setup.js'] + } + }, + }); + + grunt.event.on('coverage', function(lcov, done){ + var coveralls = require('coveralls'); + coveralls.handleInput(lcov, function(err){ + if (err) { + grunt.log.error('Failed to submit lcov file to coveralls: ' + err); + return done(err); + } + grunt.verbose.ok('Successfully submitted lcov file to coveralls'); + done(); + }); + }); + + // Making grunt default to force in order not to break the project. + grunt.option('force', true); + + // A Task for loading the configuration object + grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() { + require('./config/init')(); + var config = require('./config/config'); + grunt.config.set('applicationJavaScriptFiles', config.assets.js); + grunt.config.set('formApplicationJavaScriptFiles', config.assets.form_js); + grunt.config.set('applicationCSSFiles', config.assets.css); + }); + + // Code coverage tasks. + grunt.registerTask('coveralls', ['env:test','mocha_istanbul:coveralls']); + grunt.registerTask('coverage', ['env:test', 'mocha_istanbul:coverage']); + grunt.registerTask('coverage:client', ['env:test', 'mocha_istanbul:coverageClient']); + grunt.registerTask('coverage:server', ['env:test', 'mocha_istanbul:coverageServer']); + + // Default task(s). + grunt.registerTask('default', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'html2js:main', 'html2js:forms', 'env', 'concurrent:default']); + grunt.registerTask('dev', ['lint', 'html2js:main', 'html2js:forms', 'env:dev', 'concurrent:default']); + + // Debug task. + grunt.registerTask('debug', ['lint', 'html2js:main', 'html2js:forms', 'concurrent:debug']); + + // Lint task(s). + grunt.registerTask('lint', ['jshint', 'csslint', 'i18nlint:client', 'i18nlint:server']); + grunt.registerTask('lint:tests', ['jshint:allTests']); + + // Build task(s). + grunt.registerTask('build', ['lint', 'loadConfig', 'cssmin', 'ngAnnotate', 'uglify', 'html2js:main', 'html2js:forms']); + + //Setup task(s). + grunt.registerTask('setup', ['execute']); + + // Test task(s). + grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']); + grunt.registerTask('test:server', ['lint:tests', 'env:test', 'mochaTest']); + grunt.registerTask('test:client', ['lint:tests', 'html2js:main', 'html2js:forms', 'env:test', 'karma:unit']); + + grunt.registerTask('testdebug', ['env:test', 'karma:debug']); +}; diff --git a/package-lock.json b/package-lock.json index fcb91c18..da5ada29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -505,11 +505,6 @@ "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=" }, - "bluebird": { - "version": "2.10.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz", - "integrity": "sha1-AkpVFylTCIV/FPkfEQb8O1VfRGs=" - }, "body-parser": { "version": "1.14.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.14.2.tgz", @@ -3866,75 +3861,6 @@ "integrity": "sha1-24qsR/+Ap9+CtMgsEm/olwhwYm8=", "dev": true }, - "email-verification": { - "version": "github:tellform/node-email-verification#8b179f34e0943c389b2058c9ec1e6d2135a72857", - "requires": { - "mongoose": "3.8.40", - "nodemailer": "4.0.1", - "rand-token": "0.2.1" - }, - "dependencies": { - "bson": { - "version": "0.2.22", - "resolved": "https://registry.npmjs.org/bson/-/bson-0.2.22.tgz", - "integrity": "sha1-/NoQPybQwHTVpS1Qkn24D9ArSzk=", - "requires": { - "nan": "1.8.4" - } - }, - "mongodb": { - "version": "1.4.38", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-1.4.38.tgz", - "integrity": "sha1-jP/WGBAK86RkiplUmL/Py07Yq9I=", - "requires": { - "bson": "0.2.22", - "kerberos": "0.0.11", - "readable-stream": "2.3.3" - } - }, - "mongoose": { - "version": "3.8.40", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-3.8.40.tgz", - "integrity": "sha1-Ay9bpVWCSXVZqHwfP0s5WcJkBqc=", - "requires": { - "hooks": "0.2.1", - "mongodb": "1.4.38", - "mpath": "0.1.1", - "mpromise": "0.4.3", - "mquery": "1.10.0", - "ms": "0.1.0", - "muri": "1.1.0", - "regexp-clone": "0.0.1", - "sliced": "0.0.5" - } - }, - "ms": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.1.0.tgz", - "integrity": "sha1-8h+sSQ2vHXZn/RgP6QdzicyUQrI=" - }, - "nan": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz", - "integrity": "sha1-PHa1OC6rM+RLdY0oE8qdkuk0LzQ=" - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - } - } - }, "encodeurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", @@ -6261,14 +6187,6 @@ "jade": "1.11.0" } }, - "grunt-i18nlint": { - "version": "github:jwarby/grunt-i18nlint#6b398f775c8ca881a16f45a3cb94c5b79ee11e20", - "dev": true, - "requires": { - "chalk": "1.1.3", - "i18n-lint": "git://github.com/jwarby/i18n-lint.git#0a06373c0d880047ad680239c103d60ed414efc1" - } - }, "grunt-karma": { "version": "0.12.2", "resolved": "https://registry.npmjs.org/grunt-karma/-/grunt-karma-0.12.2.tgz", @@ -6695,11 +6613,6 @@ "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=" }, - "hooks": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/hooks/-/hooks-0.2.1.tgz", - "integrity": "sha1-D1kbGzRL3LPfWXc/Yvu6+Fv0Aos=" - }, "hooks-fixed": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-1.1.0.tgz", @@ -6854,6 +6767,11 @@ "sshpk": "1.13.1" } }, + "https": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz", + "integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q=" + }, "https-proxy-agent": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz", @@ -6889,48 +6807,6 @@ "sprintf-js": "1.1.1" } }, - "i18n-lint": { - "version": "git://github.com/jwarby/i18n-lint.git#0a06373c0d880047ad680239c103d60ed414efc1", - "dev": true, - "requires": { - "chalk": "1.1.3", - "commander": "2.8.1", - "glob": "5.0.15", - "htmlparser2": "3.8.3", - "lodash": "3.10.1", - "node.extend": "1.1.6" - }, - "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - } - } - }, "iconv-lite": { "version": "0.2.11", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", @@ -7115,12 +6991,6 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.0.5.tgz", "integrity": "sha1-X6eM8wG4JceKvDBC2BJyMEnqI8c=" }, - "is": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/is/-/is-3.2.1.tgz", - "integrity": "sha1-0Kwq1V63sL7JJqUmb2xmKqqD3KU=", - "dev": true - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -7935,23 +7805,6 @@ "phantomjs-prebuilt": "2.1.15" } }, - "kerberos": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/kerberos/-/kerberos-0.0.11.tgz", - "integrity": "sha1-yymJHCHCKsGV8xQLl90SIE/qfcI=", - "optional": true, - "requires": { - "nan": "1.8.4" - }, - "dependencies": { - "nan": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/nan/-/nan-1.8.4.tgz", - "integrity": "sha1-PHa1OC6rM+RLdY0oE8qdkuk0LzQ=", - "optional": true - } - } - }, "kew": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", @@ -9022,42 +8875,6 @@ "resolved": "https://registry.npmjs.org/mout/-/mout-1.1.0.tgz", "integrity": "sha512-XsP0vf4As6BfqglxZqbqQ8SR6KQot2AgxvR0gG+WtUkf90vUXchMOZQtPf/Hml1rEffJupqL/tIrU6EYhsUQjw==" }, - "mpath": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.1.1.tgz", - "integrity": "sha1-I9qFK3wjLuCX9HWdKcDunNItXkY=" - }, - "mpromise": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.4.3.tgz", - "integrity": "sha1-7cR6daKhd7DpOCc121Lb7DgIzDM=" - }, - "mquery": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/mquery/-/mquery-1.10.0.tgz", - "integrity": "sha1-hgPwKwtSTResBTmoWZYSTuF7fLM=", - "requires": { - "bluebird": "2.10.2", - "debug": "2.2.0", - "regexp-clone": "0.0.1", - "sliced": "0.0.5" - }, - "dependencies": { - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "requires": { - "ms": "0.7.1" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" - } - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -9230,15 +9047,6 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-2.0.0.tgz", "integrity": "sha1-ICtIAhoMTL3i34DeFaF0Q8i0OYA=" }, - "node.extend": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/node.extend/-/node.extend-1.1.6.tgz", - "integrity": "sha1-p7iCyC1sk6SGOlUEvV3o7IYli5Y=", - "dev": true, - "requires": { - "is": "3.2.1" - } - }, "nodemailer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.0.1.tgz", @@ -10749,11 +10557,6 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" }, - "rand-token": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/rand-token/-/rand-token-0.2.1.tgz", - "integrity": "sha1-3GfIEjMGyRInstw/W+pz0wE3YiY=" - }, "random-js": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/random-js/-/random-js-1.0.8.tgz", @@ -11370,11 +11173,6 @@ "resolved": "https://registry.npmjs.org/simple-is/-/simple-is-0.2.0.tgz", "integrity": "sha1-Krt1qt453rXMgVzhDmGRFkhQuvA=" }, - "sliced": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", - "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8=" - }, "smart-buffer": { "version": "1.1.15", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz", diff --git a/package.json b/package.json index 63c6aa5a..9b3b4e17 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "grunt-html2js": "~0.3.5", "grunt-ng-annotate": "~1.0.1", "helmet": "3.5.0", + "https": "^1.0.0", "i18n": "^0.8.3", "jit-grunt": "^0.9.1", "lodash": "^4.17.4", diff --git a/server.js b/server.js index 78aeefa6..d2b091ad 100755 --- a/server.js +++ b/server.js @@ -1,7 +1,10 @@ + 'use strict'; /** * Module dependencies. */ +var fs = require('fs') +var https = require('https') require('dotenv').config({path: './.env'}); @@ -9,6 +12,9 @@ if(!process.env.NODE_ENV){ process.env.NODE_ENV = 'development'; } +var pkey = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/privkey.pem') +var cert = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/fullchain.pem') + require('events').EventEmitter.prototype._maxListeners = 0; @@ -35,7 +41,7 @@ mongoose.connection.on('error', function (err) { }); const smtpTransport = nodemailer.createTransport(config.mailer.options); - +console.log("GOT PAST MONGOOSE") // verify connection configuration on startup smtpTransport.verify(function(error, success) { if (error) { @@ -61,10 +67,16 @@ if (process.env.CREATE_ADMIN_ACCOUNT === 'TRUE') { // Bootstrap passport config require('./config/passport')(); - +console.log("Got past passport!") // Start the app by listening on -app.listen(config.port); +app.listen(80, () => console.log("Listening")); +console.log("Got past Listen1") +//https.createServer({key: pkey, cert: cert}, app).listen(config.port, () => { +// console.log('Listening on 443') +//}) + +console.log("GOT PAST LISTEN"); // Expose app exports = module.exports = app; diff --git a/test.js b/test.js new file mode 100644 index 00000000..10251638 --- /dev/null +++ b/test.js @@ -0,0 +1,11 @@ +var fs = require('fs') +var pkey = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/privkey.pem') +var cert = fs.readFileSync('/etc/letsencrypt/live/register.earlybird.camp/fullchain.pem') + +var express = require('express') +var app = express() +app.get('/', (q, s) => s.send('hello')) +app.listen(80) + +var https = require('https') +https.createServer({key: pkey, cert: cert}, app).listen(443)