Skip to content

Commit

Permalink
Merge pull request #14 from jniles/patches-update-dependencies
Browse files Browse the repository at this point in the history
Update license, dependencies, and environmental variable loading
  • Loading branch information
sfount committed Jan 19, 2016
2 parents f7dcbdf + d354e01 commit 00d9c50
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 196 deletions.
27 changes: 27 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# Server Config
PORT=8080
HTTPS=1

# database configuration
DB_HOST='localhost'
DB_USER='YOUR_USERNAME'
DB_PASS='YOUR_PASSWORD'
DB_NAME='bhima'

# session variables
SESS_SECRET='XopEn BlowFISH'
SESS_RESAVE=0
SESS_SAVE_UNINITIALIZED=0
SESS_REAP_INTERVAL=-1
SESS_UNSET='destroy'

# log level
LOG_LEVEL='none'

# uploads
UPLOAD_FOLDER='client/upload'

# SSL/TLS config
TLS_KEY='server/config/keys/server.key'
TLS_CERT='server/config/keys/server.crt'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# ignore npm/node modules
node_modules/
.npm-debug.log
npm-debug.log

# ignore bower installation target
client/vendor/
Expand All @@ -25,3 +26,6 @@ bin/*
# ignore the upload folder
client/src/upload/

# ignore configuration
.env.production
.env.development
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ node_js:
- "0.10"

before_script:
- npm install -g gulp bower
- npm install -g gulp bower mocha
- bower install
- mysql -u root -e "CREATE DATABASE bhima;"
- mysql -u root -e "CREATE USER 'bhima'@'localhost' IDENTIFIED BY 'HISCongo2013';"
Expand All @@ -22,5 +22,10 @@ cache:
- node_modules/
- client/vendor

# set the clone depth to a low value
git:
depth: 3

# make sure we aren't caching verbose output from NPM
before_cache:
- rm -f npm-debug.log
2 changes: 1 addition & 1 deletion client/src/partials/patients/search/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

/*FIXME*/
.hack-left {
margin-left: -15px; !important
margin-left: -15px !important;
}
2 changes: 1 addition & 1 deletion client/src/partials/receipts/receipts.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.invoiceTable {
border none;
border: none;
width: 100%;
}

Expand Down
33 changes: 9 additions & 24 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var gulp = require('gulp'),
gulpif = require('gulp-if'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
minifycss = require('gulp-minify-css'),
cssnano = require('gulp-cssnano'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint'),
flatten = require('gulp-flatten'),
spawn = require('child_process').spawn,
Expand Down Expand Up @@ -61,7 +62,7 @@ var paths = {
},
server : {
javascript : ['server/*.js', 'server/**/*.js'],
files : ['server/*', 'server/**/*'],
files : ['server/*', 'server/**/*', '.env.*'],
plugins : ['plugins/*', 'plugins/**/*'],
unittest : []
}
Expand All @@ -76,7 +77,7 @@ var paths = {
* and writes them to the /bin/client/ folder. There are tasks to do
* the following:
* - [client-lint-js] lint the client javascript code (via jshint)
* - [client-minify-css] minify (via minify css) the css
* - [client-minify-css] minify (via css nano) the css
* - [client-minify-js] minify (via uglify) the clientside js code
* - [client-lint-i18n] compares translation files for missing values
* - [client-mv-static] moves the static files (html, img) to the client
Expand All @@ -89,11 +90,6 @@ var paths = {
* - [client-watch] watch the client/src/ for changes and run the build
*/

// removes files with del, and continues
gulp.task('client-clean', function (cb) {
rimraf(CLIENT_FOLDER, cb);
});

// run jshint on the client javascript code
gulp.task('client-lint-js', function () {
return gulp.src(paths.client.javascript.concat(paths.client.excludeLint))
Expand All @@ -115,7 +111,7 @@ gulp.task('client-minify-js', function () {
// writes output to style.min.css
gulp.task('client-minify-css', function () {
return gulp.src(paths.client.css)
.pipe(minifycss())
.pipe(cssnano())
.pipe(concat('style.min.css'))
.pipe(gulp.dest(CLIENT_FOLDER + 'css/'));
});
Expand Down Expand Up @@ -197,13 +193,13 @@ gulp.task('notify-lint-process', function () {
});

// builds the client with all the options available
gulp.task('build-client', ['client-clean'], function () {
gulp.task('build-client', function () {
gulp.start('client-minify-js', 'client-minify-css', 'client-mv-vendor', 'client-vendor-build-slickgrid', 'client-vendor-build-bootstrap', 'client-mv-static', 'notify-lint-process');
});

// Lint client code seperately from build process
// TODO Processes for linting server code - requires uncategorised commit update
gulp.task('lint', ['client-clean'], function () {
gulp.task('lint', function () {
gulp.start('client-lint-js', 'client-lint-i18n');
});

Expand All @@ -224,12 +220,6 @@ gulp.task('lint', ['client-clean'], function () {
* To run all of the above, run the gulp task `gulp build-server`.
*/

gulp.task('server-clean', function (cb) {
rimraf(SERVER_FOLDER, function () {
rimraf(PLUGIN_FOLDER, cb);
});
});

// run jshint on all server javascript files
gulp.task('server-lint-js', function () {
return gulp.src(paths.server.javascript)
Expand Down Expand Up @@ -281,18 +271,13 @@ gulp.task('client-test-e2e', function () {
* The following tasks will run unit tests on the bhima server using gulp-mocha
*/

// ensure that the server actually runs
gulp.task('server-test-run', function () {
spawn('node', [path.join(SERVER_FOLDER, 'app.js')], {stdio: 'inherit'});
});

/* -------------------------------------------------------------------------- */

gulp.task('clean', function (cb) {
rimraf('./bin/', cb);
});

gulp.task('build', function () {
gulp.task('build', ['clean'], function () {
gulp.start('build-client', 'build-server');
});

Expand All @@ -301,6 +286,6 @@ gulp.task('test', ['build'], function () {
});

// run the build-client and build-server tasks when no arguments
gulp.task('default', [], function () {
gulp.task('default', ['clean'], function () {
gulp.start('build-client', 'build-server');
});
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"main": "server/app.js",
"scripts": {
"test": "./sh/travis.sh",
"app": "gulp build && cd bin && node server/app.js",
"dev": "gulp build && cd bin && node server/app.js development"
"app": "gulp build && cd bin && NODE_ENV=production node server/app.js",
"dev": "gulp build && cd bin && NODE_ENV=development node server/app.js",
"start": "gulp build && cd bin && NODE_ENV=production node server/app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/IMA-WorldHealth/bhima.git"
"url": "https://github.com/IMA-WorldHealth/bhima-2.X.git"
},
"keywords": [
"bhima",
Expand All @@ -19,26 +20,25 @@
"hospital information system",
"rural accounting"
],
"author": "IMA World Health Web Development Team",
"license": "GPLv2",
"author": "IMA World Health",
"license": "GPL-2.0",
"bugs": {
"url": "https://github.com/IMA-WorldHealth/bhima/issues"
},
"dependencies": {
"body-parser": "^1.14.1",
"compression": "^1.5.2",
"connect-multiparty": "^2.0.0",
"csv": "^0.4.1",
"dot": "^1.0.3",
"dotenv": "^1.2.0",
"express": "^4.13.3",
"express-session": "^1.11.3",
"fast-csv": "^0.6.0",
"later": "^1.2.0",
"fast-csv": "1.0.0",
"morgan": "^1.6.1",
"mysql": "^2.9.0",
"numeral": "^1.5.3",
"q": "~1.4.1",
"session-file-store": "0.0.22",
"session-file-store": "0.0.24",
"wkhtmltopdf": "^0.1.5"
},
"devDependencies": {
Expand All @@ -47,12 +47,12 @@
"chai-http": "^1.0.0",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.0",
"gulp-flatten": "^0.2.0",
"gulp-if": "^2.0.0",
"gulp-iife": "^0.2.4",
"gulp-jshint": "^2.0.0",
"gulp-less": "^3.0.3",
"gulp-minify-css": "^1.2.1",
"gulp-mocha": "^2.1.3",
"gulp-protractor": "^2.1.0",
"gulp-uglify": "^1.4.2",
Expand Down
28 changes: 16 additions & 12 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ var express = require('express'),
https = require('https'),
fs = require('fs');

// Temporary switch between production and development
// TODO -- in the future, this should be done via environmental
// variablesk
var MODE = (process.argv[2]) ? process.argv[2] : 'production';
var config = require('./config/environment/' + MODE);
process.env.NODE_ENV = MODE; // allow other modules to check the environment
// switch for environmental variables
var env = (process.env.NODE_ENV === 'production') ?
'server/.env.production' :
'server/.env.development';

// load the environmnetal variables into process
require('dotenv').config({ path : env });

// SSL credentials
var privateKey = fs.readFileSync(config.tls.key, 'utf8');
var certificate = fs.readFileSync(config.tls.cert, 'utf8');
var privateKey = fs.readFileSync(process.env.TLS_KEY, 'utf8');
var certificate = fs.readFileSync(process.env.TLS_CERT, 'utf8');
var credentials = { key : privateKey, cert : certificate };
var db = require('./lib/db').initialise(config.db);

// configure the database for use within the application
require('./lib/db').initialise();

var app = express();

Expand All @@ -27,15 +30,16 @@ require('./config/routes').configure(app);
require('./config/express').errorHandling(app);

// Load and configure plugins
require('./lib/pluginManager')(app, config.plugins);
// TODO - find a better way to load in a list of plugins
require('./lib/pluginManager')(app, []);

// start the server
https.createServer(credentials, app).listen(config.port, logApplicationStart);
https.createServer(credentials, app).listen(process.env.PORT, logApplicationStart);

process.on('uncaughtException', forceExit);

function logApplicationStart() {
console.log('[app] BHIMA server started in mode %s on port %s.', MODE.toUpperCase(), config.port);
console.log('[app] BHIMA server started in mode %s on port %s.', process.env.NODE_ENV.toUpperCase(), process.env.PORT);
}

function forceExit(err) {
Expand Down
32 changes: 0 additions & 32 deletions server/config/environment/development.js

This file was deleted.

34 changes: 0 additions & 34 deletions server/config/environment/production.js

This file was deleted.

Loading

0 comments on commit 00d9c50

Please sign in to comment.