1
0
mirror of https://github.com/Foltik/Shimapan synced 2025-01-05 15:58:03 -05:00

Add different env configs

This commit is contained in:
Jack 2017-10-12 17:26:35 -04:00
parent e01051f97f
commit 25d28720dd
Signed by: foltik
GPG Key ID: 303F88F996E95541
9 changed files with 56 additions and 29 deletions

3
config/default.json Normal file
View File

@ -0,0 +1,3 @@
{
"dbHost": "mongodb://localhost/shimapan"
}

3
config/dev.json Normal file
View File

@ -0,0 +1,3 @@
{
"dbHost": "mongodb://localhost/shimapan"
}

3
config/test.json Normal file
View File

@ -0,0 +1,3 @@
{
"dbHost": "mongodb://localhost/shimapan-test"
}

13
gulpfile.js Normal file
View File

@ -0,0 +1,13 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var jsFiles = 'public/js/**/*.js',
jsDest = 'public/libs/app';
gulp.task('concat', function() {
return gulp.src(jsFiles)
.pipe(concat('app.js'))
.pipe(gulp.dest(jsDest));
});

View File

@ -6,13 +6,14 @@
"angular-ui-router": "^0.4.3",
"async": "^2.5.0",
"body-parser": "^1.18.2",
"express": "latest",
"config": "^1.26.2",
"express": "^4.16.2",
"express-jwt": "^5.3.0",
"gulp": "latest",
"jsonwebtoken": "^8.1.0",
"jwt-sign": "^0.1.0",
"method-override": "latest",
"mongoose": "latest",
"mongoose": "^4.12.1",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"ng-file-upload": "^12.2.13",
"passport": "^0.4.0",
@ -20,7 +21,16 @@
},
"description": "A simple file sharing website.",
"main": "index.js",
"devDependencies": {},
"devDependencies": {
"chai": "^4.1.2",
"chai-http": "^3.0.0",
"gulp": "latest",
"gulp-concat": "^2.6.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^3.0.0",
"mocha": "^4.0.1",
"nyc": "^11.2.1"
},
"author": "Jack Foltz",
"license": "WTFPL",
"scripts": {

View File

@ -14,11 +14,8 @@
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script>
<script src="/libs/ngclipboard/src/ngclipboard.js"></script>
<script src="/js/components/UploadComp.js"></script>
<script src="/js/components/RegisterComp.js"></script>
<script src="/js/components/LoginComp.js"></script>
<script src="/js/services/AuthSvc.js"></script>
<script src="/js/shimapan.js"></script>
<script src="/libs/app/app.js"></script>
</head>
<body ng-app="shimapan">
<div id="container">

View File

@ -12,8 +12,7 @@
<script src="/libs/angular/angular.min.js"></script>
<script src="/libs/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="/js/PanelRoutes.js"></script>
<script src="/js/shimapan-panel.js"></script>
<script src="/libs/app/app.js"></script>
</head>
<body ng-app="shimapan-panel">
<div id="container" ui-view></div>

View File

@ -10,11 +10,7 @@
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script>
<script src="/libs/ngclipboard/src/ngclipboard.js"></script>
<script src="/js/components/UploadComp.js"></script>
<script src="/js/components/RegisterComp.js"></script>
<script src="/js/components/LoginComp.js"></script>
<script src="/js/services/AuthSvc.js"></script>
<script src="/js/shimapan.js"></script>
<script src="/libs/app/app.js"></script>
</head>
<body ng-app="shimapan">
<div id="container">

View File

@ -2,30 +2,31 @@ var express = require('express');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var mongoose = require('mongoose');
var morgan = require('morgan');
var passport = require('passport');
var app = express();
mongoose.connect('mongodb://localhost/shimapan', {useMongoClient: true});
var config = require('config');
if(config.util.getEnv('NODE_ENV') !== 'test') {
app.use(morgan('combined'));
}
mongoose.Promise = global.Promise;
mongoose.connect(config.dbHost, {useMongoClient: true});
var db = mongoose.connection;
db.on('error', function(err) {
if (err)
console.log('MongoDB Connection Error: ', err);
else
console.log('MongoDB Connection Established');
});
db.once('open', function() {
console.log('MongoDB Connection Open')
if (err) console.log('MongoDB Connection Error: ', err);
});
require('./config/passport.js');
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
app.use(bodyParser.json({ type: 'application/json' }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(passport.initialize());
app.use(bodyParser.text());
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(passport.initialize());
// Set /public to document root
app.use(express.static(__dirname + '/public'));
@ -33,8 +34,10 @@ require('./app/routes')(app);
// Start app
var port = process.env.PORT || 8080;
app.listen(port);
var server = app.listen(port);
console.log('Listening on port ', port, '...');
// Expose app
exports = module.exports = app;
exports.db = db;
exports.server = server;
exports.app = app;