mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-06 04:01:04 +01:00
Merge branch 'pr/140'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ public/lib
|
||||
app/tests/coverage/
|
||||
.bower-*/
|
||||
.idea/
|
||||
config/sslcert/*.pem
|
||||
|
||||
3
config/env/all.js
vendored
3
config/env/all.js
vendored
@@ -7,6 +7,7 @@ module.exports = {
|
||||
keywords: 'mongodb, express, angularjs, node.js, mongoose, passport'
|
||||
},
|
||||
port: process.env.PORT || 3000,
|
||||
secure: process.env.SECURE || false,
|
||||
templateEngine: 'swig',
|
||||
sessionSecret: 'MEAN',
|
||||
sessionCollection: 'sessions',
|
||||
@@ -39,4 +40,4 @@ module.exports = {
|
||||
'public/modules/*/tests/*.js'
|
||||
]
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
2
config/env/development.js
vendored
2
config/env/development.js
vendored
@@ -40,4 +40,4 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
2
config/env/production.js
vendored
2
config/env/production.js
vendored
@@ -55,4 +55,4 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
60
config/env/secure.js
vendored
Normal file
60
config/env/secure.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
secure: true,
|
||||
port: 443,
|
||||
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean',
|
||||
assets: {
|
||||
lib: {
|
||||
css: [
|
||||
'public/lib/bootstrap/dist/css/bootstrap.min.css',
|
||||
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
|
||||
],
|
||||
js: [
|
||||
'public/lib/angular/angular.min.js',
|
||||
'public/lib/angular-resource/angular-resource.min.js',
|
||||
'public/lib/angular-animate/angular-animate.min.js',
|
||||
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
|
||||
'public/lib/angular-ui-utils/ui-utils.min.js',
|
||||
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js'
|
||||
]
|
||||
},
|
||||
css: 'public/dist/application.min.css',
|
||||
js: 'public/dist/application.min.js'
|
||||
},
|
||||
facebook: {
|
||||
clientID: process.env.FACEBOOK_ID || 'APP_ID',
|
||||
clientSecret: process.env.FACEBOOK_SECRET || 'APP_SECRET',
|
||||
callbackURL: 'https://localhost:443/auth/facebook/callback'
|
||||
},
|
||||
twitter: {
|
||||
clientID: process.env.TWITTER_KEY || 'CONSUMER_KEY',
|
||||
clientSecret: process.env.TWITTER_SECRET || 'CONSUMER_SECRET',
|
||||
callbackURL: 'https://localhost:443/auth/twitter/callback'
|
||||
},
|
||||
google: {
|
||||
clientID: process.env.GOOGLE_ID || 'APP_ID',
|
||||
clientSecret: process.env.GOOGLE_SECRET || 'APP_SECRET',
|
||||
callbackURL: 'https://localhost:443/auth/google/callback'
|
||||
},
|
||||
linkedin: {
|
||||
clientID: process.env.LINKEDIN_ID || 'APP_ID',
|
||||
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
|
||||
callbackURL: 'https://localhost:443/auth/linkedin/callback'
|
||||
},
|
||||
github: {
|
||||
clientID: process.env.GITHUB_ID || 'APP_ID',
|
||||
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
|
||||
callbackURL: 'https://localhost:443/auth/github/callback'
|
||||
},
|
||||
mailer: {
|
||||
from: process.env.MAILER_FROM || 'MAILER_FROM',
|
||||
options: {
|
||||
service: process.env.MAILER_SERVICE_PROVIDER || 'MAILER_SERVICE_PROVIDER',
|
||||
auth: {
|
||||
user: process.env.MAILER_EMAIL_ID || 'MAILER_EMAIL_ID',
|
||||
pass: process.env.MAILER_PASSWORD || 'MAILER_PASSWORD'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3,7 +3,9 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var express = require('express'),
|
||||
var fs = require('fs'),
|
||||
http = require('http'),
|
||||
express = require('express'),
|
||||
morgan = require('morgan'),
|
||||
bodyParser = require('body-parser'),
|
||||
session = require('express-session'),
|
||||
@@ -36,6 +38,7 @@ module.exports = function(db) {
|
||||
app.locals.facebookAppId = config.facebook.clientID;
|
||||
app.locals.jsFiles = config.getJavaScriptAssets();
|
||||
app.locals.cssFiles = config.getCSSAssets();
|
||||
app.locals.secure = config.secure;
|
||||
|
||||
// Passing the request url to environment locals
|
||||
app.use(function(req, res, next) {
|
||||
@@ -137,5 +140,17 @@ module.exports = function(db) {
|
||||
});
|
||||
});
|
||||
|
||||
return app;
|
||||
};
|
||||
if (app.locals.secure) {
|
||||
console.log('Securely using https protocol');
|
||||
var https = require('https'),
|
||||
privateKey = fs.readFileSync('./config/sslcert/key.pem', 'utf8'),
|
||||
certificate = fs.readFileSync('./config/sslcert/cert.pem', 'utf8'),
|
||||
credentials = {key: privateKey, cert: certificate},
|
||||
httpsServer = https.createServer(credentials, app);
|
||||
return httpsServer;
|
||||
} else {
|
||||
console.log('Insecurely using http protocol');
|
||||
var httpServer = http.createServer(app);
|
||||
return httpServer;
|
||||
}
|
||||
};
|
||||
|
||||
7
config/sslcert/gen-certs
Executable file
7
config/sslcert/gen-certs
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo "Generating self-signed certificates..."
|
||||
openssl genrsa -out key.pem -aes256 1024
|
||||
openssl req -new -key key.pem -out csr.pem
|
||||
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
|
||||
rm csr.pem
|
||||
chmod 600 key.pem cert.pem
|
||||
Reference in New Issue
Block a user