Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update basic packages and testing packages #20

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ node_modules
# Ignore everything in the data/hl7-uploads folder for now
data/hl7-uploads/*
!data/hl7-uploads/.gitkeep

# No need to commit code coverage reports
.nyc_output
11 changes: 11 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"nyc": {
"all": true,
"include": [
"server/**/*.js"
],
"exclude": [
"**/*.test.js"
]
}
}
2 changes: 1 addition & 1 deletion config/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const debug = require('debug')('hl7-telescoper-api-server:index');

// connect to mongo db
const mongoUri = config.mongo.host;
mongoose.connect(mongoUri, { keepAlive: 1, useNewUrlParser: true });
mongoose.connect(mongoUri, { keepAlive: 1, useNewUrlParser: true, useUnifiedTopology: true });
mongoose.connection.on('error', () => {
throw new Error(`unable to connect to database: ${mongoUri}`);
});
Expand Down
30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "5.0.0",
"description": "A server side application for the Amida HL7-Telescoper Project",
"author": "Perry Ogwuche <[email protected]>",
"contributors": [
"Alan Thompson <[email protected]>",
"Grant Orndorff <[email protected]>",
"James Zhu <[email protected]>"
],
"main": "index.js",
"private": false,
"engines": {
Expand All @@ -20,8 +25,8 @@
"pretest": "cross-env NODE_ENV=test yarn drop-database",
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors server --recursive",
"test:watch": "yarn test -- --watch",
"test:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/istanbul cover _mocha -- --ui bdd --reporter spec --colors server --recursive",
"test:check-coverage": "yarn test:coverage && istanbul check-coverage",
"test:coverage": "yarn pretest && cross-env NODE_ENV=test nyc ./node_modules/.bin/mocha --ui bdd --reporter spec --colors server --recursive",
"test:check-coverage": "yarn test:coverage && nyc check-coverage",
"report-coverage": "coveralls < ./coverage/lcov.info"
},
"repository": {
Expand All @@ -48,39 +53,40 @@
"compression": "1.7.2",
"cookie-parser": "1.4.3",
"cors": "2.8.4",
"debug": "^2.4.5",
"dotenv": "^4.0.0",
"express": "4.16.3",
"express-jwt": "5.3.1",
"express-validation": "1.0.2",
"express-validation": "1.0.3",
"express-winston": "2.5.0",
"health-level-seven-parser": "1.2.2",
"helmet": "3.12.0",
"http-status": "1.0.1",
"joi": "10.6.0",
"jsonwebtoken": "8.5.1",
"method-override": "^2.3.10",
"mongoose": "5.6.4",
"mongoose": "5.7.9",
"morgan": "1.9.1",
"multer": "1.4.1",
"passport": "0.4.0",
"passport-jwt": "4.0.0",
"winston": "2.4.1"
},
"devDependencies": {
"@istanbuljs/nyc-config-babel": "2.1.1",
"babel-plugin-istanbul": "5.2.0",
"chai": "4.1.2",
"commitizen": "^2.9.6",
"coveralls": "^3.0.0",
"commitizen": "^4.0.3",
"coveralls": "^3.0.7",
"cross-env": "5.1.4",
"cz-conventional-changelog": "1.2.0",
"eslint": "3.16.1",
"eslint": "6.6.0",
"eslint-config-airbnb-base": "7.1.0",
"eslint-plugin-import": "1.16.0",
"eslint-watch": "2.1.14",
"eslint-watch": "6.0.1",
"husky": "0.14.3",
"istanbul": "1.1.0-alpha.1",
"mocha": "3.5.0",
"supertest": "3.0.0",
"mocha": "6.2.2",
"nyc": "14.1.1",
"supertest": "4.0.2",
"supertest-as-promised": "4.0.2",
"validate-commit-msg": "^2.14.0"
},
Expand Down
18 changes: 9 additions & 9 deletions server/hl7/hl7.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ function parseFile(req, res, next) {
rawMessage,
parsedMessage: parseRawHl7(rawMessage),
})
));
));
})
.then(() => res.status(201).send(`Successfully uploaded ${getFileName(req.user.files[0].filename)}`))
.catch(err => next(new APIError(err, httpStatus.INTERNAL_SERVER_ERROR)));
.then(() => res.status(201).send(`Successfully uploaded ${getFileName(req.user.files[0].filename)}`))
.catch(err => next(new APIError(err, httpStatus.INTERNAL_SERVER_ERROR)));
}

/**
Expand Down Expand Up @@ -196,12 +196,12 @@ function _getMessageByIdOrIndex(value, fileId) {
{ fileId }
]
})
.exec((err, message) => {
if (err) {
reject(err);
}
resolve(message);
});
.exec((err, message) => {
if (err) {
reject(err);
}
resolve(message);
});
});
}

Expand Down
16 changes: 16 additions & 0 deletions server/hl7/hl7.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const mongoose = require('mongoose');
const request = require('supertest-as-promised');
const httpStatus = require('http-status');
Expand Down Expand Up @@ -25,6 +27,20 @@ const user = {
};
let userToken = '';
before((done) => {
// Delete the test file if it exists (else subsequent tests will fail)
const jsonPath = path.join(__dirname, '..', '..', 'data', 'hl7-uploads', '500HL7Messages.txt');
try {
if (fs.existsSync(jsonPath)) {
try {
fs.unlinkSync(jsonPath);
} catch (err) {
console.error(err); // eslint-disable-line no-console
}
}
} catch (err) {
console.error(err); // eslint-disable-line no-console
}

// create a user
request(app)
.post('/api/users')
Expand Down
Loading