From 3693bd5bcf7f0239c3f58b6fcfd9760e8bc30f42 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sat, 8 Jul 2017 16:52:01 +0100 Subject: [PATCH 01/98] set up staging --- package.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..88c4fbb --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "document-manager", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/iakhator/document-manager.git" + }, + "keywords": [], + "author": "iakhator", + "license": "ISC", + "bugs": { + "url": "https://github.com/iakhator/document-manager/issues" + }, + "homepage": "https://github.com/iakhator/document-manager#readme" +} From aa917cc453a528bb36afd7c9f5b702ec47ccd8e5 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sat, 8 Jul 2017 17:05:54 +0100 Subject: [PATCH 02/98] chore(eslint):configure-eslint - ensure directory is properly linting [Finishes #148533841] --- .eslintrc | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..f8aa27a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,109 @@ +{ + "root": true, + "extends": "airbnb-base", + "plugins": [ + "react", + "jsx-a11y", + "import" + ], + "env": { + "node": true, + "es6": true, + "mocha": true, + "jquery": true, + "browser": true + }, + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "allowImportExportEverywhere": true, + "ecmaFeatures": { + "jsx": true + } + }, + "ecmaFeatures": { + "arrowFunctions": true, + "blockBindings": true, + "classes": true, + "defaultParams": true, + "destructuring": true, + "forOf": true, + "generators": false, + "modules": true, + "objectLiteralComputedProperties": true, + "objectLiteralDuplicateProperties": false, + "objectLiteralShorthandMethods": true, + "objectLiteralShorthandProperties": true, + "spread": true, + "superInFunctions": true, + "templateStrings": true + }, + "rules": { + "import/no-unresolved": 0, + "one-var": 0, + "one-var-declaration-per-line": 0, + "new-cap": 0, + "consistent-return": 0, + "no-param-reassign": 0, + "no-restricted-syntax": [2, "WithStatement"], + "comma-dangle": 0, + "curly": [1, "multi-line"], + "no-multi-spaces": [2, { "exceptions": { "ImportDeclaration": true } }], + "no-multi-str": 0, + "import/no-extraneous-dependencies": [ + 2, + { + "devDependencies": true, + "optionalDependencies": false, + "peerDependencies": false + } + ], + "max-len": [2, 80, 2], + "no-shadow": [1, { "allow": ["req", "res", "err"] }], + "require-jsdoc": [0, { + "require": { + "FunctionDeclaration": true, + "MethodDefinition": true, + "ClassDeclaration": true + } + }], + "valid-jsdoc": [1, { + "requireReturn": true, + "requireReturnType": true, + "requireParamDescription": true, + "requireReturnDescription": true + }], + "jsx-quotes": 1, + "react/display-name": [1, { "ignoreTranspilerName": false }], + "react/forbid-prop-types": [1, { "forbid": ["any"] }], + "react/jsx-boolean-value": 1, + "react/jsx-closing-bracket-location": 0, + "react/jsx-curly-spacing": 1, + "react/jsx-indent-props": 0, + "react/jsx-key": 1, + "react/jsx-max-props-per-line": 0, + "react/jsx-no-bind": 1, + "react/jsx-no-duplicate-props": 1, + "react/jsx-no-literals": 0, + "react/jsx-no-undef": 1, + "react/jsx-pascal-case": 1, + "react/jsx-sort-prop-types": 0, + "react/jsx-sort-props": 0, + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1, + "react/no-danger": 1, + "react/no-did-mount-set-state": 1, + "react/no-did-update-set-state": 1, + "react/no-direct-mutation-state": 1, + "react/no-multi-comp": 1, + "react/no-set-state": 0, + "react/no-unknown-property": 1, + "react/prefer-es6-class": 1, + "react/prop-types": 1, + "react/react-in-jsx-scope": 1, + "react/require-extension": 1, + "react/self-closing-comp": 1, + "react/sort-comp": 1, + "react/wrap-multilines": 1 + } +} From 9867473dd19427481b54645faea160a71ace3146 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sat, 8 Jul 2017 17:57:34 +0100 Subject: [PATCH 03/98] chore(base-application):Set up base application - make sure application runs smoothly [Footer #148533999] --- .eslintrc | 103 ++++++---------------------------------- .gitignore | 1 + package.json | 18 ++++++- server/config/server.js | 28 +++++++++++ 4 files changed, 59 insertions(+), 91 deletions(-) create mode 100644 .gitignore create mode 100644 server/config/server.js diff --git a/.eslintrc b/.eslintrc index f8aa27a..716973b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,109 +1,34 @@ { "root": true, "extends": "airbnb-base", - "plugins": [ - "react", - "jsx-a11y", - "import" - ], "env": { - "node": true, - "es6": true, - "mocha": true, - "jquery": true, - "browser": true - }, - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "allowImportExportEverywhere": true, - "ecmaFeatures": { - "jsx": true - } - }, - "ecmaFeatures": { - "arrowFunctions": true, - "blockBindings": true, - "classes": true, - "defaultParams": true, - "destructuring": true, - "forOf": true, - "generators": false, - "modules": true, - "objectLiteralComputedProperties": true, - "objectLiteralDuplicateProperties": false, - "objectLiteralShorthandMethods": true, - "objectLiteralShorthandProperties": true, - "spread": true, - "superInFunctions": true, - "templateStrings": true + "node": true, + "es6": true, + "mocha": true }, "rules": { - "import/no-unresolved": 0, "one-var": 0, "one-var-declaration-per-line": 0, "new-cap": 0, "consistent-return": 0, "no-param-reassign": 0, - "no-restricted-syntax": [2, "WithStatement"], "comma-dangle": 0, - "curly": [1, "multi-line"], - "no-multi-spaces": [2, { "exceptions": { "ImportDeclaration": true } }], - "no-multi-str": 0, - "import/no-extraneous-dependencies": [ - 2, - { - "devDependencies": true, - "optionalDependencies": false, - "peerDependencies": false - } - ], + "curly": ["error", "multi-line"], + "import/no-unresolved": [2, { commonjs: true }], "max-len": [2, 80, 2], - "no-shadow": [1, { "allow": ["req", "res", "err"] }], - "require-jsdoc": [0, { + "no-shadow": ["error", { "allow": ["req", "res", "err"] }], + "valid-jsdoc": ["error", { + "requireReturn": true, + "requireReturnType": true, + "requireParamDescription": false, + "requireReturnDescription": true + }], + "require-jsdoc": ["error", { "require": { "FunctionDeclaration": true, "MethodDefinition": true, "ClassDeclaration": true } - }], - "valid-jsdoc": [1, { - "requireReturn": true, - "requireReturnType": true, - "requireParamDescription": true, - "requireReturnDescription": true - }], - "jsx-quotes": 1, - "react/display-name": [1, { "ignoreTranspilerName": false }], - "react/forbid-prop-types": [1, { "forbid": ["any"] }], - "react/jsx-boolean-value": 1, - "react/jsx-closing-bracket-location": 0, - "react/jsx-curly-spacing": 1, - "react/jsx-indent-props": 0, - "react/jsx-key": 1, - "react/jsx-max-props-per-line": 0, - "react/jsx-no-bind": 1, - "react/jsx-no-duplicate-props": 1, - "react/jsx-no-literals": 0, - "react/jsx-no-undef": 1, - "react/jsx-pascal-case": 1, - "react/jsx-sort-prop-types": 0, - "react/jsx-sort-props": 0, - "react/jsx-uses-react": 1, - "react/jsx-uses-vars": 1, - "react/no-danger": 1, - "react/no-did-mount-set-state": 1, - "react/no-did-update-set-state": 1, - "react/no-direct-mutation-state": 1, - "react/no-multi-comp": 1, - "react/no-set-state": 0, - "react/no-unknown-property": 1, - "react/prefer-es6-class": 1, - "react/prop-types": 1, - "react/react-in-jsx-scope": 1, - "react/require-extension": 1, - "react/self-closing-comp": 1, - "react/sort-comp": 1, - "react/wrap-multilines": 1 + }] } } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/package.json b/package.json index 88c4fbb..033c8f6 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,9 @@ "name": "document-manager", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "server/config/server.js", "scripts": { + "start:dev": "nodemon ./server/config/server", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -16,5 +17,18 @@ "bugs": { "url": "https://github.com/iakhator/document-manager/issues" }, - "homepage": "https://github.com/iakhator/document-manager#readme" + "homepage": "https://github.com/iakhator/document-manager#readme", + "dependencies": { + "body-parser": "^1.17.2", + "eslint": "^4.1.1", + "eslint-config-airbnb": "^15.0.2", + "eslint-plugin-import": "^2.7.0", + "express": "^4.15.3", + "morgan": "^1.8.2" + }, + "devDependencies": { + "eslint": "^4.1.1", + "eslint-config-airbnb": "^15.0.2", + "eslint-plugin-import": "^2.7.0" + } } diff --git a/server/config/server.js b/server/config/server.js new file mode 100644 index 0000000..4f20c19 --- /dev/null +++ b/server/config/server.js @@ -0,0 +1,28 @@ +const http = require('http'); +const bodyParser = require('body-parser'); +const express = require('express'); +const logger = require('morgan'); + +// Set up the express app +const app = express(); + +// Log requests to the console. +app.use(logger('dev')); + +// Parse incoming requests data (https://github.com/expressjs/body-parser) +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: false })); + +// Setup a default catch-all route that sends +// back a welcome message in JSON format. +app.get('*', (req, res) => res.status(200).send({ + message: 'Welcome to the beginning of nothingness.', +})); + +const port = parseInt(process.env.PORT, 10) || 8000; +app.set('port', port); + +const server = http.createServer(app); +server.listen(port); + +module.exports = app; From 5407410bdf9646f0837df5b90250fe513ce2bcfe Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 9 Jul 2017 06:56:43 +0100 Subject: [PATCH 04/98] chore(base-application):Set up base application - make sure application runs smoothly [Footer #148533999] --- .babelrc | 5 +++++ server/config/server.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..3c078e9 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "es2015" + ] +} diff --git a/server/config/server.js b/server/config/server.js index 4f20c19..6b5985b 100644 --- a/server/config/server.js +++ b/server/config/server.js @@ -1,6 +1,6 @@ const http = require('http'); -const bodyParser = require('body-parser'); const express = require('express'); +const bodyParser = require('body-parser'); const logger = require('morgan'); // Set up the express app From 04251bd4c3d7de16f7c15b5da21c42d552b7c321 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 9 Jul 2017 12:36:52 +0100 Subject: [PATCH 05/98] chore(sequelize): setup sequelize -ensure sequelize is configure properly [Finishes #14854220] --- .eslintrc | 2 +- .sequelizerc | 8 ++++++++ package.json | 13 ++++++++++--- server/config/config.json | 25 ++++++++++++++++++++++++ server/models/index.js | 41 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 .sequelizerc create mode 100644 server/config/config.json create mode 100644 server/models/index.js diff --git a/.eslintrc b/.eslintrc index 716973b..3158207 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,7 +14,7 @@ "no-param-reassign": 0, "comma-dangle": 0, "curly": ["error", "multi-line"], - "import/no-unresolved": [2, { commonjs: true }], + "import/no-unresolved": [0, { commonjs: true, amd: true }], "max-len": [2, 80, 2], "no-shadow": ["error", { "allow": ["req", "res", "err"] }], "valid-jsdoc": ["error", { diff --git a/.sequelizerc b/.sequelizerc new file mode 100644 index 0000000..e6029e9 --- /dev/null +++ b/.sequelizerc @@ -0,0 +1,8 @@ +const path = require('path'); + +module.exports = { + "config": path.resolve('./server/config', 'config.json'), + "models-path": path.resolve('./server/models'), + "seeders-path": path.resolve('./server/seeders'), + "migrations-path": path.resolve('./server/migrations') +}; diff --git a/package.json b/package.json index 033c8f6..50c389a 100644 --- a/package.json +++ b/package.json @@ -19,15 +19,22 @@ }, "homepage": "https://github.com/iakhator/document-manager#readme", "dependencies": { + "babel": "^6.23.0", + "babel-cli": "^6.24.1", + "babel-preset-es2015": "^6.24.1", "body-parser": "^1.17.2", - "eslint": "^4.1.1", + "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", "express": "^4.15.3", - "morgan": "^1.8.2" + "morgan": "^1.8.2", + "pg": "^6.4.0", + "pg-hstore": "^2.3.2", + "sequelize": "^4.2.1", + "sequelize-cli": "^2.7.0" }, "devDependencies": { - "eslint": "^4.1.1", + "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0" } diff --git a/server/config/config.json b/server/config/config.json new file mode 100644 index 0000000..3e3cec2 --- /dev/null +++ b/server/config/config.json @@ -0,0 +1,25 @@ +{ + "development": { + "username": "andeladeveloper", + "password": null, + "database": "docmanager-dev", + "host": "127.0.0.1", + "port": 5432, + "dialect": "postgres" + }, + "test": { + "username": "andeladeveloper", + "password": null, + "database": "docmanager-test", + "host": "127.0.0.1", + "port": 5432, + "dialect": "postgres" + }, + "production": { + "username": "root", + "password": null, + "database": "database_production", + "host": "127.0.0.1", + "dialect": "postgres" + } +} diff --git a/server/models/index.js b/server/models/index.js new file mode 100644 index 0000000..681f700 --- /dev/null +++ b/server/models/index.js @@ -0,0 +1,41 @@ + +const fs = require('fs'); +const path = require('path'); +const Sequelize = require('sequelize'); + +const basename = path.basename(module.filename); +const env = process.env.NODE_ENV || 'development'; +const config = require('../config/config.json')[env]; + +const db = {}; + +let sequelize; +if (config.use_env_variable) { + sequelize = new Sequelize(process.env[config.use_env_variable]); +} else { + sequelize = new Sequelize( + config.database, config.username, config.password, config + ); +} + +fs + .readdirSync(__dirname) + .filter(file => ( + file.indexOf('.') !== 0) && + (file !== basename) && + (file.slice(-3) === '.js' + )).forEach((file) => { + const model = sequelize.import(path.join(__dirname, file)); + db[model.name] = model; + }); + +Object.keys(db).forEach((modelName) => { + if (db[modelName].associate) { + db[modelName].associate(db); + } +}); + +db.sequelize = sequelize; +db.Sequelize = Sequelize; + +module.exports = db; From 9826695fae787b439d12120b2a4b07236789015b Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 09:09:06 +0100 Subject: [PATCH 06/98] feat(schema): database-schema -ensure schemas are linked successfully [Finishes #148544303] --- .DS_Store | Bin 0 -> 8196 bytes .../migrations/20170709115254-create-user.js | 49 ++++++++++++++++++ .../migrations/20170709115813-create-role.js | 24 +++++++++ .../20170709120158-create-document.js | 40 ++++++++++++++ server/models/document.js | 32 ++++++++++++ server/models/role.js | 20 +++++++ server/models/user.js | 44 ++++++++++++++++ 7 files changed, 209 insertions(+) create mode 100644 .DS_Store create mode 100644 server/migrations/20170709115254-create-user.js create mode 100644 server/migrations/20170709115813-create-role.js create mode 100644 server/migrations/20170709120158-create-document.js create mode 100644 server/models/document.js create mode 100644 server/models/role.js create mode 100644 server/models/user.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5a9e87e94ab6e6c0c737395121a6e0bb408a8e8e GIT binary patch literal 8196 zcmeHM-A)rh6g~q8t$-|l0?~_&#DoN5Xe6L9gi;{dpi(J82w>T^Ls{9*G`m|6u%mKr8SsD1c|SD4`nX zzPhWeRzNH8Un(Hp4<=TD(E!T|<*NgYOaTxZuvr%LF%OU&Gr(woWrdQ8eX8t%1XL2F z7(~(WzA3^HqXCu`DmoBF2NH}-f((Vo(UE7$a3E2I+G+)~0w)y^xqBmIzyTX*RsJrv z(k-k5KV^~RCb$c6n1UI&4@sD*$o56_+p6dm?2$tjdrm=KdPN+Gf_I!pdVZIe-th{- z*M*Pif@6FB@bD*6SKn~1u_+V|hr+F)wd5w>N&1#w^kSB~BCqT$O$Yu0=gy&Tr5A0w zlQO!dIP)!=QMV#|^`XtOd?&_>EbGaB5|+P-Tsct6=-uCsjNTYBBR5A&L+1Y2*zk}! za(%Q^3Wa*EM#kgo`Q5$!r=@4Fq;NojHy5<2>qGk*y_!PVneAY~1_xAN&N*SGLE3=hz#pI{B!`+xuq$@es&L#_1#%8%CpFZ)E z_8v_c9aW+8H2dhNX<@g3FP8n@p#^sKa;GXT>)%`##T$NYPt{vxG}U zPfIrXVlDj>-;}KV(b)rMKsg5VD+hn@8f1ZSM#JI$Xd-9~!5~b+Jy?V-*n=1F2LG1d z!w2{bU*QL7B7Niv86+cQoJ^2ABu-{Yf;=Geid}c`XfGcOp^&T~)_k*7q*2x z9xM0z%ZmMOB3H~V8emzWTre7W3M16?eG6*X-RsnS^=%V zA1Xi^rjye#B*|0#6tXzwO|0u!MGLTtgJKLkh_ Lw9yLuRRw+lZ{8^L literal 0 HcmV?d00001 diff --git a/server/migrations/20170709115254-create-user.js b/server/migrations/20170709115254-create-user.js new file mode 100644 index 0000000..ae5277e --- /dev/null +++ b/server/migrations/20170709115254-create-user.js @@ -0,0 +1,49 @@ + +module.exports = { + up: (queryInterface, Sequelize) => queryInterface.createTable('User', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + fullName: { + type: Sequelize.STRING, + allowNull: false + }, + userName: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + email: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + validate: { isEmail: true } + }, + password: { + type: Sequelize.STRING, + allowNull: false + }, + roleId: { + type: Sequelize.INTEGER, + references: { + model: 'Role', + key: 'id', + as: 'roleId' + }, + allowNull: false, + defaultValue: 2 + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('User') +}; diff --git a/server/migrations/20170709115813-create-role.js b/server/migrations/20170709115813-create-role.js new file mode 100644 index 0000000..e53b5a9 --- /dev/null +++ b/server/migrations/20170709115813-create-role.js @@ -0,0 +1,24 @@ +module.exports = { + up: (queryInterface, Sequelize) => queryInterface.createTable('Role', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('Role') +}; diff --git a/server/migrations/20170709120158-create-document.js b/server/migrations/20170709120158-create-document.js new file mode 100644 index 0000000..d56dbd6 --- /dev/null +++ b/server/migrations/20170709120158-create-document.js @@ -0,0 +1,40 @@ +module.exports = { + up: (queryInterface, Sequelize) => queryInterface.createTable('Document', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false + }, + content: { + type: Sequelize.STRING, + allowNull: false + }, + access: { + type: Sequelize.ENUM('public', 'private', 'role'), + defaultValue: 'public', + allowNull: false + }, + userId: { + type: Sequelize.INTEGER, + references: { + model: 'User', + key: 'id', + as: 'userId', + } + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + }, + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('Document') +}; diff --git a/server/models/document.js b/server/models/document.js new file mode 100644 index 0000000..95cc63d --- /dev/null +++ b/server/models/document.js @@ -0,0 +1,32 @@ + +module.exports = (sequelize, DataTypes) => { + const Document = sequelize.define('Document', { + title: { + type: DataTypes.STRING, + allowNull: false + }, + content: { + type: DataTypes.TEXT, + allowNull: false + }, + userId: { + type: DataTypes.INTEGER, + unique: true, + allowNull: false + }, + access: { + type: DataTypes.ENUM, + values: ['public', 'private', 'role'] + } + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId', + }); + } + } + }); + return Document; +}; diff --git a/server/models/role.js b/server/models/role.js new file mode 100644 index 0000000..c7501d6 --- /dev/null +++ b/server/models/role.js @@ -0,0 +1,20 @@ + +module.exports = (sequelize, DataTypes) => { + const Role = sequelize.define('Role', { + title: { + type: DataTypes.STRING, + allowNull: false, + unique: true + }, + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + } + } + }); + return Role; +}; diff --git a/server/models/user.js b/server/models/user.js new file mode 100644 index 0000000..e3ab160 --- /dev/null +++ b/server/models/user.js @@ -0,0 +1,44 @@ + +module.exports = (sequelize, DataTypes) => { + const User = sequelize.define('User', { + fullName: { + type: DataTypes.STRING, + allowNull: false, + }, + userName: { + type: DataTypes.STRING, + allowNull: false, + unique: true + }, + email: { + type: DataTypes.STRING, + allowNull: false, + unique: true + }, + + password: { + type: DataTypes.STRING, + allowNull: false + }, + roleId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultvalue: 2 + }, + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId' + }); + } + } + }); + return User; +}; From 81bcde2052c968c052d23955b9461c6d905c3986 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 10:52:42 +0100 Subject: [PATCH 07/98] chore(gulp):set-up-gulp -ensure gulp runs the server without errors [Finishes #149215875] --- server/config/express.js | 15 +++ server/config/server.js | 28 ------ .../migrations/20170709115254-create-user.js | 97 ++++++++++--------- .../migrations/20170709115813-create-role.js | 52 +++++----- .../20170709120158-create-document.js | 82 ++++++++-------- server/models/document.js | 11 ++- server/models/index.js | 43 ++++---- server/models/role.js | 11 ++- server/models/user.js | 11 ++- server/routes/index.js | 12 +++ 10 files changed, 188 insertions(+), 174 deletions(-) create mode 100644 server/config/express.js delete mode 100644 server/config/server.js create mode 100644 server/routes/index.js diff --git a/server/config/express.js b/server/config/express.js new file mode 100644 index 0000000..d8f723b --- /dev/null +++ b/server/config/express.js @@ -0,0 +1,15 @@ +import express from 'express'; +import bodyParser from 'body-parser'; +import routes from '../routes'; + + +const app = express(); + +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: true })); + +// mount all routes on /api path +app.use('/api/v1', routes); + + +export default app; diff --git a/server/config/server.js b/server/config/server.js deleted file mode 100644 index 6b5985b..0000000 --- a/server/config/server.js +++ /dev/null @@ -1,28 +0,0 @@ -const http = require('http'); -const express = require('express'); -const bodyParser = require('body-parser'); -const logger = require('morgan'); - -// Set up the express app -const app = express(); - -// Log requests to the console. -app.use(logger('dev')); - -// Parse incoming requests data (https://github.com/expressjs/body-parser) -app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: false })); - -// Setup a default catch-all route that sends -// back a welcome message in JSON format. -app.get('*', (req, res) => res.status(200).send({ - message: 'Welcome to the beginning of nothingness.', -})); - -const port = parseInt(process.env.PORT, 10) || 8000; -app.set('port', port); - -const server = http.createServer(app); -server.listen(port); - -module.exports = app; diff --git a/server/migrations/20170709115254-create-user.js b/server/migrations/20170709115254-create-user.js index ae5277e..5e73383 100644 --- a/server/migrations/20170709115254-create-user.js +++ b/server/migrations/20170709115254-create-user.js @@ -1,49 +1,54 @@ +'use strict'; module.exports = { - up: (queryInterface, Sequelize) => queryInterface.createTable('User', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - fullName: { - type: Sequelize.STRING, - allowNull: false - }, - userName: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - email: { - type: Sequelize.STRING, - allowNull: false, - unique: true, - validate: { isEmail: true } - }, - password: { - type: Sequelize.STRING, - allowNull: false - }, - roleId: { - type: Sequelize.INTEGER, - references: { - model: 'Role', - key: 'id', - as: 'roleId' + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('User', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER }, - allowNull: false, - defaultValue: 2 - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }), - down: (queryInterface, Sequelize) => queryInterface.dropTable('User') -}; + fullName: { + type: Sequelize.STRING, + allowNull: false + }, + userName: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + email: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + validate: { isEmail: true } + }, + password: { + type: Sequelize.STRING, + allowNull: false + }, + roleId: { + type: Sequelize.INTEGER, + references: { + model: 'Role', + key: 'id', + as: 'roleId' + }, + allowNull: false, + defaultValue: 2 + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('User'); + } +}; \ No newline at end of file diff --git a/server/migrations/20170709115813-create-role.js b/server/migrations/20170709115813-create-role.js index e53b5a9..cf5ece8 100644 --- a/server/migrations/20170709115813-create-role.js +++ b/server/migrations/20170709115813-create-role.js @@ -1,24 +1,30 @@ +'use strict'; + module.exports = { - up: (queryInterface, Sequelize) => queryInterface.createTable('Role', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }), - down: (queryInterface, Sequelize) => queryInterface.dropTable('Role') -}; + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('Role', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('Role'); + } +}; \ No newline at end of file diff --git a/server/migrations/20170709120158-create-document.js b/server/migrations/20170709120158-create-document.js index d56dbd6..90412a3 100644 --- a/server/migrations/20170709120158-create-document.js +++ b/server/migrations/20170709120158-create-document.js @@ -1,40 +1,46 @@ +'use strict'; + module.exports = { - up: (queryInterface, Sequelize) => queryInterface.createTable('Document', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false - }, - content: { - type: Sequelize.STRING, - allowNull: false - }, - access: { - type: Sequelize.ENUM('public', 'private', 'role'), - defaultValue: 'public', - allowNull: false - }, - userId: { - type: Sequelize.INTEGER, - references: { - model: 'User', - key: 'id', - as: 'userId', + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('Document', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false + }, + content: { + type: Sequelize.STRING, + allowNull: false + }, + access: { + type: Sequelize.ENUM('public', 'private', 'role'), + defaultValue: 'public', + allowNull: false + }, + userId: { + type: Sequelize.INTEGER, + references: { + model: 'User', + key: 'id', + as: 'userId' + } + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE } - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - }, - }), - down: (queryInterface, Sequelize) => queryInterface.dropTable('Document') -}; + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('Document'); + } +}; \ No newline at end of file diff --git a/server/models/document.js b/server/models/document.js index 95cc63d..edd6894 100644 --- a/server/models/document.js +++ b/server/models/document.js @@ -1,6 +1,7 @@ +'use strict'; -module.exports = (sequelize, DataTypes) => { - const Document = sequelize.define('Document', { +module.exports = function (sequelize, DataTypes) { + var Document = sequelize.define('Document', { title: { type: DataTypes.STRING, allowNull: false @@ -20,13 +21,13 @@ module.exports = (sequelize, DataTypes) => { } }, { classMethods: { - associate: (models) => { + associate: function associate(models) { // associations can be defined here Document.belongsTo(models.User, { - foreignKey: 'userId', + foreignKey: 'userId' }); } } }); return Document; -}; +}; \ No newline at end of file diff --git a/server/models/index.js b/server/models/index.js index 681f700..ad2e0e2 100644 --- a/server/models/index.js +++ b/server/models/index.js @@ -1,35 +1,30 @@ +'use strict'; -const fs = require('fs'); -const path = require('path'); -const Sequelize = require('sequelize'); +var fs = require('fs'); +var path = require('path'); +var Sequelize = require('sequelize'); -const basename = path.basename(module.filename); -const env = process.env.NODE_ENV || 'development'; -const config = require('../config/config.json')[env]; +var basename = path.basename(module.filename); +var env = process.env.NODE_ENV || 'development'; +var config = require('../config/config.json')[env]; -const db = {}; +var db = {}; -let sequelize; +var sequelize = void 0; if (config.use_env_variable) { sequelize = new Sequelize(process.env[config.use_env_variable]); } else { - sequelize = new Sequelize( - config.database, config.username, config.password, config - ); + sequelize = new Sequelize(config.database, config.username, config.password, config); } -fs - .readdirSync(__dirname) - .filter(file => ( - file.indexOf('.') !== 0) && - (file !== basename) && - (file.slice(-3) === '.js' - )).forEach((file) => { - const model = sequelize.import(path.join(__dirname, file)); - db[model.name] = model; - }); - -Object.keys(db).forEach((modelName) => { +fs.readdirSync(__dirname).filter(function (file) { + return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'; +}).forEach(function (file) { + var model = sequelize.import(path.join(__dirname, file)); + db[model.name] = model; +}); + +Object.keys(db).forEach(function (modelName) { if (db[modelName].associate) { db[modelName].associate(db); } @@ -38,4 +33,4 @@ Object.keys(db).forEach((modelName) => { db.sequelize = sequelize; db.Sequelize = Sequelize; -module.exports = db; +module.exports = db; \ No newline at end of file diff --git a/server/models/role.js b/server/models/role.js index c7501d6..96e14a0 100644 --- a/server/models/role.js +++ b/server/models/role.js @@ -1,14 +1,15 @@ +'use strict'; -module.exports = (sequelize, DataTypes) => { - const Role = sequelize.define('Role', { +module.exports = function (sequelize, DataTypes) { + var Role = sequelize.define('Role', { title: { type: DataTypes.STRING, allowNull: false, unique: true - }, + } }, { classMethods: { - associate: (models) => { + associate: function associate(models) { // associations can be defined here Role.hasMany(models.User, { foreignKey: 'roleId' @@ -17,4 +18,4 @@ module.exports = (sequelize, DataTypes) => { } }); return Role; -}; +}; \ No newline at end of file diff --git a/server/models/user.js b/server/models/user.js index e3ab160..9120654 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,9 +1,10 @@ +'use strict'; -module.exports = (sequelize, DataTypes) => { - const User = sequelize.define('User', { +module.exports = function (sequelize, DataTypes) { + var User = sequelize.define('User', { fullName: { type: DataTypes.STRING, - allowNull: false, + allowNull: false }, userName: { type: DataTypes.STRING, @@ -24,10 +25,10 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.INTEGER, allowNull: false, defaultvalue: 2 - }, + } }, { classMethods: { - associate: (models) => { + associate: function associate(models) { // associations can be defined here User.hasMany(models.Document, { foreignKey: 'userId', diff --git a/server/routes/index.js b/server/routes/index.js new file mode 100644 index 0000000..5095a91 --- /dev/null +++ b/server/routes/index.js @@ -0,0 +1,12 @@ +import express from 'express'; + +const router = express.Router(); + +/** GET /api-status - Check service status **/ +router.get('/api-status', (req, res) => + res.json({ + status: 'ok' + }) +); + +export default router; From d1f979c12c15cfb4bd12ac9c9991db797149c8ee Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 11:14:11 +0100 Subject: [PATCH 08/98] feat(game screen): redesign game screen - make sure user see an exciting gaming screen [Finishes #146622705] --- dist/gulpfile.babel.js | 37 +++++++++++++ dist/index.js | 11 ++++ dist/server/config/express.js | 29 ++++++++++ .../migrations/20170709115254-create-user.js | 54 +++++++++++++++++++ .../migrations/20170709115813-create-role.js | 30 +++++++++++ .../20170709120158-create-document.js | 46 ++++++++++++++++ dist/server/models/document.js | 33 ++++++++++++ dist/server/models/index.js | 36 +++++++++++++ dist/server/models/role.js | 21 ++++++++ dist/server/models/user.js | 45 ++++++++++++++++ dist/server/routes/index.js | 22 ++++++++ gulpfile.babel.js | 28 ++++++++++ index.js | 5 ++ 13 files changed, 397 insertions(+) create mode 100644 dist/gulpfile.babel.js create mode 100644 dist/index.js create mode 100644 dist/server/config/express.js create mode 100644 dist/server/migrations/20170709115254-create-user.js create mode 100644 dist/server/migrations/20170709115813-create-role.js create mode 100644 dist/server/migrations/20170709120158-create-document.js create mode 100644 dist/server/models/document.js create mode 100644 dist/server/models/index.js create mode 100644 dist/server/models/role.js create mode 100644 dist/server/models/user.js create mode 100644 dist/server/routes/index.js create mode 100644 gulpfile.babel.js create mode 100644 index.js diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js new file mode 100644 index 0000000..54be548 --- /dev/null +++ b/dist/gulpfile.babel.js @@ -0,0 +1,37 @@ +'use strict'; + +var _gulp = require('gulp'); + +var _gulp2 = _interopRequireDefault(_gulp); + +var _gulpLoadPlugins = require('gulp-load-plugins'); + +var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); + +var _path = require('path'); + +var _path2 = _interopRequireDefault(_path); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Load the gulp plugins into the `plugins` variable +var plugins = (0, _gulpLoadPlugins2.default)(); + +var paths = { + js: ['./**/*.js', '!dist/**', '!node_modules/**'] +}; + +// Compile all Babel Javascript into ES5 and put it into the dist dir +_gulp2.default.task('babel', function () { + return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); +}); + +// Start server with restart on file change events +_gulp2.default.task('nodemon', ['babel'], function () { + return plugins.nodemon({ + script: _path2.default.join('dist', 'index.js'), + ext: 'js', + ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'], + tasks: ['babel'] + }); +}); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..296b68a --- /dev/null +++ b/dist/index.js @@ -0,0 +1,11 @@ +'use strict'; + +var _express = require('./server/config/express'); + +var _express2 = _interopRequireDefault(_express); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_express2.default.listen(3000, function () { + console.log('API Server started and listening on port 3000'); +}); \ No newline at end of file diff --git a/dist/server/config/express.js b/dist/server/config/express.js new file mode 100644 index 0000000..018f554 --- /dev/null +++ b/dist/server/config/express.js @@ -0,0 +1,29 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _bodyParser = require('body-parser'); + +var _bodyParser2 = _interopRequireDefault(_bodyParser); + +var _routes = require('../routes'); + +var _routes2 = _interopRequireDefault(_routes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var app = (0, _express2.default)(); + +app.use(_bodyParser2.default.json()); +app.use(_bodyParser2.default.urlencoded({ extended: true })); + +// mount all routes on /api path +app.use('/api/v1', _routes2.default); + +exports.default = app; \ No newline at end of file diff --git a/dist/server/migrations/20170709115254-create-user.js b/dist/server/migrations/20170709115254-create-user.js new file mode 100644 index 0000000..5e73383 --- /dev/null +++ b/dist/server/migrations/20170709115254-create-user.js @@ -0,0 +1,54 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('User', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + fullName: { + type: Sequelize.STRING, + allowNull: false + }, + userName: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + email: { + type: Sequelize.STRING, + allowNull: false, + unique: true, + validate: { isEmail: true } + }, + password: { + type: Sequelize.STRING, + allowNull: false + }, + roleId: { + type: Sequelize.INTEGER, + references: { + model: 'Role', + key: 'id', + as: 'roleId' + }, + allowNull: false, + defaultValue: 2 + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('User'); + } +}; \ No newline at end of file diff --git a/dist/server/migrations/20170709115813-create-role.js b/dist/server/migrations/20170709115813-create-role.js new file mode 100644 index 0000000..cf5ece8 --- /dev/null +++ b/dist/server/migrations/20170709115813-create-role.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('Role', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('Role'); + } +}; \ No newline at end of file diff --git a/dist/server/migrations/20170709120158-create-document.js b/dist/server/migrations/20170709120158-create-document.js new file mode 100644 index 0000000..90412a3 --- /dev/null +++ b/dist/server/migrations/20170709120158-create-document.js @@ -0,0 +1,46 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('Document', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false + }, + content: { + type: Sequelize.STRING, + allowNull: false + }, + access: { + type: Sequelize.ENUM('public', 'private', 'role'), + defaultValue: 'public', + allowNull: false + }, + userId: { + type: Sequelize.INTEGER, + references: { + model: 'User', + key: 'id', + as: 'userId' + } + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('Document'); + } +}; \ No newline at end of file diff --git a/dist/server/models/document.js b/dist/server/models/document.js new file mode 100644 index 0000000..edd6894 --- /dev/null +++ b/dist/server/models/document.js @@ -0,0 +1,33 @@ +'use strict'; + +module.exports = function (sequelize, DataTypes) { + var Document = sequelize.define('Document', { + title: { + type: DataTypes.STRING, + allowNull: false + }, + content: { + type: DataTypes.TEXT, + allowNull: false + }, + userId: { + type: DataTypes.INTEGER, + unique: true, + allowNull: false + }, + access: { + type: DataTypes.ENUM, + values: ['public', 'private', 'role'] + } + }, { + classMethods: { + associate: function associate(models) { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + } + } + }); + return Document; +}; \ No newline at end of file diff --git a/dist/server/models/index.js b/dist/server/models/index.js new file mode 100644 index 0000000..ad2e0e2 --- /dev/null +++ b/dist/server/models/index.js @@ -0,0 +1,36 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); +var Sequelize = require('sequelize'); + +var basename = path.basename(module.filename); +var env = process.env.NODE_ENV || 'development'; +var config = require('../config/config.json')[env]; + +var db = {}; + +var sequelize = void 0; +if (config.use_env_variable) { + sequelize = new Sequelize(process.env[config.use_env_variable]); +} else { + sequelize = new Sequelize(config.database, config.username, config.password, config); +} + +fs.readdirSync(__dirname).filter(function (file) { + return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'; +}).forEach(function (file) { + var model = sequelize.import(path.join(__dirname, file)); + db[model.name] = model; +}); + +Object.keys(db).forEach(function (modelName) { + if (db[modelName].associate) { + db[modelName].associate(db); + } +}); + +db.sequelize = sequelize; +db.Sequelize = Sequelize; + +module.exports = db; \ No newline at end of file diff --git a/dist/server/models/role.js b/dist/server/models/role.js new file mode 100644 index 0000000..96e14a0 --- /dev/null +++ b/dist/server/models/role.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = function (sequelize, DataTypes) { + var Role = sequelize.define('Role', { + title: { + type: DataTypes.STRING, + allowNull: false, + unique: true + } + }, { + classMethods: { + associate: function associate(models) { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + } + } + }); + return Role; +}; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js new file mode 100644 index 0000000..f173d4d --- /dev/null +++ b/dist/server/models/user.js @@ -0,0 +1,45 @@ +'use strict'; + +module.exports = function (sequelize, DataTypes) { + var User = sequelize.define('User', { + fullName: { + type: DataTypes.STRING, + allowNull: false + }, + userName: { + type: DataTypes.STRING, + allowNull: false, + unique: true + }, + email: { + type: DataTypes.STRING, + allowNull: false, + unique: true + }, + + password: { + type: DataTypes.STRING, + allowNull: false + }, + roleId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultvalue: 2 + } + }, { + classMethods: { + associate: function associate(models) { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId' + }); + } + } + }); + return User; +}; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js new file mode 100644 index 0000000..3825652 --- /dev/null +++ b/dist/server/routes/index.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +/** GET /api-status - Check service status **/ +router.get('/api-status', function (req, res) { + return res.json({ + status: 'ok' + }); +}); + +exports.default = router; \ No newline at end of file diff --git a/gulpfile.babel.js b/gulpfile.babel.js new file mode 100644 index 0000000..d9bc8cd --- /dev/null +++ b/gulpfile.babel.js @@ -0,0 +1,28 @@ +import gulp from 'gulp'; + +import loadPlugins from 'gulp-load-plugins'; +import path from 'path'; + +// Load the gulp plugins into the `plugins` variable +const plugins = loadPlugins(); + +const paths = { + js: ['./**/*.js', '!dist/**', '!node_modules/**'] +}; + +// Compile all Babel Javascript into ES5 and put it into the dist dir +gulp.task('babel', () => + gulp.src(paths.js, { base: '.' }) + .pipe(plugins.babel()) + .pipe(gulp.dest('dist')) +); + +// Start server with restart on file change events +gulp.task('nodemon', ['babel'], () => + plugins.nodemon({ + script: path.join('dist', 'index.js'), + ext: 'js', + ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'], + tasks: ['babel'] + }) +); diff --git a/index.js b/index.js new file mode 100644 index 0000000..9d28716 --- /dev/null +++ b/index.js @@ -0,0 +1,5 @@ +import app from './server/config/express'; + +app.listen(3000, () => { + console.log('API Server started and listening on port 3000'); +}); From bdf1b28bf75fd02d533316cbc502f12b48965d2f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 11:26:01 +0100 Subject: [PATCH 09/98] chores(hound):integrate-houndci - ensures hound is set up to follow code style guide [Finishes #149221199] --- .DS_Store | Bin 8196 -> 6148 bytes .Hound.yml | 3 +++ package.json | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .Hound.yml diff --git a/.DS_Store b/.DS_Store index 5a9e87e94ab6e6c0c737395121a6e0bb408a8e8e..6637985c70e81a5e9a263a0d6bf04196e54aa2d8 100644 GIT binary patch delta 121 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50C<+o_1dI7G1T(mL=Hw?Qzzrl^LAo~ kToT+s30IJPKr_EHPv#f#ob1oT!2z@qw0nTkBZ2$lO diff --git a/.Hound.yml b/.Hound.yml new file mode 100644 index 0000000..3be1f25 --- /dev/null +++ b/.Hound.yml @@ -0,0 +1,3 @@ +eslint: + enabled: true + config_file: .eslintrc diff --git a/package.json b/package.json index 50c389a..08c1f01 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "document-manager", "version": "1.0.0", "description": "", - "main": "server/config/server.js", + "main": "server/index.js", "scripts": { - "start:dev": "nodemon ./server/config/server", + "start:dev": "nodemon ./server/index", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -27,6 +27,10 @@ "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", "express": "^4.15.3", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-load-plugins": "^1.5.0", + "gulp-nodemon": "^2.2.1", "morgan": "^1.8.2", "pg": "^6.4.0", "pg-hstore": "^2.3.2", @@ -34,8 +38,14 @@ "sequelize-cli": "^2.7.0" }, "devDependencies": { + "babel-core": "^6.25.0", + "babel-preset-es2015": "^6.24.1", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", - "eslint-plugin-import": "^2.7.0" + "eslint-plugin-import": "^2.7.0", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-load-plugins": "^1.5.0", + "gulp-nodemon": "^2.2.1" } } From 7219d502b8af0a5fd98afae4ed6edfbd63389a70 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 12:03:52 +0100 Subject: [PATCH 10/98] chore(routes):setup-routes - ensures api endpoints are reachable [Finishes #149221719] ' --- .eslintignore | 2 ++ .gitignore | 1 + dist/server/controllers/users.js | 14 ++++++++++++++ dist/server/routes/index.js | 10 +++++----- dist/server/routes/users.js | 26 ++++++++++++++++++++++++++ server/controllers/users.js | 9 +++++++++ server/routes/index.js | 8 +++----- server/routes/users.js | 14 ++++++++++++++ 8 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 .eslintignore create mode 100644 dist/server/controllers/users.js create mode 100644 dist/server/routes/users.js create mode 100644 server/controllers/users.js create mode 100644 server/routes/users.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/.gitignore b/.gitignore index c2658d7..2752eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +.DS_Store diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js new file mode 100644 index 0000000..45e01de --- /dev/null +++ b/dist/server/controllers/users.js @@ -0,0 +1,14 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +function get(req, res) { + return res.json({ ok: 'none' }); +} + +function create(req, res) { + return res.json({ create: 'yes' }); +} + +exports.default = { get: get, create: create }; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index 3825652..36a32d2 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -8,15 +8,15 @@ var _express = require('express'); var _express2 = _interopRequireDefault(_express); +var _users = require('./users'); + +var _users2 = _interopRequireDefault(_users); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); /** GET /api-status - Check service status **/ -router.get('/api-status', function (req, res) { - return res.json({ - status: 'ok' - }); -}); +router.use('/users', _users2.default); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js new file mode 100644 index 0000000..1dbc49b --- /dev/null +++ b/dist/server/routes/users.js @@ -0,0 +1,26 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _users = require('../controllers/users'); + +var _users2 = _interopRequireDefault(_users); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +router.route('/') +/** GET /api/users - Get list of users */ +.get(_users2.default.get) + +/** POST /api/users - Get list of users */ +.post(_users2.default.create); + +exports.default = router; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js new file mode 100644 index 0000000..028c355 --- /dev/null +++ b/server/controllers/users.js @@ -0,0 +1,9 @@ +function get(req, res) { + return res.json({ ok: 'none' }); +} + +function create(req, res) { + return res.json({ create: 'yes' }); +} + +export default { get, create }; diff --git a/server/routes/index.js b/server/routes/index.js index 5095a91..849678a 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -1,12 +1,10 @@ import express from 'express'; +import userRoutes from './users'; + const router = express.Router(); /** GET /api-status - Check service status **/ -router.get('/api-status', (req, res) => - res.json({ - status: 'ok' - }) -); +router.use('/users', userRoutes); export default router; diff --git a/server/routes/users.js b/server/routes/users.js new file mode 100644 index 0000000..6a98828 --- /dev/null +++ b/server/routes/users.js @@ -0,0 +1,14 @@ +import express from 'express'; +import userController from '../controllers/users'; + +const router = express.Router(); + +router.route('/') + /** GET /api/users - Get list of users */ + .get(userController.get) + + /** POST /api/users - Get list of users */ + .post(userController.create); + + +export default router; From 857d8a16ec4876c5801d10e4561f3d24279b46c5 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 20 Jul 2017 16:18:10 +0100 Subject: [PATCH 11/98] fix schema --- server/config/express.js | 3 ++ .../migrations/20170709115254-create-user.js | 24 ++------- .../migrations/20170709115813-create-role.js | 15 ++---- .../20170709120158-create-document.js | 17 +++---- server/models/document.js | 22 ++++----- server/models/index.js | 49 +++++++++++-------- server/models/role.js | 22 ++++----- server/models/user.js | 30 +++++------- 8 files changed, 79 insertions(+), 103 deletions(-) diff --git a/server/config/express.js b/server/config/express.js index d8f723b..49b1337 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -1,10 +1,13 @@ import express from 'express'; import bodyParser from 'body-parser'; +import logger from 'morgan'; import routes from '../routes'; const app = express(); +app.use(logger('dev')); + app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); diff --git a/server/migrations/20170709115254-create-user.js b/server/migrations/20170709115254-create-user.js index 5e73383..4746168 100644 --- a/server/migrations/20170709115254-create-user.js +++ b/server/migrations/20170709115254-create-user.js @@ -1,8 +1,7 @@ -'use strict'; module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('User', { + up: (queryInterface, Sequelize) => + queryInterface.createTable('Users', { id: { allowNull: false, autoIncrement: true, @@ -28,16 +27,6 @@ module.exports = { type: Sequelize.STRING, allowNull: false }, - roleId: { - type: Sequelize.INTEGER, - references: { - model: 'Role', - key: 'id', - as: 'roleId' - }, - allowNull: false, - defaultValue: 2 - }, createdAt: { allowNull: false, type: Sequelize.DATE @@ -46,9 +35,6 @@ module.exports = { allowNull: false, type: Sequelize.DATE } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('User'); - } -}; \ No newline at end of file + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('Users') +}; diff --git a/server/migrations/20170709115813-create-role.js b/server/migrations/20170709115813-create-role.js index cf5ece8..d23ab66 100644 --- a/server/migrations/20170709115813-create-role.js +++ b/server/migrations/20170709115813-create-role.js @@ -1,8 +1,6 @@ -'use strict'; - module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Role', { + up: (queryInterface, Sequelize) => + queryInterface.createTable('Roles', { id: { allowNull: false, autoIncrement: true, @@ -22,9 +20,6 @@ module.exports = { allowNull: false, type: Sequelize.DATE } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Role'); - } -}; \ No newline at end of file + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('Roles') +}; diff --git a/server/migrations/20170709120158-create-document.js b/server/migrations/20170709120158-create-document.js index 90412a3..5e3df18 100644 --- a/server/migrations/20170709120158-create-document.js +++ b/server/migrations/20170709120158-create-document.js @@ -1,8 +1,6 @@ -'use strict'; - module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Document', { + up: (queryInterface, Sequelize) => + queryInterface.createTable('Documents', { id: { allowNull: false, autoIncrement: true, @@ -25,7 +23,7 @@ module.exports = { userId: { type: Sequelize.INTEGER, references: { - model: 'User', + model: 'Users', key: 'id', as: 'userId' } @@ -38,9 +36,6 @@ module.exports = { allowNull: false, type: Sequelize.DATE } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Document'); - } -}; \ No newline at end of file + }), + down: (queryInterface, Sequelize) => queryInterface.dropTable('Documents') +}; diff --git a/server/models/document.js b/server/models/document.js index edd6894..eac8ffd 100644 --- a/server/models/document.js +++ b/server/models/document.js @@ -1,7 +1,6 @@ -'use strict'; -module.exports = function (sequelize, DataTypes) { - var Document = sequelize.define('Document', { +module.exports = (sequelize, DataTypes) => { + const Document = sequelize.define('Document', { title: { type: DataTypes.STRING, allowNull: false @@ -19,15 +18,12 @@ module.exports = function (sequelize, DataTypes) { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - } - } }); + Document.associate = (models) => { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + }; return Document; -}; \ No newline at end of file +}; diff --git a/server/models/index.js b/server/models/index.js index ad2e0e2..ed98624 100644 --- a/server/models/index.js +++ b/server/models/index.js @@ -1,30 +1,34 @@ -'use strict'; +const fs = require('fs'); +const path = require('path'); +const Sequelize = require('sequelize'); -var fs = require('fs'); -var path = require('path'); -var Sequelize = require('sequelize'); +const basename = path.basename(module.filename); +const env = process.env.NODE_ENV || 'development'; +const config = require('../config/config.json')[env]; -var basename = path.basename(module.filename); -var env = process.env.NODE_ENV || 'development'; -var config = require('../config/config.json')[env]; +const db = {}; -var db = {}; - -var sequelize = void 0; +let sequelize; if (config.use_env_variable) { sequelize = new Sequelize(process.env[config.use_env_variable]); } else { - sequelize = new Sequelize(config.database, config.username, config.password, config); + sequelize = new Sequelize( + config.database, config.username, config.password, config + ); } -fs.readdirSync(__dirname).filter(function (file) { - return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'; -}).forEach(function (file) { - var model = sequelize.import(path.join(__dirname, file)); - db[model.name] = model; -}); - -Object.keys(db).forEach(function (modelName) { +fs + .readdirSync(__dirname) + .filter(file => + (file.indexOf('.') !== 0) && + (file !== basename) && + (file.slice(-3) === '.js')) + .forEach((file) => { + const model = sequelize.import(path.join(__dirname, file)); + db[model.name] = model; + }); + +Object.keys(db).forEach((modelName) => { if (db[modelName].associate) { db[modelName].associate(db); } @@ -33,4 +37,9 @@ Object.keys(db).forEach(function (modelName) { db.sequelize = sequelize; db.Sequelize = Sequelize; -module.exports = db; \ No newline at end of file +module.exports = db; + +db.sequelize = sequelize; +db.Sequelize = Sequelize; + +module.exports = db; diff --git a/server/models/role.js b/server/models/role.js index 96e14a0..a81a8fe 100644 --- a/server/models/role.js +++ b/server/models/role.js @@ -1,21 +1,17 @@ -'use strict'; -module.exports = function (sequelize, DataTypes) { - var Role = sequelize.define('Role', { +module.exports = (sequelize, DataTypes) => { + const Role = sequelize.define('Role', { title: { type: DataTypes.STRING, allowNull: false, unique: true } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - } - } }); + Role.associate = (models) => { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + }; return Role; -}; \ No newline at end of file +}; diff --git a/server/models/user.js b/server/models/user.js index 9120654..a8c4bfe 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,7 +1,6 @@ -'use strict'; -module.exports = function (sequelize, DataTypes) { - var User = sequelize.define('User', { +module.exports = (sequelize, DataTypes) => { + const User = sequelize.define('User', { fullName: { type: DataTypes.STRING, allowNull: false @@ -26,20 +25,17 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, defaultvalue: 2 } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId' - }); - } - } }); + User.associate = (models) => { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId' + }); + }; return User; }; From fc68193f9a4145ad6ad933568873b54d1e06ebd7 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 21 Jul 2017 11:32:20 +0100 Subject: [PATCH 12/98] setting up model --- dist/gulpfile.babel.js | 4 ++- dist/server/config/express.js | 6 ++++ dist/server/controllers/users.js | 11 +++++-- .../migrations/20170709115213-create-role.js | 30 +++++++++++++++++++ .../migrations/20170709115254-create-user.js | 6 ++-- .../migrations/20170709115813-create-role.js | 4 +-- .../20170709120158-create-document.js | 6 ++-- dist/server/models/index.js | 5 ++++ dist/server/models/user.js | 1 - gulpfile.babel.js | 2 ++ package.json | 4 ++- server/controllers/users.js | 4 ++- ...-role.js => 20170709115213-create-role.js} | 0 .../migrations/20170709115254-create-user.js | 10 +++++++ server/models/document.js | 15 ++++++---- server/models/role.js | 15 ++++++---- server/models/user.js | 26 ++++++++-------- 17 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 dist/server/migrations/20170709115213-create-role.js rename server/migrations/{20170709115813-create-role.js => 20170709115213-create-role.js} (100%) diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index 54be548..210b328 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -34,4 +34,6 @@ _gulp2.default.task('nodemon', ['babel'], function () { ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'], tasks: ['babel'] }); -}); \ No newline at end of file +}); + +_gulp2.default.task('default', ['nodemon']); \ No newline at end of file diff --git a/dist/server/config/express.js b/dist/server/config/express.js index 018f554..8ee0f7a 100644 --- a/dist/server/config/express.js +++ b/dist/server/config/express.js @@ -12,6 +12,10 @@ var _bodyParser = require('body-parser'); var _bodyParser2 = _interopRequireDefault(_bodyParser); +var _morgan = require('morgan'); + +var _morgan2 = _interopRequireDefault(_morgan); + var _routes = require('../routes'); var _routes2 = _interopRequireDefault(_routes); @@ -20,6 +24,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var app = (0, _express2.default)(); +app.use((0, _morgan2.default)('dev')); + app.use(_bodyParser2.default.json()); app.use(_bodyParser2.default.urlencoded({ extended: true })); diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 45e01de..5913ebc 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + function get(req, res) { return res.json({ ok: 'none' }); } -function create(req, res) { - return res.json({ create: 'yes' }); -} +function create(req, res) {} exports.default = { get: get, create: create }; \ No newline at end of file diff --git a/dist/server/migrations/20170709115213-create-role.js b/dist/server/migrations/20170709115213-create-role.js new file mode 100644 index 0000000..faafbd0 --- /dev/null +++ b/dist/server/migrations/20170709115213-create-role.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface, Sequelize) { + return queryInterface.createTable('Roles', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + title: { + type: Sequelize.STRING, + allowNull: false, + unique: true + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: function down(queryInterface, Sequelize) { + return queryInterface.dropTable('Roles'); + } +}; \ No newline at end of file diff --git a/dist/server/migrations/20170709115254-create-user.js b/dist/server/migrations/20170709115254-create-user.js index 5e73383..51491fa 100644 --- a/dist/server/migrations/20170709115254-create-user.js +++ b/dist/server/migrations/20170709115254-create-user.js @@ -2,7 +2,7 @@ module.exports = { up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('User', { + return queryInterface.createTable('Users', { id: { allowNull: false, autoIncrement: true, @@ -31,7 +31,7 @@ module.exports = { roleId: { type: Sequelize.INTEGER, references: { - model: 'Role', + model: 'Roles', key: 'id', as: 'roleId' }, @@ -49,6 +49,6 @@ module.exports = { }); }, down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('User'); + return queryInterface.dropTable('Users'); } }; \ No newline at end of file diff --git a/dist/server/migrations/20170709115813-create-role.js b/dist/server/migrations/20170709115813-create-role.js index cf5ece8..faafbd0 100644 --- a/dist/server/migrations/20170709115813-create-role.js +++ b/dist/server/migrations/20170709115813-create-role.js @@ -2,7 +2,7 @@ module.exports = { up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Role', { + return queryInterface.createTable('Roles', { id: { allowNull: false, autoIncrement: true, @@ -25,6 +25,6 @@ module.exports = { }); }, down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Role'); + return queryInterface.dropTable('Roles'); } }; \ No newline at end of file diff --git a/dist/server/migrations/20170709120158-create-document.js b/dist/server/migrations/20170709120158-create-document.js index 90412a3..9c83e45 100644 --- a/dist/server/migrations/20170709120158-create-document.js +++ b/dist/server/migrations/20170709120158-create-document.js @@ -2,7 +2,7 @@ module.exports = { up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Document', { + return queryInterface.createTable('Documents', { id: { allowNull: false, autoIncrement: true, @@ -25,7 +25,7 @@ module.exports = { userId: { type: Sequelize.INTEGER, references: { - model: 'User', + model: 'Users', key: 'id', as: 'userId' } @@ -41,6 +41,6 @@ module.exports = { }); }, down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Document'); + return queryInterface.dropTable('Documents'); } }; \ No newline at end of file diff --git a/dist/server/models/index.js b/dist/server/models/index.js index ad2e0e2..fad1007 100644 --- a/dist/server/models/index.js +++ b/dist/server/models/index.js @@ -33,4 +33,9 @@ Object.keys(db).forEach(function (modelName) { db.sequelize = sequelize; db.Sequelize = Sequelize; +module.exports = db; + +db.sequelize = sequelize; +db.Sequelize = Sequelize; + module.exports = db; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js index f173d4d..4b286b0 100644 --- a/dist/server/models/user.js +++ b/dist/server/models/user.js @@ -16,7 +16,6 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, unique: true }, - password: { type: DataTypes.STRING, allowNull: false diff --git a/gulpfile.babel.js b/gulpfile.babel.js index d9bc8cd..b66ffde 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -26,3 +26,5 @@ gulp.task('nodemon', ['babel'], () => tasks: ['babel'] }) ); + +gulp.task('default', ['nodemon']); diff --git a/package.json b/package.json index 08c1f01..76a9de0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "", "main": "server/index.js", "scripts": { - "start:dev": "nodemon ./server/index", + "start": "node node_modules/gulp/bin/gulp", + "test": "node node_modules/gulp/bin/gulp test", + "postinstall": "node node_modules/gulp/bin/gulp production", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/server/controllers/users.js b/server/controllers/users.js index 028c355..3d6b6f8 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -1,9 +1,11 @@ +import model from '../models'; + function get(req, res) { return res.json({ ok: 'none' }); } function create(req, res) { - return res.json({ create: 'yes' }); + } export default { get, create }; diff --git a/server/migrations/20170709115813-create-role.js b/server/migrations/20170709115213-create-role.js similarity index 100% rename from server/migrations/20170709115813-create-role.js rename to server/migrations/20170709115213-create-role.js diff --git a/server/migrations/20170709115254-create-user.js b/server/migrations/20170709115254-create-user.js index 4746168..0a303d6 100644 --- a/server/migrations/20170709115254-create-user.js +++ b/server/migrations/20170709115254-create-user.js @@ -27,6 +27,16 @@ module.exports = { type: Sequelize.STRING, allowNull: false }, + roleId: { + type: Sequelize.INTEGER, + references: { + model: 'Roles', + key: 'id', + as: 'roleId' + }, + allowNull: false, + defaultValue: 2 + }, createdAt: { allowNull: false, type: Sequelize.DATE diff --git a/server/models/document.js b/server/models/document.js index eac8ffd..4c4cfd1 100644 --- a/server/models/document.js +++ b/server/models/document.js @@ -18,12 +18,15 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + } + } }); - Document.associate = (models) => { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - }; return Document; }; diff --git a/server/models/role.js b/server/models/role.js index a81a8fe..986b172 100644 --- a/server/models/role.js +++ b/server/models/role.js @@ -6,12 +6,15 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, unique: true } + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + } + } }); - Role.associate = (models) => { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - }; return Role; }; diff --git a/server/models/user.js b/server/models/user.js index a8c4bfe..f126a64 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -15,7 +15,6 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, unique: true }, - password: { type: DataTypes.STRING, allowNull: false @@ -25,17 +24,20 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, defaultvalue: 2 } + }, { + classMethods: { + associate: (models) => { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId' + }); + } + } }); - User.associate = (models) => { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId' - }); - }; return User; }; From 52e3384875c854140063b6c0184027fe1150f974 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sat, 22 Jul 2017 18:57:50 +0100 Subject: [PATCH 13/98] feat(signup): create-account - ensure user is registered - ensure user data is stored in the database [Finishes #149293369] --- dist/server/config/config.js | 27 +++++++++++++++ dist/server/config/express.js | 19 +++++++++-- dist/server/controllers/users.js | 56 ++++++++++++++++++++++++++++++-- dist/server/helpers/helper.js | 12 +++++++ dist/server/models/index.js | 2 +- dist/server/models/user.js | 3 +- dist/server/routes/users.js | 6 +++- package.json | 7 ++-- server/config/config.js | 25 ++++++++++++++ server/config/config.json | 25 -------------- server/config/express.js | 14 +++++++- server/controllers/users.js | 50 ++++++++++++++++++++++++++-- server/helpers/helper.js | 8 +++++ server/models/index.js | 2 +- server/models/user.js | 3 +- server/routes/users.js | 5 ++- 16 files changed, 223 insertions(+), 41 deletions(-) create mode 100644 dist/server/config/config.js create mode 100644 dist/server/helpers/helper.js create mode 100644 server/config/config.js delete mode 100644 server/config/config.json create mode 100644 server/helpers/helper.js diff --git a/dist/server/config/config.js b/dist/server/config/config.js new file mode 100644 index 0000000..d3ec778 --- /dev/null +++ b/dist/server/config/config.js @@ -0,0 +1,27 @@ +'use strict'; + +module.exports = { + development: { + username: 'andeladeveloper', + password: null, + database: 'docmanager-dev', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' + }, + test: { + username: 'andeladeveloper', + password: null, + database: 'docmanager-test', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' + }, + production: { + username: 'root', + password: null, + database: 'database_production', + host: '127.0.0.1', + dialect: 'postgres' + } +}; \ No newline at end of file diff --git a/dist/server/config/express.js b/dist/server/config/express.js index 8ee0f7a..c440c03 100644 --- a/dist/server/config/express.js +++ b/dist/server/config/express.js @@ -16,6 +16,10 @@ var _morgan = require('morgan'); var _morgan2 = _interopRequireDefault(_morgan); +var _expressValidator = require('express-validator'); + +var _expressValidator2 = _interopRequireDefault(_expressValidator); + var _routes = require('../routes'); var _routes2 = _interopRequireDefault(_routes); @@ -27,8 +31,19 @@ var app = (0, _express2.default)(); app.use((0, _morgan2.default)('dev')); app.use(_bodyParser2.default.json()); -app.use(_bodyParser2.default.urlencoded({ extended: true })); - +app.use(_bodyParser2.default.urlencoded({ extended: false })); +app.use((0, _expressValidator2.default)()); + +app.use(function (req, res, next) { + var send = res.send; + var sent = false; + res.send = function (data) { + if (sent) return; + send.bind(res)(data); + sent = true; + }; + next(); +}); // mount all routes on /api path app.use('/api/v1', _routes2.default); diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 5913ebc..9ca2318 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -4,16 +4,68 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var _bcrypt = require('bcrypt'); + +var _bcrypt2 = _interopRequireDefault(_bcrypt); + +var _helper = require('../helpers/helper'); + +var _helper2 = _interopRequireDefault(_helper); + var _models = require('../models'); var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var User = _models2.default.User; + function get(req, res) { return res.json({ ok: 'none' }); } -function create(req, res) {} +function create(req, res) { + req.check('fullName', 'FullName is required').notEmpty(); + req.check('userName', 'userName is required').notEmpty(); + req.check('email', 'FullName is required').notEmpty(); + req.check('email', 'Please put a valid email').isEmail(); + req.check('password', 'Password is required').notEmpty(); + req.check('password', 'Password must be a mininum of 4 character').isLength(4, 50); + var errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors: errors }); + } else { + _bcrypt2.default.genSalt(10, function (err, salt) { + _bcrypt2.default.hash(req.body.password, salt, function (err, hash) { + User.findAll({ + where: { email: req.body.email } + }).then(function (err, user) { + if (!user) { + User.create({ + fullName: req.body.fullName, + userName: req.body.userName, + email: req.body.email, + password: hash, + roleId: req.body.roleId || 2 + }).then(function (userDetails) { + res.status(200).json({ + userDetails: userDetails, + success: 'ok', + message: 'You have successfully registered.' + }); + }).catch(function (error) { + res.status(400).json(error); + }); + } + }); + }); + }); + } +} + +function login(req, res) { + res.send('login page'); +} -exports.default = { get: get, create: create }; \ No newline at end of file +exports.default = { get: get, create: create, login: login }; \ No newline at end of file diff --git a/dist/server/helpers/helper.js b/dist/server/helpers/helper.js new file mode 100644 index 0000000..9669f87 --- /dev/null +++ b/dist/server/helpers/helper.js @@ -0,0 +1,12 @@ +"use strict"; + +var paginationMetaData = function paginationMetaData(count, limit, offset) { + return { + totalCount: count, + pageCount: Math.ceil(count / limit), + page: Math.floor(offset / limit) + 1, + pageSize: limit + }; +}; + +module.exports.paginationMetaData = paginationMetaData; \ No newline at end of file diff --git a/dist/server/models/index.js b/dist/server/models/index.js index fad1007..d5e98bf 100644 --- a/dist/server/models/index.js +++ b/dist/server/models/index.js @@ -6,7 +6,7 @@ var Sequelize = require('sequelize'); var basename = path.basename(module.filename); var env = process.env.NODE_ENV || 'development'; -var config = require('../config/config.json')[env]; +var config = require('../config/config.js')[env]; var db = {}; diff --git a/dist/server/models/user.js b/dist/server/models/user.js index 4b286b0..e4a24e8 100644 --- a/dist/server/models/user.js +++ b/dist/server/models/user.js @@ -35,7 +35,8 @@ module.exports = function (sequelize, DataTypes) { hooks: true }); User.belongsTo(models.Role, { - foreignKey: 'roleId' + foreignKey: 'roleId', + onDelete: 'CASCADE' }); } } diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 1dbc49b..12e8fbc 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -20,7 +20,11 @@ router.route('/') /** GET /api/users - Get list of users */ .get(_users2.default.get) -/** POST /api/users - Get list of users */ +/** POST /api/users - Create/Signup users */ .post(_users2.default.create); +router.route('/login') +/** POST /api/users/login - Login users */ +.post(_users2.default.login); + exports.default = router; \ No newline at end of file diff --git a/package.json b/package.json index 76a9de0..1e0aefd 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "main": "server/index.js", "scripts": { "start": "node node_modules/gulp/bin/gulp", - "test": "node node_modules/gulp/bin/gulp test", - "postinstall": "node node_modules/gulp/bin/gulp production", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "postinstall": "node node_modules/gulp/bin/gulp production" }, "repository": { "type": "git", @@ -24,11 +23,13 @@ "babel": "^6.23.0", "babel-cli": "^6.24.1", "babel-preset-es2015": "^6.24.1", + "bcrypt": "^1.0.2", "body-parser": "^1.17.2", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", "express": "^4.15.3", + "express-validator": "^3.2.1", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", diff --git a/server/config/config.js b/server/config/config.js new file mode 100644 index 0000000..5edaa1c --- /dev/null +++ b/server/config/config.js @@ -0,0 +1,25 @@ +module.exports = { + development: { + username: 'andeladeveloper', + password: null, + database: 'docmanager-dev', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' + }, + test: { + username: 'andeladeveloper', + password: null, + database: 'docmanager-test', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' + }, + production: { + username: 'root', + password: null, + database: 'database_production', + host: '127.0.0.1', + dialect: 'postgres' + } +}; diff --git a/server/config/config.json b/server/config/config.json deleted file mode 100644 index 3e3cec2..0000000 --- a/server/config/config.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "development": { - "username": "andeladeveloper", - "password": null, - "database": "docmanager-dev", - "host": "127.0.0.1", - "port": 5432, - "dialect": "postgres" - }, - "test": { - "username": "andeladeveloper", - "password": null, - "database": "docmanager-test", - "host": "127.0.0.1", - "port": 5432, - "dialect": "postgres" - }, - "production": { - "username": "root", - "password": null, - "database": "database_production", - "host": "127.0.0.1", - "dialect": "postgres" - } -} diff --git a/server/config/express.js b/server/config/express.js index 49b1337..0d1dbb6 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -1,6 +1,7 @@ import express from 'express'; import bodyParser from 'body-parser'; import logger from 'morgan'; +import expressValidator from 'express-validator'; import routes from '../routes'; @@ -9,8 +10,19 @@ const app = express(); app.use(logger('dev')); app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: true })); +app.use(bodyParser.urlencoded({ extended: false })); +app.use(expressValidator()); +app.use((req, res, next) => { + const send = res.send; + let sent = false; + res.send = (data) => { + if (sent) return; + send.bind(res)(data); + sent = true; + }; + next(); +}); // mount all routes on /api path app.use('/api/v1', routes); diff --git a/server/controllers/users.js b/server/controllers/users.js index 3d6b6f8..2f4611a 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -1,11 +1,57 @@ -import model from '../models'; +import bcrypt from 'bcrypt'; + +import pagination from '../helpers/helper'; +import models from '../models'; + +const User = models.User; function get(req, res) { return res.json({ ok: 'none' }); } function create(req, res) { + req.check('fullName', 'FullName is required').notEmpty(); + req.check('userName', 'userName is required').notEmpty(); + req.check('email', 'FullName is required').notEmpty(); + req.check('email', 'Please put a valid email').isEmail(); + req.check('password', 'Password is required').notEmpty(); + req.check('password', 'Password must be a mininum of 4 character') + .isLength(4, 50); + const errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors }); + } else { + bcrypt.genSalt(10, (err, salt) => { + bcrypt.hash(req.body.password, salt, (err, hash) => { + User.findAll({ + where: { email: req.body.email } + }).then((err, user) => { + if (!user) { + User.create({ + fullName: req.body.fullName, + userName: req.body.userName, + email: req.body.email, + password: hash, + roleId: req.body.roleId || 2 + }).then((userDetails) => { + res.status(200).json({ + userDetails, + success: 'ok', + message: 'You have successfully registered.' + }); + }).catch((error) => { + res.status(400).json(error); + }); + } + }); + }); + }); + } +} +function login(req, res) { + res.send('login page'); } -export default { get, create }; +export default { get, create, login }; diff --git a/server/helpers/helper.js b/server/helpers/helper.js new file mode 100644 index 0000000..9e35835 --- /dev/null +++ b/server/helpers/helper.js @@ -0,0 +1,8 @@ +const paginationMetaData = (count, limit, offset) => ({ + totalCount: count, + pageCount: Math.ceil(count / limit), + page: Math.floor(offset / limit) + 1, + pageSize: limit +}); + +module.exports.paginationMetaData = paginationMetaData; diff --git a/server/models/index.js b/server/models/index.js index ed98624..bf322e3 100644 --- a/server/models/index.js +++ b/server/models/index.js @@ -4,7 +4,7 @@ const Sequelize = require('sequelize'); const basename = path.basename(module.filename); const env = process.env.NODE_ENV || 'development'; -const config = require('../config/config.json')[env]; +const config = require('../config/config.js')[env]; const db = {}; diff --git a/server/models/user.js b/server/models/user.js index f126a64..3157132 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -34,7 +34,8 @@ module.exports = (sequelize, DataTypes) => { hooks: true }); User.belongsTo(models.Role, { - foreignKey: 'roleId' + foreignKey: 'roleId', + onDelete: 'CASCADE' }); } } diff --git a/server/routes/users.js b/server/routes/users.js index 6a98828..708e3d3 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -7,8 +7,11 @@ router.route('/') /** GET /api/users - Get list of users */ .get(userController.get) - /** POST /api/users - Get list of users */ + /** POST /api/users - Create/Signup users */ .post(userController.create); +router.route('/login') + /** POST /api/users/login - Login users */ + .post(userController.login); export default router; From 7374c1146f3fab83bdde873db538bb88189e674f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 07:36:44 +0100 Subject: [PATCH 14/98] feat(login): log-user-in -ensures user is logged in ensures a token is given to each logged in user [Finishes #149350019] --- .env | 1 + dist/index.js | 4 +- dist/server/controllers/users.js | 102 +++++++++++++++++++++++++++++-- dist/server/middlewares/auth.js | 44 +++++++++++++ dist/server/routes/users.js | 8 ++- index.js | 4 +- package.json | 2 + server/config/express.js | 1 - server/controllers/users.js | 67 +++++++++++++++++--- server/middlewares/auth.js | 35 +++++++++++ server/routes/users.js | 6 +- 11 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 .env create mode 100644 dist/server/middlewares/auth.js create mode 100644 server/middlewares/auth.js diff --git a/.env b/.env new file mode 100644 index 0000000..4dfa2cb --- /dev/null +++ b/.env @@ -0,0 +1 @@ +JWT_SECRET=iamflax diff --git a/dist/index.js b/dist/index.js index 296b68a..32c726d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,6 +6,8 @@ var _express2 = _interopRequireDefault(_express); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -_express2.default.listen(3000, function () { +var port = process.env.PORT || 3000; + +_express2.default.listen(port, function () { console.log('API Server started and listening on port 3000'); }); \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 9ca2318..02ee694 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -8,6 +8,10 @@ var _bcrypt = require('bcrypt'); var _bcrypt2 = _interopRequireDefault(_bcrypt); +var _jsonwebtoken = require('jsonwebtoken'); + +var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); + var _helper = require('../helpers/helper'); var _helper2 = _interopRequireDefault(_helper); @@ -18,16 +22,35 @@ var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +require('dotenv').config(); + +var jwtSecret = process.env.JWT_SECRET; var User = _models2.default.User; +var metaData = _helper2.default.paginationMetaData; -function get(req, res) { - return res.json({ ok: 'none' }); +function getUsers(req, res) { + var limit = req.query.limit; + var offset = req.query.offset; + return User.findAndCountAll({ limit: limit, + offset: offset, + attributes: { exclude: ['password'] } + }).then(function (_ref) { + var user = _ref.rows, + count = _ref.count; + + res.status(200).send({ + user: user, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); } -function create(req, res) { +function createUser(req, res) { req.check('fullName', 'FullName is required').notEmpty(); req.check('userName', 'userName is required').notEmpty(); - req.check('email', 'FullName is required').notEmpty(); + req.check('email', 'Email is required').notEmpty(); req.check('email', 'Please put a valid email').isEmail(); req.check('password', 'Password is required').notEmpty(); req.check('password', 'Password must be a mininum of 4 character').isLength(4, 50); @@ -65,7 +88,74 @@ function create(req, res) { } function login(req, res) { - res.send('login page'); + req.check('email', 'Email is required').notEmpty(); + req.check('email', 'Please put a valid email').isEmail(); + req.check('password', 'Password is required').notEmpty(); + + var errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors: errors }); + } else { + User.findAll({ + where: { email: req.body.email } + }).then(function (user) { + var existingUser = user[0]; + if (!existingUser) { + res.status(400).json({ + success: false, + message: 'Authentication failed. User not found.' }); + } else if (existingUser) { + _bcrypt2.default.compare(req.body.password, existingUser.password, function (err, result) { + if (err) throw err; + if (result) { + var payLoad = { + email: existingUser.email, + id: existingUser.id, + fullName: existingUser.fullName, + roleId: existingUser.roleId + }; + var token = _jsonwebtoken2.default.sign(payLoad, jwtSecret, { + expiresIn: 60 * 60 * 24 + }); + res.status(201).json({ + success: true, + token: token + }); + } else { + res.status(401).json({ + success: false, + message: 'Authentication failed. Wrong password.' + }); + } + }); + } + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +function findUser(req, res) { + var userQuery = Number(req.params.id); + if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { + return res.status(401).json({ + message: 'Unauthorized Access' + }); + } + return User.findAll({ + where: { + id: req.params.id + }, + attributes: { exclude: ['password'] } + }).then(function (user) { + if (!user.length) { + res.status(404).json({ message: 'User not found' }); + } + res.status(200).send(user); + }).catch(function (error) { + return res.status(400).send(error); + }); } -exports.default = { get: get, create: create, login: login }; \ No newline at end of file +exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser }; \ No newline at end of file diff --git a/dist/server/middlewares/auth.js b/dist/server/middlewares/auth.js new file mode 100644 index 0000000..7e0eb35 --- /dev/null +++ b/dist/server/middlewares/auth.js @@ -0,0 +1,44 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _jsonwebtoken = require('jsonwebtoken'); + +var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var jwtSecret = process.env.JWT_SECRET; + +function verifyToken(req, res, next) { + var token = req.headers.authorization || req.headers['x-access-token']; + if (token) { + _jsonwebtoken2.default.verify(token, jwtSecret, function (err, decoded) { + if (err) { + res.json({ success: false, message: 'Failed to authenticate token.' }); + } else { + req.decoded = decoded; + next(); + } + }); + } else { + return res.status(403).send({ + success: false, + message: 'No token provided.' + }); + } +} + +function adminAccess(req, res, next) { + if (req.decoded.roleId === 1) { + next(); + } else { + return res.status(401).json({ + message: 'You are not authorized' + }); + } +} + +exports.default = { verifyToken: verifyToken, adminAccess: adminAccess }; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 12e8fbc..71f3715 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -12,16 +12,20 @@ var _users = require('../controllers/users'); var _users2 = _interopRequireDefault(_users); +var _auth = require('../middlewares/auth'); + +var _auth2 = _interopRequireDefault(_auth); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); router.route('/') /** GET /api/users - Get list of users */ -.get(_users2.default.get) +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _users2.default.getUsers) /** POST /api/users - Create/Signup users */ -.post(_users2.default.create); +.post(_users2.default.createUser); router.route('/login') /** POST /api/users/login - Login users */ diff --git a/index.js b/index.js index 9d28716..e81e308 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ import app from './server/config/express'; -app.listen(3000, () => { +const port = process.env.PORT || 3000; + +app.listen(port, () => { console.log('API Server started and listening on port 3000'); }); diff --git a/package.json b/package.json index 1e0aefd..d96b323 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "babel-preset-es2015": "^6.24.1", "bcrypt": "^1.0.2", "body-parser": "^1.17.2", + "dotenv": "^4.0.0", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", @@ -34,6 +35,7 @@ "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", "gulp-nodemon": "^2.2.1", + "jsonwebtoken": "^7.4.1", "morgan": "^1.8.2", "pg": "^6.4.0", "pg-hstore": "^2.3.2", diff --git a/server/config/express.js b/server/config/express.js index 0d1dbb6..dd11f1d 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -4,7 +4,6 @@ import logger from 'morgan'; import expressValidator from 'express-validator'; import routes from '../routes'; - const app = express(); app.use(logger('dev')); diff --git a/server/controllers/users.js b/server/controllers/users.js index 2f4611a..9b7b67a 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -1,18 +1,21 @@ import bcrypt from 'bcrypt'; +import jwt from 'jsonwebtoken'; -import pagination from '../helpers/helper'; +import helper from '../helpers/helper'; import models from '../models'; +require('dotenv').config(); + +const jwtSecret = process.env.JWT_SECRET; const User = models.User; +const metaData = helper.paginationMetaData; + -function get(req, res) { - return res.json({ ok: 'none' }); -} -function create(req, res) { +function createUser(req, res) { req.check('fullName', 'FullName is required').notEmpty(); req.check('userName', 'userName is required').notEmpty(); - req.check('email', 'FullName is required').notEmpty(); + req.check('email', 'Email is required').notEmpty(); req.check('email', 'Please put a valid email').isEmail(); req.check('password', 'Password is required').notEmpty(); req.check('password', 'Password must be a mininum of 4 character') @@ -51,7 +54,55 @@ function create(req, res) { } function login(req, res) { - res.send('login page'); + req.check('email', 'Email is required').notEmpty(); + req.check('email', 'Please put a valid email').isEmail(); + req.check('password', 'Password is required').notEmpty(); + + const errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors }); + } else { + User.findAll({ + where: { email: req.body.email } + }) + .then((user) => { + const existingUser = user[0]; + if (!existingUser) { + res.status(400).json({ + success: false, + message: 'Authentication failed. User not found.' }); + } else if (existingUser) { + bcrypt + .compare(req.body.password, existingUser.password, (err, result) => { + if (err) throw err; + if (result) { + const payLoad = ( + { + email: existingUser.email, + id: existingUser.id, + fullName: existingUser.fullName, + roleId: existingUser.roleId, + } + ); + const token = jwt.sign(payLoad, jwtSecret, { + expiresIn: 60 * 60 * 24 + }); + res.status(201).json({ + success: true, + token, + }); + } else { + res.status(401).json({ + success: false, + message: 'Authentication failed. Wrong password.' + }); + } + }); + } + }).catch(error => res.status(400).send(error)); + } } -export default { get, create, login }; + +export default { , createUser, login, }; diff --git a/server/middlewares/auth.js b/server/middlewares/auth.js new file mode 100644 index 0000000..85fb266 --- /dev/null +++ b/server/middlewares/auth.js @@ -0,0 +1,35 @@ +import jwt from 'jsonwebtoken'; + +const jwtSecret = process.env.JWT_SECRET; + + +function verifyToken(req, res, next) { + const token = req.headers.authorization || req.headers['x-access-token']; + if (token) { + jwt.verify(token, jwtSecret, (err, decoded) => { + if (err) { + res.json({ success: false, message: 'Failed to authenticate token.' }); + } else { + req.decoded = decoded; + next(); + } + }); + } else { + return res.status(403).send({ + success: false, + message: 'No token provided.' + }); + } +} + +function adminAccess(req, res, next) { + if (req.decoded.roleId === 1) { + next(); + } else { + return res.status(401).json({ + message: 'You are not authorized', + }); + } +} + +export default { verifyToken, adminAccess }; diff --git a/server/routes/users.js b/server/routes/users.js index 708e3d3..47107ab 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -1,17 +1,19 @@ import express from 'express'; import userController from '../controllers/users'; +import auth from '../middlewares/auth'; const router = express.Router(); router.route('/') /** GET /api/users - Get list of users */ - .get(userController.get) + .get(auth.verifyToken, auth.adminAccess, userController.getUsers) /** POST /api/users - Create/Signup users */ - .post(userController.create); + .post(userController.createUser); router.route('/login') /** POST /api/users/login - Login users */ .post(userController.login); + export default router; From 3e131e8c4773ca21fb499f769e4ec7130e316de7 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 07:56:11 +0100 Subject: [PATCH 15/98] feat(getUsers): find-users - get all users if the user is an admin - return unauthorized access if the user is not an admin [Finishes #14935501] --- dist/server/controllers/users.js | 24 +----------------------- server/controllers/users.js | 21 ++++++++++++++++++--- server/routes/users.js | 1 - 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 02ee694..0e48060 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -136,26 +136,4 @@ function login(req, res) { } } -function findUser(req, res) { - var userQuery = Number(req.params.id); - if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { - return res.status(401).json({ - message: 'Unauthorized Access' - }); - } - return User.findAll({ - where: { - id: req.params.id - }, - attributes: { exclude: ['password'] } - }).then(function (user) { - if (!user.length) { - res.status(404).json({ message: 'User not found' }); - } - res.status(200).send(user); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser }; \ No newline at end of file +exports.default = { getUsers: getUsers, createUser: createUser, login: login }; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js index 9b7b67a..916be8f 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -10,7 +10,23 @@ const jwtSecret = process.env.JWT_SECRET; const User = models.User; const metaData = helper.paginationMetaData; - +function getUsers(req, res) { + const limit = req.query.limit; + const offset = req.query.offset; + return User + .findAndCountAll( + { limit, + offset, + attributes: { exclude: ['password'] } + }) + .then(({ rows: user, count }) => { + res.status(200).send({ + user, + pagination: metaData(count, limit, offset) + }); + }) + .catch(error => res.status(400).send(error)); +} function createUser(req, res) { req.check('fullName', 'FullName is required').notEmpty(); @@ -104,5 +120,4 @@ function login(req, res) { } } - -export default { , createUser, login, }; +export default { getUsers, createUser, login }; diff --git a/server/routes/users.js b/server/routes/users.js index 47107ab..2d98104 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -15,5 +15,4 @@ router.route('/login') /** POST /api/users/login - Login users */ .post(userController.login); - export default router; From f3ed91cb2364dcf1f01a97d821ec7a96097ead03 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 08:14:21 +0100 Subject: [PATCH 16/98] feat(finduser):find-user - ensure users can find a user when logged in [Finishes #149355603] --- dist/server/controllers/users.js | 24 +++++++++++++++++++++++- dist/server/routes/users.js | 4 ++++ server/controllers/users.js | 25 ++++++++++++++++++++++++- server/routes/users.js | 4 ++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 0e48060..02ee694 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -136,4 +136,26 @@ function login(req, res) { } } -exports.default = { getUsers: getUsers, createUser: createUser, login: login }; \ No newline at end of file +function findUser(req, res) { + var userQuery = Number(req.params.id); + if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { + return res.status(401).json({ + message: 'Unauthorized Access' + }); + } + return User.findAll({ + where: { + id: req.params.id + }, + attributes: { exclude: ['password'] } + }).then(function (user) { + if (!user.length) { + res.status(404).json({ message: 'User not found' }); + } + res.status(200).send(user); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser }; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 71f3715..e8bc15c 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -31,4 +31,8 @@ router.route('/login') /** POST /api/users/login - Login users */ .post(_users2.default.login); +router.route('/:id') +/** GET /api/users/id - Find users */ +.get(_auth2.default.verifyToken, _users2.default.findUser); + exports.default = router; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js index 916be8f..7cab0a1 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -120,4 +120,27 @@ function login(req, res) { } } -export default { getUsers, createUser, login }; +function findUser(req, res) { + const userQuery = Number(req.params.id); + if ((req.decoded.id !== userQuery) && (req.decoded.roleId !== 1)) { + return res.status(401).json({ + message: 'Unauthorized Access' + }); + } + return User + .findAll({ + where: { + id: req.params.id, + }, + attributes: { exclude: ['password'] } + }) + .then((user) => { + if (!user.length) { + res.status(404).json({ message: 'User not found' }); + } + res.status(200).send(user); + }) + .catch(error => res.status(400).send(error)); +} + +export default { getUsers, createUser, login, findUser }; diff --git a/server/routes/users.js b/server/routes/users.js index 2d98104..6362b7a 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -15,4 +15,8 @@ router.route('/login') /** POST /api/users/login - Login users */ .post(userController.login); +router.route('/:id') + /** GET /api/users/id - Find users */ + .get(auth.verifyToken, userController.findUser); + export default router; From 9d99802b95d43043eda71bdd57787030fda0dc4f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 09:39:55 +0100 Subject: [PATCH 17/98] feat(user-update): update-user -ensures user is logged in before updating attributes. ensures user cannot update another user attributes. [Finishes #149356073] --- dist/server/controllers/users.js | 39 +++++++++++++++++++++++++++++- dist/server/routes/users.js | 5 +++- server/controllers/users.js | 41 +++++++++++++++++++++++++++++++- server/routes/users.js | 5 +++- 4 files changed, 86 insertions(+), 4 deletions(-) diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 02ee694..6872f72 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -158,4 +158,41 @@ function findUser(req, res) { }); } -exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser }; \ No newline at end of file +function updateUser(req, res) { + if (Number(req.decoded.id) !== Number(req.params.id)) { + return res.status(401).json({ + message: 'You are not authorized to access this user' + }); + } + var userId = Number(req.params.id); + _bcrypt2.default.genSalt(10, function (err, salt) { + _bcrypt2.default.hash(req.body.password, salt, function (err, hash) { + User.findById(userId).then(function (user) { + if (!user) { + return res.status(404).json({ message: 'User not found' }); + } + return user.update({ + fullName: req.body.fullName || user.fullName, + userName: req.body.userName || user.userName, + email: req.body.email || user.email, + password: hash || user.password, + roleId: req.body.roleId || user.roleId + }).then(function (updatedUser) { + res.status(200).send({ + id: updatedUser.id, + fullName: updatedUser.fullName, + userName: updatedUser.userName, + email: updatedUser.email, + roleId: updatedUser.roleId + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }); + }); +} + +exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser, updateUser: updateUser }; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index e8bc15c..e1c9f0f 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -33,6 +33,9 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ -.get(_auth2.default.verifyToken, _users2.default.findUser); +.get(_auth2.default.verifyToken, _users2.default.findUser) + +/** PUT /api/users/id - update users */ +.put(_auth2.default.verifyToken, _users2.default.updateUser); exports.default = router; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js index 7cab0a1..89fbf08 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -143,4 +143,43 @@ function findUser(req, res) { .catch(error => res.status(400).send(error)); } -export default { getUsers, createUser, login, findUser }; +function updateUser(req, res) { + if (Number(req.decoded.id) !== Number(req.params.id)) { + return res.status(401).json({ + message: 'You are not authorized to access this user' + }); + } + const userId = Number(req.params.id); + bcrypt.genSalt(10, (err, salt) => { + bcrypt.hash(req.body.password, salt, (err, hash) => { + User + .findById(userId) + .then((user) => { + if (!user) { + return res.status(404).json({ message: 'User not found' }); + } + return user + .update({ + fullName: req.body.fullName || user.fullName, + userName: req.body.userName || user.userName, + email: req.body.email || user.email, + password: hash || user.password, + roleId: req.body.roleId || user.roleId + }) + .then((updatedUser) => { + res.status(200).send({ + id: updatedUser.id, + fullName: updatedUser.fullName, + userName: updatedUser.userName, + email: updatedUser.email, + roleId: updatedUser.roleId + }); + }) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); + }); + }); +} + +export default { getUsers, createUser, login, findUser, updateUser }; diff --git a/server/routes/users.js b/server/routes/users.js index 6362b7a..8f74729 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -17,6 +17,9 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ - .get(auth.verifyToken, userController.findUser); + .get(auth.verifyToken, userController.findUser) + + /** PUT /api/users/id - update users */ + .put(auth.verifyToken, userController.updateUser); export default router; From b2cda45eca451b7d556e77cd4fff5ea398c2882c Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 11:39:09 +0100 Subject: [PATCH 18/98] feat(user-delete): delete-user [Finishes #149356281] --- dist/server/config/express.js | 1 + dist/server/controllers/search.js | 1 + dist/server/controllers/searches.js | 1 + dist/server/controllers/users.js | 33 +++++++++++++++++++++++++++-- dist/server/routes/index.js | 4 ++++ dist/server/routes/search.js | 1 + dist/server/routes/users.js | 5 ++++- server/config/express.js | 1 + server/controllers/search.js | 1 + server/controllers/users.js | 33 +++++++++++++++++++++++++++-- server/routes/index.js | 1 + server/routes/search.js | 0 server/routes/users.js | 5 ++++- 13 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 dist/server/controllers/search.js create mode 100644 dist/server/controllers/searches.js create mode 100644 dist/server/routes/search.js create mode 100644 server/controllers/search.js create mode 100644 server/routes/search.js diff --git a/dist/server/config/express.js b/dist/server/config/express.js index c440c03..40c9b7c 100644 --- a/dist/server/config/express.js +++ b/dist/server/config/express.js @@ -44,6 +44,7 @@ app.use(function (req, res, next) { }; next(); }); + // mount all routes on /api path app.use('/api/v1', _routes2.default); diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js new file mode 100644 index 0000000..9a390c3 --- /dev/null +++ b/dist/server/controllers/search.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/dist/server/controllers/searches.js b/dist/server/controllers/searches.js new file mode 100644 index 0000000..9a390c3 --- /dev/null +++ b/dist/server/controllers/searches.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 6872f72..86ff844 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -183,7 +183,8 @@ function updateUser(req, res) { fullName: updatedUser.fullName, userName: updatedUser.userName, email: updatedUser.email, - roleId: updatedUser.roleId + roleId: updatedUser.roleId, + message: 'Details successfully updated.' }); }).catch(function (error) { return res.status(400).send(error); @@ -195,4 +196,32 @@ function updateUser(req, res) { }); } -exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser, updateUser: updateUser }; \ No newline at end of file +function deleteUser(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ + message: 'You are not authorized to access this field' + }); + } + return User.findById(req.params.id).then(function (user) { + if (!user) { + return res.status(404).json({ message: 'User not found' }); + } + return user.destroy().then(function () { + return res.status(204).json({ + message: 'User has been deleted successfully' }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { + getUsers: getUsers, + createUser: createUser, + login: login, + findUser: findUser, + updateUser: updateUser, + deleteUser: deleteUser +}; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index 36a32d2..e8474f9 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -12,6 +12,10 @@ var _users = require('./users'); var _users2 = _interopRequireDefault(_users); +var _search = require('./search'); + +var _search2 = _interopRequireDefault(_search); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js new file mode 100644 index 0000000..9a390c3 --- /dev/null +++ b/dist/server/routes/search.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index e1c9f0f..73b8288 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -36,6 +36,9 @@ router.route('/:id') .get(_auth2.default.verifyToken, _users2.default.findUser) /** PUT /api/users/id - update users */ -.put(_auth2.default.verifyToken, _users2.default.updateUser); +.put(_auth2.default.verifyToken, _users2.default.updateUser) + +/** DELETE /api/users/id - delete users */ +.delete(_auth2.default.verifyToken, _users2.default.deleteUser); exports.default = router; \ No newline at end of file diff --git a/server/config/express.js b/server/config/express.js index dd11f1d..197da2d 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -22,6 +22,7 @@ app.use((req, res, next) => { }; next(); }); + // mount all routes on /api path app.use('/api/v1', routes); diff --git a/server/controllers/search.js b/server/controllers/search.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/server/controllers/search.js @@ -0,0 +1 @@ + diff --git a/server/controllers/users.js b/server/controllers/users.js index 89fbf08..b48fb60 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -172,7 +172,8 @@ function updateUser(req, res) { fullName: updatedUser.fullName, userName: updatedUser.userName, email: updatedUser.email, - roleId: updatedUser.roleId + roleId: updatedUser.roleId, + message: 'Details successfully updated.' }); }) .catch(error => res.status(400).send(error)); @@ -182,4 +183,32 @@ function updateUser(req, res) { }); } -export default { getUsers, createUser, login, findUser, updateUser }; +function deleteUser(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ + message: 'You are not authorized to access this field' + }); + } + return User + .findById(req.params.id) + .then((user) => { + if (!user) { + return res.status(404).json({ message: 'User not found' }); + } + return user + .destroy() + .then(() => res.status(204).json({ + message: 'User has been deleted successfully' })) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); +} + +export default { + getUsers, + createUser, + login, + findUser, + updateUser, + deleteUser +}; diff --git a/server/routes/index.js b/server/routes/index.js index 849678a..56146a1 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -1,5 +1,6 @@ import express from 'express'; import userRoutes from './users'; +import searchRoutes from './search'; const router = express.Router(); diff --git a/server/routes/search.js b/server/routes/search.js new file mode 100644 index 0000000..e69de29 diff --git a/server/routes/users.js b/server/routes/users.js index 8f74729..5f74cc5 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -20,6 +20,9 @@ router.route('/:id') .get(auth.verifyToken, userController.findUser) /** PUT /api/users/id - update users */ - .put(auth.verifyToken, userController.updateUser); + .put(auth.verifyToken, userController.updateUser) + + /** DELETE /api/users/id - delete users */ + .delete(auth.verifyToken, userController.deleteUser); export default router; From ced461b4923b5183c1fe5b04f4a09a02a8fd0cd4 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 11:54:47 +0100 Subject: [PATCH 19/98] refactor users croute --- dist/server/routes/users.js | 4 ++-- server/routes/users.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 73b8288..e5b18dd 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -22,7 +22,7 @@ var router = _express2.default.Router(); router.route('/') /** GET /api/users - Get list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _users2.default.getUsers) +.get(_auth2.default.adminAccess, _users2.default.getUsers) /** POST /api/users - Create/Signup users */ .post(_users2.default.createUser); @@ -33,7 +33,7 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ -.get(_auth2.default.verifyToken, _users2.default.findUser) +.get(_auth2.default.adminAccess, _users2.default.findUser) /** PUT /api/users/id - update users */ .put(_auth2.default.verifyToken, _users2.default.updateUser) diff --git a/server/routes/users.js b/server/routes/users.js index 5f74cc5..524070f 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -6,7 +6,7 @@ const router = express.Router(); router.route('/') /** GET /api/users - Get list of users */ - .get(auth.verifyToken, auth.adminAccess, userController.getUsers) + .get(auth.adminAccess, userController.getUsers) /** POST /api/users - Create/Signup users */ .post(userController.createUser); @@ -17,7 +17,7 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ - .get(auth.verifyToken, userController.findUser) + .get(auth.adminAccess, userController.findUser) /** PUT /api/users/id - update users */ .put(auth.verifyToken, userController.updateUser) From 9ab604acc2c19f7390542b5f8bc5fc5359bf190f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 12:08:12 +0100 Subject: [PATCH 20/98] refactor users croute --- dist/server/routes/users.js | 4 ++-- server/routes/users.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index e5b18dd..73b8288 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -22,7 +22,7 @@ var router = _express2.default.Router(); router.route('/') /** GET /api/users - Get list of users */ -.get(_auth2.default.adminAccess, _users2.default.getUsers) +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _users2.default.getUsers) /** POST /api/users - Create/Signup users */ .post(_users2.default.createUser); @@ -33,7 +33,7 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ -.get(_auth2.default.adminAccess, _users2.default.findUser) +.get(_auth2.default.verifyToken, _users2.default.findUser) /** PUT /api/users/id - update users */ .put(_auth2.default.verifyToken, _users2.default.updateUser) diff --git a/server/routes/users.js b/server/routes/users.js index 524070f..5f74cc5 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -6,7 +6,7 @@ const router = express.Router(); router.route('/') /** GET /api/users - Get list of users */ - .get(auth.adminAccess, userController.getUsers) + .get(auth.verifyToken, auth.adminAccess, userController.getUsers) /** POST /api/users - Create/Signup users */ .post(userController.createUser); @@ -17,7 +17,7 @@ router.route('/login') router.route('/:id') /** GET /api/users/id - Find users */ - .get(auth.adminAccess, userController.findUser) + .get(auth.verifyToken, userController.findUser) /** PUT /api/users/id - update users */ .put(auth.verifyToken, userController.updateUser) From 012ba397d0e5d6d9dc413f0f494d0bc63b0133a4 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 12:19:37 +0100 Subject: [PATCH 21/98] feat(search): search-user - ensure when user search it return the result [Finishes #149357097] --- dist/server/controllers/documents.js | 20 ++++++++++ dist/server/controllers/search.js | 55 +++++++++++++++++++++++++++- dist/server/routes/documents.js | 29 +++++++++++++++ dist/server/routes/index.js | 1 + dist/server/routes/search.js | 30 ++++++++++++++- server/controllers/documents.js | 8 ++++ server/controllers/search.js | 36 ++++++++++++++++++ server/routes/documents.js | 13 +++++++ server/routes/index.js | 1 + server/routes/search.js | 13 +++++++ 10 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 dist/server/controllers/documents.js create mode 100644 dist/server/routes/documents.js create mode 100644 server/controllers/documents.js create mode 100644 server/routes/documents.js diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js new file mode 100644 index 0000000..b02ef3b --- /dev/null +++ b/dist/server/controllers/documents.js @@ -0,0 +1,20 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _helper = require('../helpers/helper'); + +var _helper2 = _interopRequireDefault(_helper); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Document = _models2.default.Document; +var metaData = _helper2.default.paginationMetaData; + +exports.default = { searchUser: searchUser }; \ No newline at end of file diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js index 9a390c3..d5d4518 100644 --- a/dist/server/controllers/search.js +++ b/dist/server/controllers/search.js @@ -1 +1,54 @@ -"use strict"; \ No newline at end of file +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _helper = require('../helpers/helper'); + +var _helper2 = _interopRequireDefault(_helper); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var User = _models2.default.User; +var metaData = _helper2.default.paginationMetaData; + +function searchUser(req, res) { + var searchQuery = req.query.q, + limit = req.query.limit, + offset = req.query.offset; + if (!searchQuery) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + return User.findAndCountAll({ + limit: limit, + offset: offset, + attributes: { exclude: ['password'] }, + where: { + userName: { + $like: '%' + searchQuery + '%' + } + } + }).then(function (_ref) { + var user = _ref.rows, + count = _ref.count; + + if (count === 0) { + return res.status(404).json({ message: 'User not found' }); + } + res.status(200).send({ + user: user, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { searchUser: searchUser }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js new file mode 100644 index 0000000..ca9282a --- /dev/null +++ b/dist/server/routes/documents.js @@ -0,0 +1,29 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _documents = require('../controllers/documents'); + +var _documents2 = _interopRequireDefault(_documents); + +var _auth = require('../middlewares/auth'); + +var _auth2 = _interopRequireDefault(_auth); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +router.route('/users') +/** GET /api/users - Get list of users */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _documents2.default.searchUser); + +/** POST /api/users - Create/Signup users */ + +exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index e8474f9..2e35f08 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -22,5 +22,6 @@ var router = _express2.default.Router(); /** GET /api-status - Check service status **/ router.use('/users', _users2.default); +router.use('/search', _search2.default); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js index 9a390c3..cf4eb95 100644 --- a/dist/server/routes/search.js +++ b/dist/server/routes/search.js @@ -1 +1,29 @@ -"use strict"; \ No newline at end of file +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _search = require('../controllers/search'); + +var _search2 = _interopRequireDefault(_search); + +var _auth = require('../middlewares/auth'); + +var _auth2 = _interopRequireDefault(_auth); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +router.route('/users') +/** GET /api/users - Get list of users */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); + +/** POST /api/users - Create/Signup users */ + +exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js new file mode 100644 index 0000000..a263ca4 --- /dev/null +++ b/server/controllers/documents.js @@ -0,0 +1,8 @@ +import helper from '../helpers/helper'; +import models from '../models'; + +const Document = models.Document; +const metaData = helper.paginationMetaData; + + +export default { searchUser }; diff --git a/server/controllers/search.js b/server/controllers/search.js index 8b13789..39c595d 100644 --- a/server/controllers/search.js +++ b/server/controllers/search.js @@ -1 +1,37 @@ +import helper from '../helpers/helper'; +import models from '../models'; +const User = models.User; +const metaData = helper.paginationMetaData; + +function searchUser(req, res) { + const searchQuery = req.query.q, + limit = req.query.limit, + offset = req.query.offset; + if (!searchQuery) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + return User + .findAndCountAll({ + limit, + offset, + attributes: { exclude: ['password'] }, + where: { + userName: { + $like: `%${searchQuery}%`, + } + } + }).then(({ rows: user, count }) => { + if (count === 0) { + return res.status(404).json({ message: 'User not found' }); + } + res.status(200).send({ + user, + pagination: metaData(count, limit, offset) + }); + }).catch(error => res.status(400).send(error)); +} + +export default { searchUser }; diff --git a/server/routes/documents.js b/server/routes/documents.js new file mode 100644 index 0000000..267d23d --- /dev/null +++ b/server/routes/documents.js @@ -0,0 +1,13 @@ +import express from 'express'; +import searchController from '../controllers/documents'; +import auth from '../middlewares/auth'; + +const router = express.Router(); + +router.route('/users') + /** GET /api/users - Get list of users */ + .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); + + /** POST /api/users - Create/Signup users */ + +export default router; diff --git a/server/routes/index.js b/server/routes/index.js index 56146a1..2fdb9b0 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -7,5 +7,6 @@ const router = express.Router(); /** GET /api-status - Check service status **/ router.use('/users', userRoutes); +router.use('/search', searchRoutes); export default router; diff --git a/server/routes/search.js b/server/routes/search.js index e69de29..4915745 100644 --- a/server/routes/search.js +++ b/server/routes/search.js @@ -0,0 +1,13 @@ +import express from 'express'; +import searchController from '../controllers/search'; +import auth from '../middlewares/auth'; + +const router = express.Router(); + +router.route('/users') + /** GET /api/users - Get list of users */ + .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); + + /** POST /api/users - Create/Signup users */ + +export default router; From 7e161e9a2f771fcf4ca2d85c5ee8ba3db32e1755 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 13:07:20 +0100 Subject: [PATCH 22/98] feat(createDoc): create-document -make sure user can create document and give it an access type [Finishes #149357821] --- dist/server/controllers/documents.js | 39 +++++++++++++++++++++++++++- dist/server/routes/documents.js | 10 +++---- dist/server/routes/index.js | 5 ++++ server/controllers/documents.js | 34 +++++++++++++++++++++++- server/routes/documents.js | 12 ++++----- server/routes/index.js | 2 ++ 6 files changed, 89 insertions(+), 13 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index b02ef3b..f122495 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -15,6 +15,43 @@ var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Document = _models2.default.Document; +var User = _models2.default.User; var metaData = _helper2.default.paginationMetaData; -exports.default = { searchUser: searchUser }; \ No newline at end of file +function createDocument(req, res) { + req.check('title', 'Title is required').notEmpty(); + req.check('content', 'Content is required').notEmpty(); + req.check('access', 'accessType is required').notEmpty(); + + var errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors: errors }); + } else { + Document.findAll({ + where: { + title: req.body.title + } + }).then(function (document) { + if (document.length === 0) { + return Document.create({ + title: req.body.title, + content: req.body.content, + access: req.body.value, + userId: req.body.userId + }).then(function (documentResponse) { + return res.status(201).send(documentResponse); + }).catch(function (error) { + return res.status(400).send(error); + }); + } + return res.status(403).json({ + title: 'Document already exists' + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +exports.default = { createDocument: createDocument }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index ca9282a..dbc9e6f 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -20,10 +20,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var router = _express2.default.Router(); -router.route('/users') -/** GET /api/users - Get list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _documents2.default.searchUser); - -/** POST /api/users - Create/Signup users */ +router.route('/') +/** GET /api/v1/documents - Get all documents */ +// .get(documentController.getDocuments) +/** POST /api/v1/documents - Create document */ +.post(_auth2.default.verifyToken, _documents2.default.createDocument); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index 2e35f08..7515895 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -16,6 +16,10 @@ var _search = require('./search'); var _search2 = _interopRequireDefault(_search); +var _documents = require('./documents'); + +var _documents2 = _interopRequireDefault(_documents); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); @@ -23,5 +27,6 @@ var router = _express2.default.Router(); /** GET /api-status - Check service status **/ router.use('/users', _users2.default); router.use('/search', _search2.default); +router.use('/documents', _documents2.default); exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index a263ca4..e748b17 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -2,7 +2,39 @@ import helper from '../helpers/helper'; import models from '../models'; const Document = models.Document; +const User = models.User; const metaData = helper.paginationMetaData; +function createDocument(req, res) { + req.check('title', 'Title is required').notEmpty(); + req.check('content', 'Content is required').notEmpty(); + req.check('access', 'accessType is required').notEmpty(); -export default { searchUser }; + const errors = req.validationErrors(); + + if (errors) { + res.status(400).json({ errors }); + } else { + Document.findAll({ + where: { + title: req.body.title + } + }).then((document) => { + if (document.length === 0) { + return Document.create({ + title: req.body.title, + content: req.body.content, + access: req.body.value, + userId: req.body.userId + }) + .then(documentResponse => res.status(201).send(documentResponse)) + .catch(error => res.status(400).send(error)); + } + return res.status(403).json({ + title: 'Document already exists' + }); + }).catch(error => res.status(400).send(error)); + } +} + +export default { createDocument }; diff --git a/server/routes/documents.js b/server/routes/documents.js index 267d23d..82b0cd8 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -1,13 +1,13 @@ import express from 'express'; -import searchController from '../controllers/documents'; +import documentController from '../controllers/documents'; import auth from '../middlewares/auth'; const router = express.Router(); -router.route('/users') - /** GET /api/users - Get list of users */ - .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); - - /** POST /api/users - Create/Signup users */ +router.route('/') + /** GET /api/v1/documents - Get all documents */ + // .get(documentController.getDocuments) + /** POST /api/v1/documents - Create document */ + .post(auth.verifyToken, documentController.createDocument); export default router; diff --git a/server/routes/index.js b/server/routes/index.js index 2fdb9b0..eb44098 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -1,6 +1,7 @@ import express from 'express'; import userRoutes from './users'; import searchRoutes from './search'; +import documentRoutes from './documents'; const router = express.Router(); @@ -8,5 +9,6 @@ const router = express.Router(); /** GET /api-status - Check service status **/ router.use('/users', userRoutes); router.use('/search', searchRoutes); +router.use('/documents', documentRoutes); export default router; From 75f9717d7d6ad5e2dba8912a32bc9deb6aa70550 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 13:32:19 +0100 Subject: [PATCH 23/98] feat(updateDoc): update-document -user can edit document after creating [Footer #149358075] --- .DS_Store | Bin 6148 -> 0 bytes dist/server/controllers/documents.js | 33 ++++++++++++++++++++++++++- dist/server/routes/documents.js | 5 ++++ server/controllers/documents.js | 32 +++++++++++++++++++++++++- server/routes/documents.js | 5 ++++ 5 files changed, 73 insertions(+), 2 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 6637985c70e81a5e9a263a0d6bf04196e54aa2d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK-A)rh6g~r0T7G2tsX+8%BQYU?7>EQkhENJb8&oPK2mvg+?NC;>GtKT61jO{l z2k=f!d;qV#^ab<@yfQw5CSG}^XMPH$NaB?-W=}HnojG&Pna;O8J39bClI8pefB^te zYyuX+L% zBVG${u?_r`f*L?8FyN2}3Rx&htqd-Xd{y_=IMVZ{arUlXvRxVX(Jr};9}EwFA`Oj^ zbLX3)u~;d1!X^Jd8=~da<;%+c#(hlkN<&()EM)JAb{ z|KRE2vsaP|Ao$vo(yp-zuTeRZC?~h0H%#7DH~hsgj<(#~(%N>R-RS7->geu>$Kw}! z;=O%+m$F8eZRNHLp7`<8+~r=aw9l8s zl)pqhAMsSo@`~ko7Aw%?-nwhq)SYKZ9t6B7JVmw~XK9a$Ov?`HVlVxZ-xRC;iMgsW zpcDi8m4XM9K^7TjG#2Ymq_r^$gD?g6UppS@eg%Vhh!}TpFV2xaZ$KYel zu)11#j=r@u7J~(>#wnP=Uq6dcMab7he6Nc*k9jG0up|1DzHkeDU)EGG4yEWFMq8?e z5JLt+20{ij1LFN)ViTCqSWzfn9oWe$0Ad8qQcxEk4I;+Wn9x{Jh%+ceg(9j@qOTZ4 zg`?fnehG~gg(@6~zI+h9GSN2_B3H-!rgR6AP#E?h10e$^8E8~PL!AG!XW#!%28E-L zfsld!iUAUt$;>2iOZsd*wK;Ltn%Fk52@!r3g)#&?eH=?g9L2rZq~M$>6vTwaibAxY QgdYNuhOi46_^S;30=z;PfdBvi diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index f122495..841ce4a 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -54,4 +54,35 @@ function createDocument(req, res) { } } -exports.default = { createDocument: createDocument }; \ No newline at end of file +function updateDocument(req, res) { + if (isNaN(req.params.id)) { + return res.status(400); + } + var docId = Number(req.params.id); + return Document.findById(docId).then(function (document) { + if (!document) { + return res.status(404).send({ + message: 'Document Not Found' + }); + } + if (Number(document.userId) !== Number(req.decoded.id)) { + return res.status(401).json({ + message: 'You are not authorized to edit this document' + }); + } + return document.update({ + title: req.body.title || document.title, + content: req.body.content || document.content, + access: req.body.value || document.access, + userId: req.body.userId || document.userId + }).then(function () { + return res.status(200).send(document); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { createDocument: createDocument, updateDocument: updateDocument }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index dbc9e6f..0824527 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -26,4 +26,9 @@ router.route('/') /** POST /api/v1/documents - Create document */ .post(_auth2.default.verifyToken, _documents2.default.createDocument); + +router.route('/:id') +/** PUT /api/v1/documents/id - Create document */ +.put(_auth2.default.verifyToken, _documents2.default.updateDocument); + exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index e748b17..2ede70e 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -37,4 +37,34 @@ function createDocument(req, res) { } } -export default { createDocument }; +function updateDocument(req, res) { + if (isNaN(req.params.id)) { + return res.status(400); + } + const docId = Number(req.params.id); + return Document.findById(docId) + .then((document) => { + if (!document) { + return res.status(404).send({ + message: 'Document Not Found' + }); + } + if (Number(document.userId) !== Number(req.decoded.id)) { + return res.status(401).json({ + message: 'You are not authorized to edit this document' + }); + } + return document + .update({ + title: req.body.title || document.title, + content: req.body.content || document.content, + access: req.body.value || document.access, + userId: req.body.userId || document.userId + }) + .then(() => res.status(200).send(document)) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); +} + +export default { createDocument, updateDocument }; diff --git a/server/routes/documents.js b/server/routes/documents.js index 82b0cd8..cfd2c6c 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -10,4 +10,9 @@ router.route('/') /** POST /api/v1/documents - Create document */ .post(auth.verifyToken, documentController.createDocument); + +router.route('/:id') + /** PUT /api/v1/documents/id - Create document */ + .put(auth.verifyToken, documentController.updateDocument); + export default router; From 22847557b6badf7256bafba8b04283e672591cbf Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 19:28:17 +0100 Subject: [PATCH 24/98] get all documents and paginations --- dist/server/controllers/documents.js | 60 +++++++++++++++++++++++++++- dist/server/routes/documents.js | 2 +- server/controllers/documents.js | 58 ++++++++++++++++++++++++++- server/routes/documents.js | 2 +- 4 files changed, 118 insertions(+), 4 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index 841ce4a..7ad8802 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -85,4 +85,62 @@ function updateDocument(req, res) { }); } -exports.default = { createDocument: createDocument, updateDocument: updateDocument }; \ No newline at end of file +function getAllDocument(req, res) { + var limit = req.query.limit; + var offset = req.query.offset; + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + access: { + $ne: 'private' + } + }, + include: [{ + model: User, + attributes: ['userName', 'roleId'] + }] + }).then(function (_ref) { + var document = _ref.rows, + count = _ref.count; + + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + include: [{ + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + } + }], + where: { + access: { + $ne: 'private' + } + } + + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +exports.default = { createDocument: createDocument, updateDocument: updateDocument, getAllDocument: getAllDocument }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index 0824527..be28eaf 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -22,7 +22,7 @@ var router = _express2.default.Router(); router.route('/') /** GET /api/v1/documents - Get all documents */ -// .get(documentController.getDocuments) +.get(_auth2.default.verifyToken, _documents2.default.getAllDocument) /** POST /api/v1/documents - Create document */ .post(_auth2.default.verifyToken, _documents2.default.createDocument); diff --git a/server/controllers/documents.js b/server/controllers/documents.js index 2ede70e..394fddc 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -67,4 +67,60 @@ function updateDocument(req, res) { .catch(error => res.status(400).send(error)); } -export default { createDocument, updateDocument }; +function getAllDocument(req, res) { + const limit = req.query.limit; + const offset = req.query.offset; + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit, + offset, + where: { + access: { + $ne: 'private' + } + }, + include: [ + { + model: User, + attributes: ['userName', 'roleId'] + } + ] + }) + .then(({ rows: document, count }) => { + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit, + offset, + include: [ + { + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + }, + }, + ], + where: { + access: { + $ne: 'private' + } + }, + + }) + .then(({ rows: document, count }) => { + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } +} + +export default { createDocument, updateDocument, getAllDocument }; diff --git a/server/routes/documents.js b/server/routes/documents.js index cfd2c6c..b34098e 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -6,7 +6,7 @@ const router = express.Router(); router.route('/') /** GET /api/v1/documents - Get all documents */ - // .get(documentController.getDocuments) + .get(auth.verifyToken, documentController.getAllDocument) /** POST /api/v1/documents - Create document */ .post(auth.verifyToken, documentController.createDocument); From c3a090496675aa49a495bcad11701436e8284d82 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 20:02:35 +0100 Subject: [PATCH 25/98] add the functionality to find document base on a user access type --- dist/server/controllers/documents.js | 40 +++++++++++++++++++++++++- dist/server/routes/documents.js | 8 +++++- server/controllers/documents.js | 43 +++++++++++++++++++++++++++- server/routes/documents.js | 8 +++++- 4 files changed, 95 insertions(+), 4 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index 7ad8802..1341c9c 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -143,4 +143,42 @@ function getAllDocument(req, res) { } } -exports.default = { createDocument: createDocument, updateDocument: updateDocument, getAllDocument: getAllDocument }; \ No newline at end of file +function findDocument(req, res) { + return Document.findById(req.params.id).then(function (document) { + if (!document) { + return res.status(404).json({ + message: 'Document not found' + }); + } + if (req.decoded.roleId === 1) { + return res.json(document); + } + if (document.access === 'public') { + res.status(200).send(document); + } + if (document.access === 'private') { + if (document.userId !== req.decoded.id) { + res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + } + if (document.access === 'role') { + return _models2.default.User.findById(document.userId).then(function (documentAuthor) { + if (Number(documentAuthor.roleId) !== Number(req.decoded.roleId)) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + }).catch(function (error) { + return res.status(400).send(error); + }); + } + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { createDocument: createDocument, updateDocument: updateDocument, getAllDocument: getAllDocument, findDocument: findDocument }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index be28eaf..f229db6 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -29,6 +29,12 @@ router.route('/') router.route('/:id') /** PUT /api/v1/documents/id - Create document */ -.put(_auth2.default.verifyToken, _documents2.default.updateDocument); +.put(_auth2.default.verifyToken, _documents2.default.updateDocument) + +/** GET /api/v1/documents/id - get document */ +.get(_auth2.default.verifyToken, _documents2.default.findDocument); + +/** DELETE /api/v1/documents/id - delete document */ +// .delete(auth.verifyToken, documentController.deleteDocument); exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index 394fddc..9bc4f99 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -123,4 +123,45 @@ function getAllDocument(req, res) { } } -export default { createDocument, updateDocument, getAllDocument }; +function findDocument(req, res) { + return Document.findById(req.params.id) + .then((document) => { + if (!document) { + return res.status(404).json({ + message: 'Document not found' + }); + } + if (req.decoded.roleId === 1) { + return res.json(document); + } + if (document.access === 'public') { + res.status(200).send(document); + } + if (document.access === 'private') { + if (document.userId !== req.decoded.id) { + res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + } + if (document.access === 'role') { + return models.User + .findById(document.userId) + .then((documentAuthor) => { + if ( + Number(documentAuthor.roleId) !== Number(req.decoded.roleId) + ) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + }) + .catch(error => res.status(400).send(error)); + } + }) + .catch(error => res.status(400).send(error)); +} + +export default { createDocument, updateDocument, getAllDocument, findDocument }; diff --git a/server/routes/documents.js b/server/routes/documents.js index b34098e..1115655 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -13,6 +13,12 @@ router.route('/') router.route('/:id') /** PUT /api/v1/documents/id - Create document */ - .put(auth.verifyToken, documentController.updateDocument); + .put(auth.verifyToken, documentController.updateDocument) + + /** GET /api/v1/documents/id - get document */ + .get(auth.verifyToken, documentController.findDocument); + + /** DELETE /api/v1/documents/id - delete document */ + // .delete(auth.verifyToken, documentController.deleteDocument); export default router; From f85428a7c98dd365d48441d5b54d0c66961c183b Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 20:13:14 +0100 Subject: [PATCH 26/98] feat(find-delete): find-delete - ensure user can find and view document based on public on private access - ensure user can can delete only document associated to the userid [Finishes #149367289] --- dist/server/controllers/documents.js | 32 +++++++++++++++++++++++++- dist/server/routes/documents.js | 4 ++-- server/controllers/documents.js | 34 +++++++++++++++++++++++++++- server/routes/documents.js | 4 ++-- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index 1341c9c..4987f0d 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -181,4 +181,34 @@ function findDocument(req, res) { }); } -exports.default = { createDocument: createDocument, updateDocument: updateDocument, getAllDocument: getAllDocument, findDocument: findDocument }; \ No newline at end of file +function deleteDocument(req, res) { + return Document.findById(req.params.id).then(function (document) { + if (!document) { + return res.status(404).send({ + message: 'Document Not Found' + }); + } + if (req.decoded.roleId !== 1 && Number(document.userId) !== Number(req.decoded.id)) { + return res.status(401).json({ + message: 'You are not authorized to delete this document' + }); + } + return document.destroy().then(function () { + return res.status(204).send({ + message: 'Document successfully deleted' + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { + createDocument: createDocument, + updateDocument: updateDocument, + getAllDocument: getAllDocument, + findDocument: findDocument, + deleteDocument: deleteDocument +}; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index f229db6..f57376c 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -32,9 +32,9 @@ router.route('/:id') .put(_auth2.default.verifyToken, _documents2.default.updateDocument) /** GET /api/v1/documents/id - get document */ -.get(_auth2.default.verifyToken, _documents2.default.findDocument); +.get(_auth2.default.verifyToken, _documents2.default.findDocument) /** DELETE /api/v1/documents/id - delete document */ -// .delete(auth.verifyToken, documentController.deleteDocument); +.delete(_auth2.default.verifyToken, _documents2.default.deleteDocument); exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index 9bc4f99..b970ac3 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -164,4 +164,36 @@ function findDocument(req, res) { .catch(error => res.status(400).send(error)); } -export default { createDocument, updateDocument, getAllDocument, findDocument }; +function deleteDocument(req, res) { + return Document.findById(req.params.id) + .then((document) => { + if (!document) { + return res.status(404).send({ + message: 'Document Not Found' + }); + } + if ( + req.decoded.roleId !== 1 && + Number(document.userId) !== Number(req.decoded.id) + ) { + return res.status(401).json({ + message: 'You are not authorized to delete this document' + }); + } + return document + .destroy() + .then(() => res.status(204).send({ + message: 'Document successfully deleted' + })) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); +} + +export default { + createDocument, + updateDocument, + getAllDocument, + findDocument, + deleteDocument +}; diff --git a/server/routes/documents.js b/server/routes/documents.js index 1115655..3224ec3 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -16,9 +16,9 @@ router.route('/:id') .put(auth.verifyToken, documentController.updateDocument) /** GET /api/v1/documents/id - get document */ - .get(auth.verifyToken, documentController.findDocument); + .get(auth.verifyToken, documentController.findDocument) /** DELETE /api/v1/documents/id - delete document */ - // .delete(auth.verifyToken, documentController.deleteDocument); + .delete(auth.verifyToken, documentController.deleteDocument); export default router; From f6c304a610455471be7572b62b2dd8843bd27fc8 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 23 Jul 2017 20:17:58 +0100 Subject: [PATCH 27/98] feat(find-delete): find-delete - ensure user can find and view document based on public on private access - ensure user can can delete only document associated to the userid [Finishes #149367289] --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2752eb9..6e267fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ .DS_Store +.env From 5e123af6e629a9076f9115a87cfccaa186d13d01 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Tue, 25 Jul 2017 22:38:27 +0100 Subject: [PATCH 28/98] find user document --- dist/server/controllers/users.js | 5 ++++- dist/server/routes/users.js | 4 ++++ server/controllers/users.js | 7 ++++++- server/routes/users.js | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 86ff844..c7035fd 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -217,11 +217,14 @@ function deleteUser(req, res) { }); } +function findUserDocument(req, res) {} + exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser, updateUser: updateUser, - deleteUser: deleteUser + deleteUser: deleteUser, + findUserDocument: findUserDocument }; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 73b8288..cb6c0b1 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -41,4 +41,8 @@ router.route('/:id') /** DELETE /api/users/id - delete users */ .delete(_auth2.default.verifyToken, _users2.default.deleteUser); +router.route('/:id/documents') +/** GET /api/users/id/documents - Find documents of a specific user*/ +.get(_auth2.default.verifyToken, _users2.default.findUserDocument); + exports.default = router; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js index b48fb60..a339371 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -204,11 +204,16 @@ function deleteUser(req, res) { .catch(error => res.status(400).send(error)); } +function findUserDocument(req, res) { + +} + export default { getUsers, createUser, login, findUser, updateUser, - deleteUser + deleteUser, + findUserDocument }; diff --git a/server/routes/users.js b/server/routes/users.js index 5f74cc5..42fe7da 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -25,4 +25,8 @@ router.route('/:id') /** DELETE /api/users/id - delete users */ .delete(auth.verifyToken, userController.deleteUser); +router.route('/:id/documents') + /** GET /api/users/id/documents - Find documents of a specific user*/ + .get(auth.verifyToken, userController.findUserDocument); + export default router; From ad54e5a04778a698d92666843e651deb5781d131 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Tue, 25 Jul 2017 22:51:41 +0100 Subject: [PATCH 29/98] feat(getalluserdoc)get-user-documents - ensure all document associated to a user Id is retrieved [Footer #149530895] --- dist/server/controllers/users.js | 34 ++++++++++++++++++++++++++++++-- dist/server/routes/users.js | 2 +- server/controllers/users.js | 31 ++++++++++++++++++++++++++--- server/routes/users.js | 2 +- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index c7035fd..e80105b 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -26,6 +26,7 @@ require('dotenv').config(); var jwtSecret = process.env.JWT_SECRET; var User = _models2.default.User; +var Document = _models2.default.Document; var metaData = _helper2.default.paginationMetaData; function getUsers(req, res) { @@ -217,7 +218,36 @@ function deleteUser(req, res) { }); } -function findUserDocument(req, res) {} +function getUserDocuments(req, res) { + var limit = req.query.limit; + var offset = req.query.offset; + User.findById(req.params.id).then(function (user) { + if (!user) { + return res.status(404).json({ + message: 'User not found' + }); + } + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + userId: user.id + } + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} exports.default = { getUsers: getUsers, @@ -226,5 +256,5 @@ exports.default = { findUser: findUser, updateUser: updateUser, deleteUser: deleteUser, - findUserDocument: findUserDocument + getUserDocuments: getUserDocuments }; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index cb6c0b1..4eb365a 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -43,6 +43,6 @@ router.route('/:id') router.route('/:id/documents') /** GET /api/users/id/documents - Find documents of a specific user*/ -.get(_auth2.default.verifyToken, _users2.default.findUserDocument); +.get(_auth2.default.verifyToken, _users2.default.getUserDocuments); exports.default = router; \ No newline at end of file diff --git a/server/controllers/users.js b/server/controllers/users.js index a339371..229adb3 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -8,6 +8,7 @@ require('dotenv').config(); const jwtSecret = process.env.JWT_SECRET; const User = models.User; +const Document = models.Document; const metaData = helper.paginationMetaData; function getUsers(req, res) { @@ -204,8 +205,32 @@ function deleteUser(req, res) { .catch(error => res.status(400).send(error)); } -function findUserDocument(req, res) { - +function getUserDocuments(req, res) { + const limit = req.query.limit; + const offset = req.query.offset; + User.findById(req.params.id) + .then((user) => { + if (!user) { + return res.status(404).json({ + message: 'User not found' + }); + } + return Document.findAndCountAll({ + limit, + offset, + where: { + userId: user.id + } + }) + .then(({ rows: document, count }) => { + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); } export default { @@ -215,5 +240,5 @@ export default { findUser, updateUser, deleteUser, - findUserDocument + getUserDocuments }; diff --git a/server/routes/users.js b/server/routes/users.js index 42fe7da..e1bb222 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -27,6 +27,6 @@ router.route('/:id') router.route('/:id/documents') /** GET /api/users/id/documents - Find documents of a specific user*/ - .get(auth.verifyToken, userController.findUserDocument); + .get(auth.verifyToken, userController.getUserDocuments); export default router; From 5e0dc2f944eda7e902f5f308018ce954da092e4c Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Wed, 26 Jul 2017 00:09:20 +0100 Subject: [PATCH 30/98] feat(search): search-document - ensure user can search using a search input - ensure user can only see public documents when searching [Footer #149534905] --- dist/server/controllers/documents.js | 2 +- dist/server/controllers/search.js | 83 +++++++++++++++++++++++++++- dist/server/models/document.js | 14 ++--- dist/server/models/user.js | 26 ++++----- dist/server/routes/search.js | 6 +- server/controllers/documents.js | 2 +- server/controllers/search.js | 81 ++++++++++++++++++++++++++- server/models/document.js | 14 ++--- server/models/user.js | 26 ++++----- server/routes/search.js | 6 +- 10 files changed, 204 insertions(+), 56 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index 4987f0d..e6d4e21 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -14,8 +14,8 @@ var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var Document = _models2.default.Document; var User = _models2.default.User; +var Document = _models2.default.Document; var metaData = _helper2.default.paginationMetaData; function createDocument(req, res) { diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js index d5d4518..1a9145b 100644 --- a/dist/server/controllers/search.js +++ b/dist/server/controllers/search.js @@ -15,6 +15,7 @@ var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var User = _models2.default.User; +var Document = _models2.default.Document; var metaData = _helper2.default.paginationMetaData; function searchUser(req, res) { @@ -51,4 +52,84 @@ function searchUser(req, res) { }); } -exports.default = { searchUser: searchUser }; \ No newline at end of file +function searchDocuments(req, res) { + var limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + }, + include: [{ + model: User, + attributes: ['userName', 'roleId'] + }] + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + if (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + include: [{ + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + } + }], + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + } + + }).then(function (_ref3) { + var document = _ref3.rows, + count = _ref3.count; + + if (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/models/document.js b/dist/server/models/document.js index edd6894..d204122 100644 --- a/dist/server/models/document.js +++ b/dist/server/models/document.js @@ -19,15 +19,11 @@ module.exports = function (sequelize, DataTypes) { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - } - } }); + Document.associate = function (models) { + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + }; return Document; }; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js index e4a24e8..def997e 100644 --- a/dist/server/models/user.js +++ b/dist/server/models/user.js @@ -25,21 +25,17 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, defaultvalue: 2 } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - } - } }); + User.associate = function (models) { + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId', + onDelete: 'CASCADE' + }); + }; return User; }; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js index cf4eb95..ea6c0e2 100644 --- a/dist/server/routes/search.js +++ b/dist/server/routes/search.js @@ -21,9 +21,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var router = _express2.default.Router(); router.route('/users') -/** GET /api/users - Get list of users */ +/** GET /api/v1/users - search list of users */ .get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); -/** POST /api/users - Create/Signup users */ +router.route('/documents') +/** GET /api/v1/search - search list of documents */ +.get(_auth2.default.verifyToken, _search2.default.searchDocuments); exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index b970ac3..cdd1941 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -1,8 +1,8 @@ import helper from '../helpers/helper'; import models from '../models'; -const Document = models.Document; const User = models.User; +const Document = models.Document; const metaData = helper.paginationMetaData; function createDocument(req, res) { diff --git a/server/controllers/search.js b/server/controllers/search.js index 39c595d..af826db 100644 --- a/server/controllers/search.js +++ b/server/controllers/search.js @@ -2,6 +2,7 @@ import helper from '../helpers/helper'; import models from '../models'; const User = models.User; +const Document = models.Document; const metaData = helper.paginationMetaData; function searchUser(req, res) { @@ -34,4 +35,82 @@ function searchUser(req, res) { }).catch(error => res.status(400).send(error)); } -export default { searchUser }; +function searchDocuments(req, res) { + const limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit, + offset, + where: { + access: { + $ne: 'private' + }, + title: { + $like: `%${queryString}%` + } + }, + include: [ + { + model: User, + attributes: ['userName', 'roleId'] + } + ] + }) + .then(({ rows: document, count }) => { + if (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); + } + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit, + offset, + include: [ + { + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + }, + }, + ], + where: { + access: { + $ne: 'private' + }, + title: { + $like: `%${queryString}%` + } + }, + + }) + .then(({ rows: document, count }) => { + if (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); + } + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } +} + +export default { searchUser, searchDocuments }; diff --git a/server/models/document.js b/server/models/document.js index 4c4cfd1..d7315ac 100644 --- a/server/models/document.js +++ b/server/models/document.js @@ -18,15 +18,11 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - } - } }); + Document.associate = (models) => { + Document.belongsTo(models.User, { + foreignKey: 'userId', + }); + }; return Document; }; diff --git a/server/models/user.js b/server/models/user.js index 3157132..908f44f 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -24,21 +24,17 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, defaultvalue: 2 } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - } - } }); + User.associate = (models) => { + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId', + onDelete: 'CASCADE' + }); + }; return User; }; diff --git a/server/routes/search.js b/server/routes/search.js index 4915745..ccca593 100644 --- a/server/routes/search.js +++ b/server/routes/search.js @@ -5,9 +5,11 @@ import auth from '../middlewares/auth'; const router = express.Router(); router.route('/users') - /** GET /api/users - Get list of users */ + /** GET /api/v1/users - search list of users */ .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); - /** POST /api/users - Create/Signup users */ +router.route('/documents') + /** GET /api/v1/search - search list of documents */ + .get(auth.verifyToken, searchController.searchDocuments); export default router; From edd9efed2411acf48023ac4e158cfb35735d09b7 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 27 Jul 2017 00:06:18 +0100 Subject: [PATCH 31/98] feat(roles): roles - ensure users can create roles - ensure user can view all roles [Finishes #149606559] --- dist/server/controllers/roles.js | 58 ++++++++++++++++++++++++++++++++ dist/server/models/role.js | 14 +++----- dist/server/routes/index.js | 5 +++ dist/server/routes/roles.js | 39 +++++++++++++++++++++ server/controllers/roles.js | 50 +++++++++++++++++++++++++++ server/models/role.js | 14 +++----- server/routes/index.js | 2 ++ server/routes/roles.js | 23 +++++++++++++ 8 files changed, 187 insertions(+), 18 deletions(-) create mode 100644 dist/server/controllers/roles.js create mode 100644 dist/server/routes/roles.js create mode 100644 server/controllers/roles.js create mode 100644 server/routes/roles.js diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js new file mode 100644 index 0000000..88b1181 --- /dev/null +++ b/dist/server/controllers/roles.js @@ -0,0 +1,58 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var models = require('../models'); + +var Role = models.Role; + +/** + * Creates a new Role. + * @param {object} req - role to be created + * @param {object} res - new created role + * @returns {object} - newly created role + */ +function createRole(req, res) { + req.check('title', 'Title is required').notEmpty(); + + var errors = req.validationErrors(); + if (errors) { + res.status(400).json({ errors: errors }); + } else { + Role.findAll({ + where: { title: req.body.title } + }).then(function (err, existingRole) { + if (!existingRole) { + Role.create({ + title: req.body.title + }).then(function (role) { + res.status(201).send({ + message: 'Role successfully created', + role: role + }); + }).catch(function (error) { + res.json(error.errors); + }); + } + }).catch(function (error) { + return res.json(error); + }); + } +} + +/** + * Get all roles. + * @param {void} req - no request body attached + * @param {array} res - an array of roles and their id + * @returns {array} array of roles + */ +function getRoles(req, res) { + return Role.findAll().then(function (role) { + return res.status(200).json(role); + }).catch(function (error) { + return res.json(error); + }); +} + +exports.default = { createRole: createRole, getRoles: getRoles }; \ No newline at end of file diff --git a/dist/server/models/role.js b/dist/server/models/role.js index 96e14a0..4979353 100644 --- a/dist/server/models/role.js +++ b/dist/server/models/role.js @@ -7,15 +7,11 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, unique: true } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - } - } }); + Role.associate = function (models) { + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + }; return Role; }; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index 7515895..1f4a3ec 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -20,6 +20,10 @@ var _documents = require('./documents'); var _documents2 = _interopRequireDefault(_documents); +var _roles = require('./roles'); + +var _roles2 = _interopRequireDefault(_roles); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); @@ -28,5 +32,6 @@ var router = _express2.default.Router(); router.use('/users', _users2.default); router.use('/search', _search2.default); router.use('/documents', _documents2.default); +router.use('/roles', _roles2.default); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/roles.js b/dist/server/routes/roles.js new file mode 100644 index 0000000..726a7f9 --- /dev/null +++ b/dist/server/routes/roles.js @@ -0,0 +1,39 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _roles = require('../controllers/roles'); + +var _roles2 = _interopRequireDefault(_roles); + +var _auth = require('../middlewares/auth'); + +var _auth2 = _interopRequireDefault(_auth); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +router.route('/') +/** GET /api/roles - Get list of roles */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.getRoles) + +/** POST /api/roles - Create roles */ +.post(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.createRole); + +// router.route('/:id') +// /** GET /api/users/roles - Find roles */ +// .get(auth.verifyToken, roleController.findRole) +// +// /** PUT /api/users/id - update roles */ +// .put(auth.verifyToken, roleController.updateRole) +// +// /** DELETE /api/users/id - delete roles */ +// .delete(auth.verifyToken, roleController.deleteRole); +exports.default = router; \ No newline at end of file diff --git a/server/controllers/roles.js b/server/controllers/roles.js new file mode 100644 index 0000000..a1c9731 --- /dev/null +++ b/server/controllers/roles.js @@ -0,0 +1,50 @@ +const models = require('../models'); + +const Role = models.Role; + +/** + * Creates a new Role. + * @param {object} req - role to be created + * @param {object} res - new created role + * @returns {object} - newly created role + */ +function createRole(req, res) { + req.check('title', 'Title is required').notEmpty(); + + const errors = req.validationErrors(); + if (errors) { + res.status(400).json({ errors }); + } else { + Role.findAll({ + where: { title: req.body.title } + }).then((err, existingRole) => { + if (!existingRole) { + Role.create({ + title: req.body.title + }).then((role) => { + res.status(201).send({ + message: 'Role successfully created', + role + }); + }).catch((error) => { + res.json(error.errors); + }); + } + }).catch(error => res.json(error)); + } +} + +/** + * Get all roles. + * @param {void} req - no request body attached + * @param {array} res - an array of roles and their id + * @returns {array} array of roles + */ +function getRoles(req, res) { + return Role + .findAll() + .then(role => res.status(200).json(role)) + .catch(error => res.json(error)); +} + +export default { createRole, getRoles }; diff --git a/server/models/role.js b/server/models/role.js index 986b172..f0351dc 100644 --- a/server/models/role.js +++ b/server/models/role.js @@ -6,15 +6,11 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, unique: true } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - } - } }); + Role.associate = (models) => { + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + }; return Role; }; diff --git a/server/routes/index.js b/server/routes/index.js index eb44098..fdde1f5 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -2,6 +2,7 @@ import express from 'express'; import userRoutes from './users'; import searchRoutes from './search'; import documentRoutes from './documents'; +import roleRoutes from './roles'; const router = express.Router(); @@ -10,5 +11,6 @@ const router = express.Router(); router.use('/users', userRoutes); router.use('/search', searchRoutes); router.use('/documents', documentRoutes); +router.use('/roles', roleRoutes); export default router; diff --git a/server/routes/roles.js b/server/routes/roles.js new file mode 100644 index 0000000..0a76c29 --- /dev/null +++ b/server/routes/roles.js @@ -0,0 +1,23 @@ +import express from 'express'; +import roleController from '../controllers/roles'; +import auth from '../middlewares/auth'; + +const router = express.Router(); + +router.route('/') + /** GET /api/roles - Get list of roles */ + .get(auth.verifyToken, auth.adminAccess, roleController.getRoles) + + /** POST /api/roles - Create roles */ + .post(auth.verifyToken, auth.adminAccess, roleController.createRole); + +// router.route('/:id') +// /** GET /api/users/roles - Find roles */ +// .get(auth.verifyToken, roleController.findRole) +// +// /** PUT /api/users/id - update roles */ +// .put(auth.verifyToken, roleController.updateRole) +// +// /** DELETE /api/users/id - delete roles */ +// .delete(auth.verifyToken, roleController.deleteRole); +export default router; From 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 27 Jul 2017 10:44:10 +0100 Subject: [PATCH 32/98] feat(roles): roles - ensure admin can find roles - ensure admin can delete roles [Finishes #149606559] --- dist/server/controllers/documents.js | 6 +-- dist/server/controllers/roles.js | 80 +++++++++++++++++++++++++++- dist/server/routes/roles.js | 19 +++---- server/controllers/documents.js | 4 +- server/controllers/roles.js | 80 +++++++++++++++++++++++++++- server/routes/roles.js | 19 +++---- 6 files changed, 183 insertions(+), 25 deletions(-) diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index e6d4e21..8343bfb 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -39,14 +39,14 @@ function createDocument(req, res) { content: req.body.content, access: req.body.value, userId: req.body.userId - }).then(function (documentResponse) { - return res.status(201).send(documentResponse); + }).then(function () { + return res.status(200).send(document); }).catch(function (error) { return res.status(400).send(error); }); } return res.status(403).json({ - title: 'Document already exists' + message: 'Document already exists' }); }).catch(function (error) { return res.status(400).send(error); diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js index 88b1181..0f9a564 100644 --- a/dist/server/controllers/roles.js +++ b/dist/server/controllers/roles.js @@ -55,4 +55,82 @@ function getRoles(req, res) { }); } -exports.default = { createRole: createRole, getRoles: getRoles }; \ No newline at end of file +/** + * Find roles by Id. + * @param {number} req - requested role + * @param {object} res - role found by id + * @returns {object} - role found by id + */ +function findRole(req, res) { + return Role.findById(req.params.id).then(function (role) { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(function (error) { + return res.status(400).json(error); + }); +} + +/** + * Update role. + * @param {number} req - requested role by id + * @param {object} res - updated role + * @returns {object} - updated role status + */ +function updateRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id).then(function (role) { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + return role.update({ + title: req.body.title || role.title + }).then(function () { + return res.status(200).json({ + message: 'Role updated successfully', + role: role + }); + }).catch(function (error) { + return res.status(400).json(error); + }); + }).catch(function (error) { + return res.status(400).json(error); + }); +} + +/** + * Delete roles by Id. + * @param {number} req - role to be deleted by id + * @param {object} res - deleted role + * @returns {object} - message + */ +function deleteRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id).then(function (role) { + if (!role) { + res.status(404).json({ + message: 'Role not found' + }); + } + return role.destroy().then(function () { + return res.status(204).send({ + message: 'Role deleted successfully' + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.json(error); + }); +} + +exports.default = { createRole: createRole, getRoles: getRoles, findRole: findRole, updateRole: updateRole, deleteRole: deleteRole }; \ No newline at end of file diff --git a/dist/server/routes/roles.js b/dist/server/routes/roles.js index 726a7f9..63ea87b 100644 --- a/dist/server/routes/roles.js +++ b/dist/server/routes/roles.js @@ -27,13 +27,14 @@ router.route('/') /** POST /api/roles - Create roles */ .post(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.createRole); -// router.route('/:id') -// /** GET /api/users/roles - Find roles */ -// .get(auth.verifyToken, roleController.findRole) -// -// /** PUT /api/users/id - update roles */ -// .put(auth.verifyToken, roleController.updateRole) -// -// /** DELETE /api/users/id - delete roles */ -// .delete(auth.verifyToken, roleController.deleteRole); +router.route('/:id') +/** GET /api/users/roles - Find roles */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.findRole) + +/** PUT /api/users/id - update roles */ +.put(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.updateRole) + +/** DELETE /api/users/id - delete roles */ +.delete(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.deleteRole); + exports.default = router; \ No newline at end of file diff --git a/server/controllers/documents.js b/server/controllers/documents.js index cdd1941..3faf6c6 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -27,11 +27,11 @@ function createDocument(req, res) { access: req.body.value, userId: req.body.userId }) - .then(documentResponse => res.status(201).send(documentResponse)) + .then(() => res.status(200).send(document)) .catch(error => res.status(400).send(error)); } return res.status(403).json({ - title: 'Document already exists' + message: 'Document already exists' }); }).catch(error => res.status(400).send(error)); } diff --git a/server/controllers/roles.js b/server/controllers/roles.js index a1c9731..5550d72 100644 --- a/server/controllers/roles.js +++ b/server/controllers/roles.js @@ -47,4 +47,82 @@ function getRoles(req, res) { .catch(error => res.json(error)); } -export default { createRole, getRoles }; +/** + * Find roles by Id. + * @param {number} req - requested role + * @param {object} res - role found by id + * @returns {object} - role found by id + */ +function findRole(req, res) { + return Role + .findById(req.params.id) + .then((role) => { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(error => res.status(400).json(error)); +} + +/** + * Update role. + * @param {number} req - requested role by id + * @param {object} res - updated role + * @returns {object} - updated role status + */ +function updateRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401) + .json({ message: 'You are not authorized to access the role' }); + } + return Role + .findById(req.params.id) + .then((role) => { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + return role + .update({ + title: req.body.title || role.title + }) + .then(() => res.status(200).json({ + message: 'Role updated successfully', + role + })) + .catch(error => res.status(400).json(error)); + }).catch(error => res.status(400).json(error)); +} + +/** + * Delete roles by Id. + * @param {number} req - role to be deleted by id + * @param {object} res - deleted role + * @returns {object} - message + */ +function deleteRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401) + .json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id) + .then((role) => { + if (!role) { + res.status(404).json({ + message: 'Role not found' + }); + } + return role + .destroy() + .then(() => res.status(204) + .send({ + message: 'Role deleted successfully' + })) + .catch(error => res.status(400).send(error)); + }).catch(error => res.json(error)); +} + +export default { createRole, getRoles, findRole, updateRole, deleteRole }; diff --git a/server/routes/roles.js b/server/routes/roles.js index 0a76c29..a42e59f 100644 --- a/server/routes/roles.js +++ b/server/routes/roles.js @@ -11,13 +11,14 @@ router.route('/') /** POST /api/roles - Create roles */ .post(auth.verifyToken, auth.adminAccess, roleController.createRole); -// router.route('/:id') -// /** GET /api/users/roles - Find roles */ -// .get(auth.verifyToken, roleController.findRole) -// -// /** PUT /api/users/id - update roles */ -// .put(auth.verifyToken, roleController.updateRole) -// -// /** DELETE /api/users/id - delete roles */ -// .delete(auth.verifyToken, roleController.deleteRole); +router.route('/:id') + /** GET /api/users/roles - Find roles */ + .get(auth.verifyToken, auth.adminAccess, roleController.findRole) + + /** PUT /api/users/id - update roles */ + .put(auth.verifyToken, auth.adminAccess, roleController.updateRole) + + /** DELETE /api/users/id - delete roles */ + .delete(auth.verifyToken, auth.adminAccess, roleController.deleteRole); + export default router; From 6f9bb3203d143b9a7b9586cce2a48b8444c62419 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 27 Jul 2017 13:58:03 +0100 Subject: [PATCH 33/98] feature(testing routes): routes - add document routes for getting a user document - add route for deleting user document [Finishes #149632847] --- .sequelizerc | 2 +- dist/gulpfile.babel.js | 11 +++ dist/index.js | 2 +- dist/server/controllers/roles.js | 136 +++++++++++++++++++++++++++++++ dist/server/routes/roles.js | 40 +++++++++ dist/server/test/index.spec.js | 10 +++ gulpfile.babel.js | 9 ++ index.js | 2 +- package.json | 12 ++- server/controllers/documents.js | 100 ++++++++++++++++++++++- server/controllers/roles.js | 128 +++++++++++++++++++++++++++++ server/controllers/search.js | 90 +++++++++++++++++++- server/controllers/users.js | 75 ++++++++++++++++- server/routes/documents.js | 8 +- server/routes/roles.js | 24 ++++++ server/routes/search.js | 4 +- server/routes/users.js | 4 + server/test/index.spec.js | 8 ++ 18 files changed, 654 insertions(+), 11 deletions(-) create mode 100644 dist/server/controllers/roles.js create mode 100644 dist/server/routes/roles.js create mode 100644 dist/server/test/index.spec.js create mode 100644 server/controllers/roles.js create mode 100644 server/routes/roles.js create mode 100644 server/test/index.spec.js diff --git a/.sequelizerc b/.sequelizerc index e6029e9..352fb29 100644 --- a/.sequelizerc +++ b/.sequelizerc @@ -1,7 +1,7 @@ const path = require('path'); module.exports = { - "config": path.resolve('./server/config', 'config.json'), + "config": path.resolve('./server/config', 'config.js'), "models-path": path.resolve('./server/models'), "seeders-path": path.resolve('./server/seeders'), "migrations-path": path.resolve('./server/migrations') diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index 210b328..566dff4 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -4,6 +4,10 @@ var _gulp = require('gulp'); var _gulp2 = _interopRequireDefault(_gulp); +var _gulpMocha = require('gulp-mocha'); + +var _gulpMocha2 = _interopRequireDefault(_gulpMocha); + var _gulpLoadPlugins = require('gulp-load-plugins'); var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); @@ -26,6 +30,12 @@ _gulp2.default.task('babel', function () { return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); }); +_gulp2.default.task('mochaTest', function () { + _gulp2.default.src(['dist/server/test/**/*.js']).pipe((0, _gulpMocha2.default)({ + reporter: 'spec' + })); +}); + // Start server with restart on file change events _gulp2.default.task('nodemon', ['babel'], function () { return plugins.nodemon({ @@ -36,4 +46,5 @@ _gulp2.default.task('nodemon', ['babel'], function () { }); }); +_gulp2.default.task('test', ['mochaTest']); _gulp2.default.task('default', ['nodemon']); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 32c726d..a6d24a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,6 +8,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var port = process.env.PORT || 3000; -_express2.default.listen(port, function () { +module.exports = _express2.default.listen(port, function () { console.log('API Server started and listening on port 3000'); }); \ No newline at end of file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js new file mode 100644 index 0000000..9fd7ab2 --- /dev/null +++ b/dist/server/controllers/roles.js @@ -0,0 +1,136 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var models = require('../models'); + +var Role = models.Role; + +/** + * Creates a new Role. + * @param {object} req - role to be created + * @param {object} res - new created role + * @returns {object} - newly created role + */ +function createRole(req, res) { + req.check('title', 'Title is required').notEmpty(); + + var errors = req.validationErrors(); + if (errors) { + res.status(400).json({ errors: errors }); + } else { + Role.findAll({ + where: { title: req.body.title } + }).then(function (err, existingRole) { + if (!existingRole) { + Role.create({ + title: req.body.title + }).then(function (role) { + res.status(201).send({ + message: 'Role successfully created', + role: role + }); + }).catch(function (error) { + res.json(error.errors); + }); + } + }).catch(function (error) { + return res.json(error); + }); + } +} + +/** + * Get all roles. + * @param {void} req - no request body attached + * @param {array} res - an array of roles and their id + * @returns {array} array of roles + */ +function getRoles(req, res) { + return Role.findAll().then(function (role) { + return res.status(200).json(role); + }).catch(function (error) { + return res.json(error); + }); +} + +/** + * Find roles by Id. + * @param {number} req - requested role + * @param {object} res - role found by id + * @returns {object} - role found by id + */ +function findRole(req, res) { + return Role.findById(req.params.id).then(function (role) { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(function (error) { + return res.status(400).json(error); + }); +} + +/** + * Update role. + * @param {number} req - requested role by id + * @param {object} res - updated role + * @returns {object} - updated role status + */ +function updateRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id).then(function (role) { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + return role.update({ + title: req.body.title || role.title + }).then(function () { + return res.status(200).json({ + message: 'Role updated successfully', + role: role + }); + }).catch(function (error) { + return res.status(400).json(error); + }); + }).catch(function (error) { + return res.status(400).json(error); + }); +} + +/** + * Delete roles by Id. + * @param {number} req - role to be deleted by id + * @param {object} res - deleted role + * @returns {object} - message + */ +function deleteRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401).json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id).then(function (role) { + if (!role) { + res.status(404).json({ + message: 'Role not found' + }); + } + return role.destroy().then(function () { + return res.status(204).json({ + message: 'Role deleted successfully' + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.json(error); + }); +} + +exports.default = { createRole: createRole, getRoles: getRoles, findRole: findRole, updateRole: updateRole, deleteRole: deleteRole }; \ No newline at end of file diff --git a/dist/server/routes/roles.js b/dist/server/routes/roles.js new file mode 100644 index 0000000..63ea87b --- /dev/null +++ b/dist/server/routes/roles.js @@ -0,0 +1,40 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _express = require('express'); + +var _express2 = _interopRequireDefault(_express); + +var _roles = require('../controllers/roles'); + +var _roles2 = _interopRequireDefault(_roles); + +var _auth = require('../middlewares/auth'); + +var _auth2 = _interopRequireDefault(_auth); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var router = _express2.default.Router(); + +router.route('/') +/** GET /api/roles - Get list of roles */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.getRoles) + +/** POST /api/roles - Create roles */ +.post(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.createRole); + +router.route('/:id') +/** GET /api/users/roles - Find roles */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.findRole) + +/** PUT /api/users/id - update roles */ +.put(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.updateRole) + +/** DELETE /api/users/id - delete roles */ +.delete(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.deleteRole); + +exports.default = router; \ No newline at end of file diff --git a/dist/server/test/index.spec.js b/dist/server/test/index.spec.js new file mode 100644 index 0000000..4a1eedb --- /dev/null +++ b/dist/server/test/index.spec.js @@ -0,0 +1,10 @@ +'use strict'; + +process.env.NODE_ENV = 'test'; +var chai = require('chai'); +var chaiHttp = require('chai-http'); +var server = require('../../index'); + +var should = chai.should(); + +chai.use(chaiHttp); \ No newline at end of file diff --git a/gulpfile.babel.js b/gulpfile.babel.js index b66ffde..c2d6716 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,4 +1,5 @@ import gulp from 'gulp'; +import mocha from 'gulp-mocha'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; @@ -17,6 +18,13 @@ gulp.task('babel', () => .pipe(gulp.dest('dist')) ); +gulp.task('mochaTest', () => { + gulp.src(['dist/server/test/**/*.js']) + .pipe(mocha({ + reporter: 'spec', + })); +}); + // Start server with restart on file change events gulp.task('nodemon', ['babel'], () => plugins.nodemon({ @@ -27,4 +35,5 @@ gulp.task('nodemon', ['babel'], () => }) ); +gulp.task('test', ['mochaTest']); gulp.task('default', ['nodemon']); diff --git a/index.js b/index.js index e81e308..ed93dc4 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,6 @@ import app from './server/config/express'; const port = process.env.PORT || 3000; -app.listen(port, () => { +module.exports = app.listen(port, () => { console.log('API Server started and listening on port 3000'); }); diff --git a/package.json b/package.json index d96b323..109bcaa 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "document-manager", "version": "1.0.0", "description": "", - "main": "server/index.js", + "main": "index.js", "scripts": { "start": "node node_modules/gulp/bin/gulp", - "test": "echo \"Error: no test specified\" && exit 1", + "test": "node node_modules/gulp/bin/gulp test", "postinstall": "node node_modules/gulp/bin/gulp production" }, "repository": { @@ -35,7 +35,9 @@ "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", "gulp-nodemon": "^2.2.1", + "gulp-mocha": "^4.3.1", "jsonwebtoken": "^7.4.1", + "mocha": "^3.4.2", "morgan": "^1.8.2", "pg": "^6.4.0", "pg-hstore": "^2.3.2", @@ -45,12 +47,16 @@ "devDependencies": { "babel-core": "^6.25.0", "babel-preset-es2015": "^6.24.1", + "chai": "^4.1.0", + "chai-http": "^3.0.0", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", - "gulp-nodemon": "^2.2.1" + "gulp-mocha": "^4.3.1", + "gulp-nodemon": "^2.2.1", + "mocha": "^3.4.2" } } diff --git a/server/controllers/documents.js b/server/controllers/documents.js index 394fddc..eb61020 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -5,6 +5,12 @@ const Document = models.Document; const User = models.User; const metaData = helper.paginationMetaData; +/** + * Create documents for users + * @param {object} req - document to be created + * @param {object} res - created document + * @returns {object} - created document + */ function createDocument(req, res) { req.check('title', 'Title is required').notEmpty(); req.check('content', 'Content is required').notEmpty(); @@ -37,6 +43,12 @@ function createDocument(req, res) { } } +/** + * Update user document. + * @param {number} req - request id of the document to be updated + * @param {object} res - object of the updated document + * @returns {object} - updated document + */ function updateDocument(req, res) { if (isNaN(req.params.id)) { return res.status(400); @@ -67,6 +79,12 @@ function updateDocument(req, res) { .catch(error => res.status(400).send(error)); } +/** + * Get all documents + * @param {object} req - contains an object of the query, limits and offset + * @param {array} res - array of documents with pagination + * @returns {array} - array of documents + */ function getAllDocument(req, res) { const limit = req.query.limit; const offset = req.query.offset; @@ -123,4 +141,84 @@ function getAllDocument(req, res) { } } -export default { createDocument, updateDocument, getAllDocument }; +/** + * Find a document by Id + * @param {number} req - id of the requested document + * @param {object} res - object containg the requested document + * @returns {object} requested document + */ +function findDocument(req, res) { + return Document.findById(req.params.id) + .then((document) => { + if (!document) { + res.status(404).json({ message: 'Document not found' }); + } + if (req.decoded.roleId === 1) { + return document; + } + if (document.access === 'public') { + return res.status(200).send(document); + } + if (document.access === 'private') { + if (document.userId !== req.decoded.id) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + } + if (document.access === 'role') { + return models.User + .findById(document.userId) + .then((documentOwner) => { + if ( + Number(documentOwner.roleId) !== Number(req.decoded.roleId) + ) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + }) + .catch(error => res.status(400).send(error)); + } + }) + .catch(error => res.status(400).send(error)); +} + +/** + * + * Delete a document by Id + * @param {number} req - id of the requested document + * @param {object} res - message + * @returns {object} - message + */ +function deleteDocument(req, res) { + return Document.findById(req.params.id) + .then((document) => { + if (!document) { + res.status(404).json({ message: 'Document not found' }); + } + if ( + req.decoded.roleId !== 1 && + Number(document.userId) !== Number(req.decoded.id) + ) { + return res.status(401).json({ + message: 'You are not authorized to delete this document' + }); + } + return document + .destroy() + .then(() => res.status(204) + .send({ message: 'Document deleted successfully' })) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); +} + +export default { + createDocument, + updateDocument, + getAllDocument, + findDocument, + deleteDocument }; diff --git a/server/controllers/roles.js b/server/controllers/roles.js new file mode 100644 index 0000000..c2e4cb7 --- /dev/null +++ b/server/controllers/roles.js @@ -0,0 +1,128 @@ +const models = require('../models'); + +const Role = models.Role; + +/** + * Creates a new Role. + * @param {object} req - role to be created + * @param {object} res - new created role + * @returns {object} - newly created role + */ +function createRole(req, res) { + req.check('title', 'Title is required').notEmpty(); + + const errors = req.validationErrors(); + if (errors) { + res.status(400).json({ errors }); + } else { + Role.findAll({ + where: { title: req.body.title } + }).then((err, existingRole) => { + if (!existingRole) { + Role.create({ + title: req.body.title + }).then((role) => { + res.status(201).send({ + message: 'Role successfully created', + role + }); + }).catch((error) => { + res.json(error.errors); + }); + } + }).catch(error => res.json(error)); + } +} + +/** + * Get all roles. + * @param {void} req - no request body attached + * @param {array} res - an array of roles and their id + * @returns {array} array of roles + */ +function getRoles(req, res) { + return Role + .findAll() + .then(role => res.status(200).json(role)) + .catch(error => res.json(error)); +} + +/** + * Find roles by Id. + * @param {number} req - requested role + * @param {object} res - role found by id + * @returns {object} - role found by id + */ +function findRole(req, res) { + return Role + .findById(req.params.id) + .then((role) => { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(error => res.status(400).json(error)); +} + +/** + * Update role. + * @param {number} req - requested role by id + * @param {object} res - updated role + * @returns {object} - updated role status + */ +function updateRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401) + .json({ message: 'You are not authorized to access the role' }); + } + return Role + .findById(req.params.id) + .then((role) => { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + return role + .update({ + title: req.body.title || role.title + }) + .then(() => res.status(200).json({ + message: 'Role updated successfully', + role + })) + .catch(error => res.status(400).json(error)); + }).catch(error => res.status(400).json(error)); +} + +/** + * Delete roles by Id. + * @param {number} req - role to be deleted by id + * @param {object} res - deleted role + * @returns {object} - message + */ +function deleteRole(req, res) { + if (req.decoded.roleId !== 1) { + return res.status(401) + .json({ message: 'You are not authorized to access the role' }); + } + return Role.findById(req.params.id) + .then((role) => { + if (!role) { + res.status(404).json({ + message: 'Role not found' + }); + } + return role + .destroy() + .then(() => res.status(204) + .json({ + message: 'Role deleted successfully' + })) + .catch(error => res.status(400).send(error)); + }).catch(error => res.json(error)); +} + +export default { createRole, getRoles, findRole, updateRole, deleteRole }; diff --git a/server/controllers/search.js b/server/controllers/search.js index 39c595d..78d39a1 100644 --- a/server/controllers/search.js +++ b/server/controllers/search.js @@ -1,9 +1,16 @@ import helper from '../helpers/helper'; import models from '../models'; +const Document = models.Document; const User = models.User; const metaData = helper.paginationMetaData; +/** + * Search for user using a query string + * @param {string} req - search query of string + * @param {array} res - array of users + * @returns {array} - array users searched + */ function searchUser(req, res) { const searchQuery = req.query.q, limit = req.query.limit, @@ -34,4 +41,85 @@ function searchUser(req, res) { }).catch(error => res.status(400).send(error)); } -export default { searchUser }; +/** + * + * Search for documents by title + * @param {string} req - an object containing the query, offset and limit + * @param {array} res - an array containing searched document + * @returns {array} - searched document + */ +function searchDocuments(req, res) { + const limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit, + offset, + where: { + access: { + $ne: 'private' + }, + title: { + $like: `%${queryString}%` + } + }, + include: [ + { + model: User, + attributes: ['userName', 'roleId'] + } + ] + }) + .then(({ rows: document, count }) => { + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit, + offset, + include: [ + { + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + }, + }, + ], + where: { + access: { + $ne: 'private' + }, + title: { + $like: `%${queryString}%` + } + }, + + }) + .then(({ rows: document, count }) => { + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + } +} + +export default { searchUser, searchDocuments }; diff --git a/server/controllers/users.js b/server/controllers/users.js index b48fb60..9bb38be 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -7,9 +7,16 @@ import models from '../models'; require('dotenv').config(); const jwtSecret = process.env.JWT_SECRET; +const Document = models.Document; const User = models.User; const metaData = helper.paginationMetaData; +/** + * Get all users + * @param {number} req - limit and offset for getting all user + * @param {array} res - array of users or error + * @returns {array} - an array of users + */ function getUsers(req, res) { const limit = req.query.limit; const offset = req.query.offset; @@ -28,6 +35,12 @@ function getUsers(req, res) { .catch(error => res.status(400).send(error)); } +/** + * Create a user + * @param {object} req - request from user + * @param {object} res - newly created user or error + * @returns {object} - an object of a created user + */ function createUser(req, res) { req.check('fullName', 'FullName is required').notEmpty(); req.check('userName', 'userName is required').notEmpty(); @@ -69,6 +82,12 @@ function createUser(req, res) { } } +/** + * Log In user with JWT + * @param {object} req - request from log in user + * @param {object} res - authenicated user details + * @returns {object} - an object of the logged in user and a token + */ function login(req, res) { req.check('email', 'Email is required').notEmpty(); req.check('email', 'Please put a valid email').isEmail(); @@ -120,6 +139,12 @@ function login(req, res) { } } +/** + * Find a user by Id + * @param {number} req - request for user using the id of the user + * @param {object} res - an object of the user(s) found or error + * @returns {object} - an object of found user + */ function findUser(req, res) { const userQuery = Number(req.params.id); if ((req.decoded.id !== userQuery) && (req.decoded.roleId !== 1)) { @@ -143,6 +168,12 @@ function findUser(req, res) { .catch(error => res.status(400).send(error)); } +/** + *Update a user by Id + * @param {object} req - updated user object + * @param {object} res - updated user object or error + * @returns {object} - return an object of the updated user + */ function updateUser(req, res) { if (Number(req.decoded.id) !== Number(req.params.id)) { return res.status(401).json({ @@ -183,6 +214,12 @@ function updateUser(req, res) { }); } +/** + * Delete a user by Id + * @param {number} req - delete user with an id + * @param {object} res - message + * @returns {object} - null + */ function deleteUser(req, res) { if (req.decoded.roleId !== 1) { return res.status(401).json({ @@ -204,11 +241,47 @@ function deleteUser(req, res) { .catch(error => res.status(400).send(error)); } +/** + * + * Get documents for specific user + * @param {object} req - request object containing limit query and offset + * @param {array} res - array of documents for the requested user + * @return {array} - array of requested user's document + */ +function getUserDocuments(req, res) { + const limit = req.query.limit; + const offset = req.query.offset; + User.findById(req.params.id) + .then((user) => { + if (!user) { + return res.status(404).json({ + message: 'User not found' + }); + } + return Document.findAndCountAll({ + limit, + offset, + where: { + userId: user.id + } + }) + .then(({ rows: document, count }) => { + res.status(200).send({ + document, + pagination: metaData(count, limit, offset), + }); + }) + .catch(error => res.status(400).send(error)); + }) + .catch(error => res.status(400).send(error)); +} + export default { getUsers, createUser, login, findUser, updateUser, - deleteUser + deleteUser, + getUserDocuments }; diff --git a/server/routes/documents.js b/server/routes/documents.js index b34098e..e936492 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -13,6 +13,12 @@ router.route('/') router.route('/:id') /** PUT /api/v1/documents/id - Create document */ - .put(auth.verifyToken, documentController.updateDocument); + .put(auth.verifyToken, documentController.updateDocument) + + /** GET /api/v1/documents/id - find document */ + .get(auth.verifyToken, documentController.findDocument) + + /** GET /api/v1/documents/id - find document */ + .delete(auth.verifyToken, documentController.deleteDocument); export default router; diff --git a/server/routes/roles.js b/server/routes/roles.js new file mode 100644 index 0000000..a42e59f --- /dev/null +++ b/server/routes/roles.js @@ -0,0 +1,24 @@ +import express from 'express'; +import roleController from '../controllers/roles'; +import auth from '../middlewares/auth'; + +const router = express.Router(); + +router.route('/') + /** GET /api/roles - Get list of roles */ + .get(auth.verifyToken, auth.adminAccess, roleController.getRoles) + + /** POST /api/roles - Create roles */ + .post(auth.verifyToken, auth.adminAccess, roleController.createRole); + +router.route('/:id') + /** GET /api/users/roles - Find roles */ + .get(auth.verifyToken, auth.adminAccess, roleController.findRole) + + /** PUT /api/users/id - update roles */ + .put(auth.verifyToken, auth.adminAccess, roleController.updateRole) + + /** DELETE /api/users/id - delete roles */ + .delete(auth.verifyToken, auth.adminAccess, roleController.deleteRole); + +export default router; diff --git a/server/routes/search.js b/server/routes/search.js index 4915745..80b0df7 100644 --- a/server/routes/search.js +++ b/server/routes/search.js @@ -8,6 +8,8 @@ router.route('/users') /** GET /api/users - Get list of users */ .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); - /** POST /api/users - Create/Signup users */ +router.route('/documents') + /** GET /api/documents - Get list of users */ + .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments); export default router; diff --git a/server/routes/users.js b/server/routes/users.js index 5f74cc5..e18eca9 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -25,4 +25,8 @@ router.route('/:id') /** DELETE /api/users/id - delete users */ .delete(auth.verifyToken, userController.deleteUser); +router.route('/:id/documents') + /** GET /api/users/id/documents - get user document */ + .get(auth.verifyToken, userController.getUserDocuments); + export default router; diff --git a/server/test/index.spec.js b/server/test/index.spec.js new file mode 100644 index 0000000..6550627 --- /dev/null +++ b/server/test/index.spec.js @@ -0,0 +1,8 @@ +process.env.NODE_ENV = 'test'; +const chai = require('chai'); +const chaiHttp = require('chai-http'); +const server = require('../../index'); + +let expect = chai.expect(); + +chai.use(chaiHttp); From d4bd8c4360fbf9b006f88199cf1f69e68f71313d Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 27 Jul 2017 14:12:50 +0100 Subject: [PATCH 34/98] feature(testing routes): routes - add document routes for getting a user document - add route for deleting user document [Finishes #149632847] --- dist/index.js | 2 +- dist/server/controllers/documents.js | 94 +++++++++++++++++++++++++++- dist/server/controllers/search.js | 92 ++++++++++++++++++++++++++- dist/server/controllers/users.js | 78 ++++++++++++++++++++++- dist/server/models/document.js | 15 ++--- dist/server/models/role.js | 15 ++--- dist/server/models/user.js | 27 ++++---- dist/server/routes/documents.js | 8 ++- dist/server/routes/index.js | 5 ++ dist/server/routes/search.js | 4 +- dist/server/routes/users.js | 4 ++ dist/server/test/index.spec.js | 2 +- index.js | 2 +- server/models/document.js | 15 ++--- server/models/role.js | 15 ++--- server/models/user.js | 27 ++++---- server/routes/index.js | 2 + 17 files changed, 333 insertions(+), 74 deletions(-) diff --git a/dist/index.js b/dist/index.js index a6d24a7..32c726d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,6 +8,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var port = process.env.PORT || 3000; -module.exports = _express2.default.listen(port, function () { +_express2.default.listen(port, function () { console.log('API Server started and listening on port 3000'); }); \ No newline at end of file diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index 7ad8802..b4dc0ad 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -18,6 +18,12 @@ var Document = _models2.default.Document; var User = _models2.default.User; var metaData = _helper2.default.paginationMetaData; +/** + * Create documents for users + * @param {object} req - document to be created + * @param {object} res - created document + * @returns {object} - created document + */ function createDocument(req, res) { req.check('title', 'Title is required').notEmpty(); req.check('content', 'Content is required').notEmpty(); @@ -54,6 +60,12 @@ function createDocument(req, res) { } } +/** + * Update user document. + * @param {number} req - request id of the document to be updated + * @param {object} res - object of the updated document + * @returns {object} - updated document + */ function updateDocument(req, res) { if (isNaN(req.params.id)) { return res.status(400); @@ -85,6 +97,12 @@ function updateDocument(req, res) { }); } +/** + * Get all documents + * @param {object} req - contains an object of the query, limits and offset + * @param {array} res - array of documents with pagination + * @returns {array} - array of documents + */ function getAllDocument(req, res) { var limit = req.query.limit; var offset = req.query.offset; @@ -143,4 +161,78 @@ function getAllDocument(req, res) { } } -exports.default = { createDocument: createDocument, updateDocument: updateDocument, getAllDocument: getAllDocument }; \ No newline at end of file +/** + * Find a document by Id + * @param {number} req - id of the requested document + * @param {object} res - object containg the requested document + * @returns {object} requested document + */ +function findDocument(req, res) { + return Document.findById(req.params.id).then(function (document) { + if (!document) { + res.status(404).json({ message: 'Document not found' }); + } + if (req.decoded.roleId === 1) { + return document; + } + if (document.access === 'public') { + return res.status(200).send(document); + } + if (document.access === 'private') { + if (document.userId !== req.decoded.id) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + } + if (document.access === 'role') { + return _models2.default.User.findById(document.userId).then(function (documentOwner) { + if (Number(documentOwner.roleId) !== Number(req.decoded.roleId)) { + return res.status(401).json({ + message: 'You are not authorized to view this document' + }); + } + return res.status(200).send(document); + }).catch(function (error) { + return res.status(400).send(error); + }); + } + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +/** + * + * Delete a document by Id + * @param {number} req - id of the requested document + * @param {object} res - message + * @returns {object} - message + */ +function deleteDocument(req, res) { + return Document.findById(req.params.id).then(function (document) { + if (!document) { + res.status(404).json({ message: 'Document not found' }); + } + if (req.decoded.roleId !== 1 && Number(document.userId) !== Number(req.decoded.id)) { + return res.status(401).json({ + message: 'You are not authorized to delete this document' + }); + } + return document.destroy().then(function () { + return res.status(204).send({ message: 'Document deleted successfully' }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +exports.default = { + createDocument: createDocument, + updateDocument: updateDocument, + getAllDocument: getAllDocument, + findDocument: findDocument, + deleteDocument: deleteDocument }; \ No newline at end of file diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js index d5d4518..fd34c6c 100644 --- a/dist/server/controllers/search.js +++ b/dist/server/controllers/search.js @@ -14,9 +14,16 @@ var _models2 = _interopRequireDefault(_models); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var Document = _models2.default.Document; var User = _models2.default.User; var metaData = _helper2.default.paginationMetaData; +/** + * Search for user using a query string + * @param {string} req - search query of string + * @param {array} res - array of users + * @returns {array} - array users searched + */ function searchUser(req, res) { var searchQuery = req.query.q, limit = req.query.limit, @@ -51,4 +58,87 @@ function searchUser(req, res) { }); } -exports.default = { searchUser: searchUser }; \ No newline at end of file +/** + * + * Search for documents by title + * @param {string} req - an object containing the query, offset and limit + * @param {array} res - an array containing searched document + * @returns {array} - searched document + */ +function searchDocuments(req, res) { + var limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + }, + include: [{ + model: User, + attributes: ['userName', 'roleId'] + }] + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + include: [{ + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + } + }], + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + } + + }).then(function (_ref3) { + var document = _ref3.rows, + count = _ref3.count; + + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 86ff844..669a273 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -25,9 +25,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de require('dotenv').config(); var jwtSecret = process.env.JWT_SECRET; +var Document = _models2.default.Document; var User = _models2.default.User; var metaData = _helper2.default.paginationMetaData; +/** + * Get all users + * @param {number} req - limit and offset for getting all user + * @param {array} res - array of users or error + * @returns {array} - an array of users + */ function getUsers(req, res) { var limit = req.query.limit; var offset = req.query.offset; @@ -47,6 +54,12 @@ function getUsers(req, res) { }); } +/** + * Create a user + * @param {object} req - request from user + * @param {object} res - newly created user or error + * @returns {object} - an object of a created user + */ function createUser(req, res) { req.check('fullName', 'FullName is required').notEmpty(); req.check('userName', 'userName is required').notEmpty(); @@ -87,6 +100,12 @@ function createUser(req, res) { } } +/** + * Log In user with JWT + * @param {object} req - request from log in user + * @param {object} res - authenicated user details + * @returns {object} - an object of the logged in user and a token + */ function login(req, res) { req.check('email', 'Email is required').notEmpty(); req.check('email', 'Please put a valid email').isEmail(); @@ -136,6 +155,12 @@ function login(req, res) { } } +/** + * Find a user by Id + * @param {number} req - request for user using the id of the user + * @param {object} res - an object of the user(s) found or error + * @returns {object} - an object of found user + */ function findUser(req, res) { var userQuery = Number(req.params.id); if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { @@ -158,6 +183,12 @@ function findUser(req, res) { }); } +/** + *Update a user by Id + * @param {object} req - updated user object + * @param {object} res - updated user object or error + * @returns {object} - return an object of the updated user + */ function updateUser(req, res) { if (Number(req.decoded.id) !== Number(req.params.id)) { return res.status(401).json({ @@ -196,6 +227,12 @@ function updateUser(req, res) { }); } +/** + * Delete a user by Id + * @param {number} req - delete user with an id + * @param {object} res - message + * @returns {object} - null + */ function deleteUser(req, res) { if (req.decoded.roleId !== 1) { return res.status(401).json({ @@ -217,11 +254,50 @@ function deleteUser(req, res) { }); } +/** + * + * Get documents for specific user + * @param {object} req - request object containing limit query and offset + * @param {array} res - array of documents for the requested user + * @return {array} - array of requested user's document + */ +function getUserDocuments(req, res) { + var limit = req.query.limit; + var offset = req.query.offset; + User.findById(req.params.id).then(function (user) { + if (!user) { + return res.status(404).json({ + message: 'User not found' + }); + } + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + userId: user.id + } + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + exports.default = { getUsers: getUsers, createUser: createUser, login: login, findUser: findUser, updateUser: updateUser, - deleteUser: deleteUser + deleteUser: deleteUser, + getUserDocuments: getUserDocuments }; \ No newline at end of file diff --git a/dist/server/models/document.js b/dist/server/models/document.js index edd6894..d5bf4c7 100644 --- a/dist/server/models/document.js +++ b/dist/server/models/document.js @@ -19,15 +19,12 @@ module.exports = function (sequelize, DataTypes) { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - } - } }); + Document.associate = function (models) { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + }; return Document; }; \ No newline at end of file diff --git a/dist/server/models/role.js b/dist/server/models/role.js index 96e14a0..421c0e1 100644 --- a/dist/server/models/role.js +++ b/dist/server/models/role.js @@ -7,15 +7,12 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, unique: true } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - } - } }); + Role.associate = function (models) { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + }; return Role; }; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js index e4a24e8..e18d564 100644 --- a/dist/server/models/user.js +++ b/dist/server/models/user.js @@ -25,21 +25,18 @@ module.exports = function (sequelize, DataTypes) { allowNull: false, defaultvalue: 2 } - }, { - classMethods: { - associate: function associate(models) { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - } - } }); + User.associate = function (models) { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId', + onDelete: 'CASCADE' + }); + }; return User; }; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index be28eaf..5d1849c 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -29,6 +29,12 @@ router.route('/') router.route('/:id') /** PUT /api/v1/documents/id - Create document */ -.put(_auth2.default.verifyToken, _documents2.default.updateDocument); +.put(_auth2.default.verifyToken, _documents2.default.updateDocument) + +/** GET /api/v1/documents/id - find document */ +.get(_auth2.default.verifyToken, _documents2.default.findDocument) + +/** GET /api/v1/documents/id - find document */ +.delete(_auth2.default.verifyToken, _documents2.default.deleteDocument); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js index 7515895..1f4a3ec 100644 --- a/dist/server/routes/index.js +++ b/dist/server/routes/index.js @@ -20,6 +20,10 @@ var _documents = require('./documents'); var _documents2 = _interopRequireDefault(_documents); +var _roles = require('./roles'); + +var _roles2 = _interopRequireDefault(_roles); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var router = _express2.default.Router(); @@ -28,5 +32,6 @@ var router = _express2.default.Router(); router.use('/users', _users2.default); router.use('/search', _search2.default); router.use('/documents', _documents2.default); +router.use('/roles', _roles2.default); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js index cf4eb95..92217fb 100644 --- a/dist/server/routes/search.js +++ b/dist/server/routes/search.js @@ -24,6 +24,8 @@ router.route('/users') /** GET /api/users - Get list of users */ .get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); -/** POST /api/users - Create/Signup users */ +router.route('/documents') +/** GET /api/documents - Get list of users */ +.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchDocuments); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 73b8288..db1d79a 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -41,4 +41,8 @@ router.route('/:id') /** DELETE /api/users/id - delete users */ .delete(_auth2.default.verifyToken, _users2.default.deleteUser); +router.route('/:id/documents') +/** GET /api/users/id/documents - get user document */ +.get(_auth2.default.verifyToken, _users2.default.getUserDocuments); + exports.default = router; \ No newline at end of file diff --git a/dist/server/test/index.spec.js b/dist/server/test/index.spec.js index 4a1eedb..9e65c02 100644 --- a/dist/server/test/index.spec.js +++ b/dist/server/test/index.spec.js @@ -5,6 +5,6 @@ var chai = require('chai'); var chaiHttp = require('chai-http'); var server = require('../../index'); -var should = chai.should(); +var expect = chai.expect(); chai.use(chaiHttp); \ No newline at end of file diff --git a/index.js b/index.js index ed93dc4..e81e308 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,6 @@ import app from './server/config/express'; const port = process.env.PORT || 3000; -module.exports = app.listen(port, () => { +app.listen(port, () => { console.log('API Server started and listening on port 3000'); }); diff --git a/server/models/document.js b/server/models/document.js index 4c4cfd1..eac8ffd 100644 --- a/server/models/document.js +++ b/server/models/document.js @@ -18,15 +18,12 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.ENUM, values: ['public', 'private', 'role'] } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - } - } }); + Document.associate = (models) => { + // associations can be defined here + Document.belongsTo(models.User, { + foreignKey: 'userId' + }); + }; return Document; }; diff --git a/server/models/role.js b/server/models/role.js index 986b172..a81a8fe 100644 --- a/server/models/role.js +++ b/server/models/role.js @@ -6,15 +6,12 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, unique: true } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - } - } }); + Role.associate = (models) => { + // associations can be defined here + Role.hasMany(models.User, { + foreignKey: 'roleId' + }); + }; return Role; }; diff --git a/server/models/user.js b/server/models/user.js index 3157132..437c1f3 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -24,21 +24,18 @@ module.exports = (sequelize, DataTypes) => { allowNull: false, defaultvalue: 2 } - }, { - classMethods: { - associate: (models) => { - // associations can be defined here - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - } - } }); + User.associate = (models) => { + // associations can be defined here + User.hasMany(models.Document, { + foreignKey: 'userId', + onDelete: 'CASCADE', + hooks: true + }); + User.belongsTo(models.Role, { + foreignKey: 'roleId', + onDelete: 'CASCADE' + }); + }; return User; }; diff --git a/server/routes/index.js b/server/routes/index.js index eb44098..fdde1f5 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -2,6 +2,7 @@ import express from 'express'; import userRoutes from './users'; import searchRoutes from './search'; import documentRoutes from './documents'; +import roleRoutes from './roles'; const router = express.Router(); @@ -10,5 +11,6 @@ const router = express.Router(); router.use('/users', userRoutes); router.use('/search', searchRoutes); router.use('/documents', documentRoutes); +router.use('/roles', roleRoutes); export default router; From 590c2aabef834b2d75298ac90256ac8821173d2d Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 30 Jul 2017 09:49:05 +0100 Subject: [PATCH 35/98] feature(testing routes): routes - add document routes for getting a user document - add route for deleting user document [Finishes #149632847] --- .env | 4 + .gitignore | 1 + .../761fb25525ac9854b017da3143f5384b.json | 1 + .../d9387f41d819cd714da6161ea327df8e.json | 1 + coverage/auth.spec.js.html | 383 +++++ coverage/base.css | 212 +++ coverage/document-manager/index.html | 93 ++ coverage/document-manager/index.js.html | 92 ++ .../server/config/config.js.html | 140 ++ .../server/config/express.js.html | 155 ++ .../document-manager/server/config/index.html | 106 ++ .../server/controllers/documents.js.html | 737 ++++++++++ .../server/controllers/index.html | 132 ++ .../server/controllers/roles.js.html | 467 ++++++ .../server/controllers/search.js.html | 440 ++++++ .../server/controllers/searches.js.html | 440 ++++++ .../server/controllers/users.js.html | 917 ++++++++++++ .../server/helpers/helper.js.html | 89 ++ .../server/helpers/index.html | 93 ++ .../server/middlewares/auth.js.html | 170 +++ .../server/middlewares/index.html | 93 ++ .../server/models/document.js.html | 152 ++ .../document-manager/server/models/index.html | 132 ++ .../server/models/index.js.html | 200 +++ .../server/models/role.js.html | 116 ++ .../server/models/user.js.html | 185 +++ .../server/routes/documents.js.html | 137 ++ .../document-manager/server/routes/index.html | 145 ++ .../server/routes/index.js.html | 113 ++ .../server/routes/roles.js.html | 137 ++ .../server/routes/search.js.html | 110 ++ .../server/routes/searches.js.html | 110 ++ .../server/routes/users.js.html | 161 +++ .../server/test/document.spec.js.html | 1151 +++++++++++++++ .../document-manager/server/test/index.html | 145 ++ .../server/test/index.spec.js.html | 89 ++ .../server/test/middlewares/auth.spec.js.html | 383 +++++ .../server/test/middlewares/index.html | 93 ++ .../server/test/mockData.js.html | 197 +++ .../document-manager/server/test/role.js.html | 950 +++++++++++++ .../server/test/role.spec.js.html | 992 +++++++++++++ .../server/test/search.spec.js.html | 386 +++++ .../server/test/user.spec.js.html | 1247 +++++++++++++++++ coverage/index.html | 184 +++ coverage/mockData.js.html | 197 +++ coverage/prettify.css | 1 + coverage/prettify.js | 1 + coverage/sort-arrow-sprite.png | Bin 0 -> 209 bytes coverage/sorter.js | 158 +++ coverage/user.spec.js.html | 179 +++ dist/coverage/prettify.js | 363 +++++ dist/coverage/sorter.js | 169 +++ dist/index.js | 10 +- dist/server/controllers/roles.js | 26 +- dist/server/controllers/searches.js | 145 +- dist/server/controllers/users.js | 90 +- .../seeders/20170727152600-sample-roles.js | 23 + .../seeders/20170727153559-sample-users.js | 38 + .../20170727153641-sample-documents.js | 32 + dist/server/test/document.spec.js | 291 ++++ dist/server/test/mockData.js | 54 + dist/server/test/role.spec.js | 245 ++++ dist/server/test/search.spec.js | 106 ++ dist/server/test/user.spec.js | 314 +++++ index.js | 4 +- npm-debug.log | 49 + package.json | 15 +- server/controllers/roles.js | 26 +- server/controllers/users.js | 95 +- server/models/user.js | 1 - server/seeders/20170727152600-sample-roles.js | 18 + server/seeders/20170727153559-sample-users.js | 34 + .../20170727153641-sample-documents.js | 28 + server/test/document.spec.js | 362 +++++ server/test/index.spec.js | 8 - server/test/mockData.js | 44 + server/test/role.spec.js | 309 ++++ server/test/search.spec.js | 107 ++ server/test/user.spec.js | 394 ++++++ 79 files changed, 16087 insertions(+), 130 deletions(-) create mode 100644 .nyc_output/761fb25525ac9854b017da3143f5384b.json create mode 100644 .nyc_output/d9387f41d819cd714da6161ea327df8e.json create mode 100644 coverage/auth.spec.js.html create mode 100644 coverage/base.css create mode 100644 coverage/document-manager/index.html create mode 100644 coverage/document-manager/index.js.html create mode 100644 coverage/document-manager/server/config/config.js.html create mode 100644 coverage/document-manager/server/config/express.js.html create mode 100644 coverage/document-manager/server/config/index.html create mode 100644 coverage/document-manager/server/controllers/documents.js.html create mode 100644 coverage/document-manager/server/controllers/index.html create mode 100644 coverage/document-manager/server/controllers/roles.js.html create mode 100644 coverage/document-manager/server/controllers/search.js.html create mode 100644 coverage/document-manager/server/controllers/searches.js.html create mode 100644 coverage/document-manager/server/controllers/users.js.html create mode 100644 coverage/document-manager/server/helpers/helper.js.html create mode 100644 coverage/document-manager/server/helpers/index.html create mode 100644 coverage/document-manager/server/middlewares/auth.js.html create mode 100644 coverage/document-manager/server/middlewares/index.html create mode 100644 coverage/document-manager/server/models/document.js.html create mode 100644 coverage/document-manager/server/models/index.html create mode 100644 coverage/document-manager/server/models/index.js.html create mode 100644 coverage/document-manager/server/models/role.js.html create mode 100644 coverage/document-manager/server/models/user.js.html create mode 100644 coverage/document-manager/server/routes/documents.js.html create mode 100644 coverage/document-manager/server/routes/index.html create mode 100644 coverage/document-manager/server/routes/index.js.html create mode 100644 coverage/document-manager/server/routes/roles.js.html create mode 100644 coverage/document-manager/server/routes/search.js.html create mode 100644 coverage/document-manager/server/routes/searches.js.html create mode 100644 coverage/document-manager/server/routes/users.js.html create mode 100644 coverage/document-manager/server/test/document.spec.js.html create mode 100644 coverage/document-manager/server/test/index.html create mode 100644 coverage/document-manager/server/test/index.spec.js.html create mode 100644 coverage/document-manager/server/test/middlewares/auth.spec.js.html create mode 100644 coverage/document-manager/server/test/middlewares/index.html create mode 100644 coverage/document-manager/server/test/mockData.js.html create mode 100644 coverage/document-manager/server/test/role.js.html create mode 100644 coverage/document-manager/server/test/role.spec.js.html create mode 100644 coverage/document-manager/server/test/search.spec.js.html create mode 100644 coverage/document-manager/server/test/user.spec.js.html create mode 100644 coverage/index.html create mode 100644 coverage/mockData.js.html create mode 100644 coverage/prettify.css create mode 100644 coverage/prettify.js create mode 100644 coverage/sort-arrow-sprite.png create mode 100644 coverage/sorter.js create mode 100644 coverage/user.spec.js.html create mode 100644 dist/coverage/prettify.js create mode 100644 dist/coverage/sorter.js create mode 100644 dist/server/seeders/20170727152600-sample-roles.js create mode 100644 dist/server/seeders/20170727153559-sample-users.js create mode 100644 dist/server/seeders/20170727153641-sample-documents.js create mode 100644 dist/server/test/document.spec.js create mode 100644 dist/server/test/mockData.js create mode 100644 dist/server/test/role.spec.js create mode 100644 dist/server/test/search.spec.js create mode 100644 dist/server/test/user.spec.js create mode 100644 npm-debug.log create mode 100644 server/seeders/20170727152600-sample-roles.js create mode 100644 server/seeders/20170727153559-sample-users.js create mode 100644 server/seeders/20170727153641-sample-documents.js create mode 100644 server/test/document.spec.js delete mode 100644 server/test/index.spec.js create mode 100644 server/test/mockData.js create mode 100644 server/test/role.spec.js create mode 100644 server/test/search.spec.js create mode 100644 server/test/user.spec.js diff --git a/.env b/.env index 4dfa2cb..3ab0297 100644 --- a/.env +++ b/.env @@ -1 +1,5 @@ JWT_SECRET=iamflax +TEST_ADMIN_PASSWORD=pass123 +TEST_FELLOW_PASSWORD=pass123 +TEST_FACILITATOR_PASSWORD=pass123 +PASSWORD=pass123 diff --git a/.gitignore b/.gitignore index 2752eb9..6e267fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ .DS_Store +.env diff --git a/.nyc_output/761fb25525ac9854b017da3143f5384b.json b/.nyc_output/761fb25525ac9854b017da3143f5384b.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.nyc_output/761fb25525ac9854b017da3143f5384b.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.nyc_output/d9387f41d819cd714da6161ea327df8e.json b/.nyc_output/d9387f41d819cd714da6161ea327df8e.json new file mode 100644 index 0000000..107ace2 --- /dev/null +++ b/.nyc_output/d9387f41d819cd714da6161ea327df8e.json @@ -0,0 +1 @@ +{"/Users/andeladeveloper/Documents/projects/document-manager/server/test/document.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/document.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":291,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":106,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":79,"column":7}},"38":{"start":{"line":64,"column":21},"end":{"line":69,"column":7}},"39":{"start":{"line":70,"column":6},"end":{"line":78,"column":9}},"40":{"start":{"line":71,"column":8},"end":{"line":71,"column":41}},"41":{"start":{"line":72,"column":8},"end":{"line":72,"column":43}},"42":{"start":{"line":73,"column":8},"end":{"line":73,"column":48}},"43":{"start":{"line":74,"column":8},"end":{"line":74,"column":54}},"44":{"start":{"line":75,"column":8},"end":{"line":75,"column":71}},"45":{"start":{"line":76,"column":8},"end":{"line":76,"column":51}},"46":{"start":{"line":77,"column":8},"end":{"line":77,"column":15}},"47":{"start":{"line":81,"column":4},"end":{"line":91,"column":7}},"48":{"start":{"line":82,"column":21},"end":{"line":86,"column":7}},"49":{"start":{"line":87,"column":6},"end":{"line":90,"column":9}},"50":{"start":{"line":88,"column":8},"end":{"line":88,"column":41}},"51":{"start":{"line":89,"column":8},"end":{"line":89,"column":67}},"52":{"start":{"line":92,"column":4},"end":{"line":105,"column":7}},"53":{"start":{"line":93,"column":21},"end":{"line":98,"column":7}},"54":{"start":{"line":99,"column":6},"end":{"line":104,"column":9}},"55":{"start":{"line":100,"column":8},"end":{"line":100,"column":41}},"56":{"start":{"line":101,"column":8},"end":{"line":101,"column":43}},"57":{"start":{"line":102,"column":8},"end":{"line":102,"column":62}},"58":{"start":{"line":103,"column":8},"end":{"line":103,"column":15}},"59":{"start":{"line":108,"column":2},"end":{"line":142,"column":5}},"60":{"start":{"line":109,"column":4},"end":{"line":116,"column":7}},"61":{"start":{"line":110,"column":6},"end":{"line":115,"column":9}},"62":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"63":{"start":{"line":112,"column":8},"end":{"line":112,"column":43}},"64":{"start":{"line":113,"column":8},"end":{"line":113,"column":66}},"65":{"start":{"line":114,"column":8},"end":{"line":114,"column":15}},"66":{"start":{"line":117,"column":4},"end":{"line":125,"column":7}},"67":{"start":{"line":118,"column":6},"end":{"line":124,"column":9}},"68":{"start":{"line":119,"column":8},"end":{"line":119,"column":41}},"69":{"start":{"line":120,"column":8},"end":{"line":120,"column":43}},"70":{"start":{"line":121,"column":8},"end":{"line":121,"column":62}},"71":{"start":{"line":122,"column":8},"end":{"line":122,"column":47}},"72":{"start":{"line":123,"column":8},"end":{"line":123,"column":15}},"73":{"start":{"line":126,"column":4},"end":{"line":133,"column":7}},"74":{"start":{"line":127,"column":18},"end":{"line":127,"column":19}},"75":{"start":{"line":128,"column":6},"end":{"line":132,"column":9}},"76":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"77":{"start":{"line":130,"column":8},"end":{"line":130,"column":43}},"78":{"start":{"line":131,"column":8},"end":{"line":131,"column":15}},"79":{"start":{"line":134,"column":4},"end":{"line":141,"column":7}},"80":{"start":{"line":135,"column":19},"end":{"line":135,"column":20}},"81":{"start":{"line":136,"column":6},"end":{"line":140,"column":9}},"82":{"start":{"line":137,"column":8},"end":{"line":137,"column":41}},"83":{"start":{"line":138,"column":8},"end":{"line":138,"column":43}},"84":{"start":{"line":139,"column":8},"end":{"line":139,"column":15}},"85":{"start":{"line":144,"column":2},"end":{"line":217,"column":5}},"86":{"start":{"line":145,"column":4},"end":{"line":153,"column":7}},"87":{"start":{"line":146,"column":23},"end":{"line":146,"column":24}},"88":{"start":{"line":147,"column":6},"end":{"line":152,"column":9}},"89":{"start":{"line":148,"column":8},"end":{"line":148,"column":41}},"90":{"start":{"line":149,"column":8},"end":{"line":149,"column":43}},"91":{"start":{"line":150,"column":8},"end":{"line":150,"column":62}},"92":{"start":{"line":151,"column":8},"end":{"line":151,"column":15}},"93":{"start":{"line":154,"column":4},"end":{"line":164,"column":7}},"94":{"start":{"line":155,"column":23},"end":{"line":155,"column":24}},"95":{"start":{"line":156,"column":6},"end":{"line":163,"column":9}},"96":{"start":{"line":157,"column":8},"end":{"line":157,"column":41}},"97":{"start":{"line":158,"column":8},"end":{"line":158,"column":43}},"98":{"start":{"line":159,"column":8},"end":{"line":159,"column":38}},"99":{"start":{"line":160,"column":8},"end":{"line":160,"column":56}},"100":{"start":{"line":161,"column":8},"end":{"line":161,"column":51}},"101":{"start":{"line":162,"column":8},"end":{"line":162,"column":15}},"102":{"start":{"line":165,"column":4},"end":{"line":173,"column":7}},"103":{"start":{"line":166,"column":23},"end":{"line":166,"column":24}},"104":{"start":{"line":167,"column":6},"end":{"line":172,"column":9}},"105":{"start":{"line":168,"column":8},"end":{"line":168,"column":41}},"106":{"start":{"line":169,"column":8},"end":{"line":169,"column":43}},"107":{"start":{"line":170,"column":8},"end":{"line":170,"column":88}},"108":{"start":{"line":171,"column":8},"end":{"line":171,"column":15}},"109":{"start":{"line":174,"column":4},"end":{"line":185,"column":7}},"110":{"start":{"line":175,"column":23},"end":{"line":175,"column":24}},"111":{"start":{"line":176,"column":6},"end":{"line":184,"column":9}},"112":{"start":{"line":177,"column":8},"end":{"line":177,"column":41}},"113":{"start":{"line":178,"column":8},"end":{"line":178,"column":43}},"114":{"start":{"line":179,"column":8},"end":{"line":179,"column":50}},"115":{"start":{"line":180,"column":8},"end":{"line":180,"column":54}},"116":{"start":{"line":181,"column":8},"end":{"line":181,"column":38}},"117":{"start":{"line":182,"column":8},"end":{"line":182,"column":42}},"118":{"start":{"line":183,"column":8},"end":{"line":183,"column":15}},"119":{"start":{"line":186,"column":4},"end":{"line":194,"column":7}},"120":{"start":{"line":187,"column":23},"end":{"line":187,"column":24}},"121":{"start":{"line":188,"column":6},"end":{"line":193,"column":9}},"122":{"start":{"line":189,"column":8},"end":{"line":189,"column":41}},"123":{"start":{"line":190,"column":8},"end":{"line":190,"column":43}},"124":{"start":{"line":191,"column":8},"end":{"line":191,"column":88}},"125":{"start":{"line":192,"column":8},"end":{"line":192,"column":15}},"126":{"start":{"line":195,"column":4},"end":{"line":205,"column":7}},"127":{"start":{"line":196,"column":23},"end":{"line":196,"column":24}},"128":{"start":{"line":197,"column":6},"end":{"line":204,"column":9}},"129":{"start":{"line":198,"column":8},"end":{"line":198,"column":41}},"130":{"start":{"line":199,"column":8},"end":{"line":199,"column":43}},"131":{"start":{"line":200,"column":8},"end":{"line":200,"column":38}},"132":{"start":{"line":201,"column":8},"end":{"line":201,"column":53}},"133":{"start":{"line":202,"column":8},"end":{"line":202,"column":47}},"134":{"start":{"line":203,"column":8},"end":{"line":203,"column":15}},"135":{"start":{"line":206,"column":4},"end":{"line":216,"column":7}},"136":{"start":{"line":207,"column":23},"end":{"line":207,"column":24}},"137":{"start":{"line":208,"column":6},"end":{"line":214,"column":9}},"138":{"start":{"line":209,"column":8},"end":{"line":209,"column":41}},"139":{"start":{"line":210,"column":8},"end":{"line":210,"column":43}},"140":{"start":{"line":211,"column":8},"end":{"line":211,"column":38}},"141":{"start":{"line":212,"column":8},"end":{"line":212,"column":53}},"142":{"start":{"line":213,"column":8},"end":{"line":213,"column":47}},"143":{"start":{"line":215,"column":6},"end":{"line":215,"column":13}},"144":{"start":{"line":219,"column":2},"end":{"line":255,"column":5}},"145":{"start":{"line":220,"column":4},"end":{"line":229,"column":7}},"146":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"147":{"start":{"line":222,"column":6},"end":{"line":228,"column":9}},"148":{"start":{"line":223,"column":8},"end":{"line":223,"column":41}},"149":{"start":{"line":224,"column":8},"end":{"line":224,"column":43}},"150":{"start":{"line":225,"column":8},"end":{"line":225,"column":38}},"151":{"start":{"line":226,"column":8},"end":{"line":226,"column":56}},"152":{"start":{"line":227,"column":8},"end":{"line":227,"column":15}},"153":{"start":{"line":230,"column":4},"end":{"line":238,"column":7}},"154":{"start":{"line":231,"column":15},"end":{"line":231,"column":16}},"155":{"start":{"line":232,"column":6},"end":{"line":237,"column":9}},"156":{"start":{"line":233,"column":8},"end":{"line":233,"column":41}},"157":{"start":{"line":234,"column":8},"end":{"line":234,"column":43}},"158":{"start":{"line":235,"column":8},"end":{"line":235,"column":88}},"159":{"start":{"line":236,"column":8},"end":{"line":236,"column":15}},"160":{"start":{"line":239,"column":4},"end":{"line":245,"column":7}},"161":{"start":{"line":240,"column":15},"end":{"line":240,"column":16}},"162":{"start":{"line":241,"column":6},"end":{"line":244,"column":9}},"163":{"start":{"line":242,"column":8},"end":{"line":242,"column":41}},"164":{"start":{"line":243,"column":8},"end":{"line":243,"column":15}},"165":{"start":{"line":246,"column":4},"end":{"line":254,"column":7}},"166":{"start":{"line":247,"column":15},"end":{"line":247,"column":17}},"167":{"start":{"line":248,"column":6},"end":{"line":253,"column":9}},"168":{"start":{"line":249,"column":8},"end":{"line":249,"column":41}},"169":{"start":{"line":250,"column":8},"end":{"line":250,"column":43}},"170":{"start":{"line":251,"column":8},"end":{"line":251,"column":62}},"171":{"start":{"line":252,"column":8},"end":{"line":252,"column":15}},"172":{"start":{"line":257,"column":2},"end":{"line":290,"column":5}},"173":{"start":{"line":258,"column":4},"end":{"line":264,"column":7}},"174":{"start":{"line":259,"column":15},"end":{"line":259,"column":16}},"175":{"start":{"line":260,"column":6},"end":{"line":263,"column":9}},"176":{"start":{"line":261,"column":8},"end":{"line":261,"column":41}},"177":{"start":{"line":262,"column":8},"end":{"line":262,"column":15}},"178":{"start":{"line":265,"column":4},"end":{"line":271,"column":7}},"179":{"start":{"line":266,"column":15},"end":{"line":266,"column":16}},"180":{"start":{"line":267,"column":6},"end":{"line":270,"column":9}},"181":{"start":{"line":268,"column":8},"end":{"line":268,"column":41}},"182":{"start":{"line":269,"column":8},"end":{"line":269,"column":15}},"183":{"start":{"line":272,"column":4},"end":{"line":280,"column":7}},"184":{"start":{"line":273,"column":15},"end":{"line":273,"column":16}},"185":{"start":{"line":274,"column":6},"end":{"line":279,"column":9}},"186":{"start":{"line":275,"column":8},"end":{"line":275,"column":41}},"187":{"start":{"line":276,"column":8},"end":{"line":276,"column":43}},"188":{"start":{"line":277,"column":8},"end":{"line":277,"column":90}},"189":{"start":{"line":278,"column":8},"end":{"line":278,"column":15}},"190":{"start":{"line":281,"column":4},"end":{"line":289,"column":7}},"191":{"start":{"line":282,"column":15},"end":{"line":282,"column":18}},"192":{"start":{"line":283,"column":6},"end":{"line":288,"column":9}},"193":{"start":{"line":284,"column":8},"end":{"line":284,"column":41}},"194":{"start":{"line":285,"column":8},"end":{"line":285,"column":43}},"195":{"start":{"line":286,"column":8},"end":{"line":286,"column":62}},"196":{"start":{"line":287,"column":8},"end":{"line":287,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":22},"end":{"line":38,"column":23}},"loc":{"start":{"line":38,"column":34},"end":{"line":291,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":29},"end":{"line":62,"column":30}},"loc":{"start":{"line":62,"column":41},"end":{"line":106,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":65},"end":{"line":63,"column":66}},"loc":{"start":{"line":63,"column":81},"end":{"line":79,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":70,"column":127},"end":{"line":70,"column":128}},"loc":{"start":{"line":70,"column":147},"end":{"line":78,"column":7}},"line":70},"12":{"name":"(anonymous_12)","decl":{"start":{"line":81,"column":48},"end":{"line":81,"column":49}},"loc":{"start":{"line":81,"column":60},"end":{"line":91,"column":5}},"line":81},"13":{"name":"(anonymous_13)","decl":{"start":{"line":87,"column":112},"end":{"line":87,"column":113}},"loc":{"start":{"line":87,"column":132},"end":{"line":90,"column":7}},"line":87},"14":{"name":"(anonymous_14)","decl":{"start":{"line":92,"column":77},"end":{"line":92,"column":78}},"loc":{"start":{"line":92,"column":93},"end":{"line":105,"column":5}},"line":92},"15":{"name":"(anonymous_15)","decl":{"start":{"line":99,"column":93},"end":{"line":99,"column":94}},"loc":{"start":{"line":99,"column":113},"end":{"line":104,"column":7}},"line":99},"16":{"name":"(anonymous_16)","decl":{"start":{"line":108,"column":29},"end":{"line":108,"column":30}},"loc":{"start":{"line":108,"column":41},"end":{"line":142,"column":3}},"line":108},"17":{"name":"(anonymous_17)","decl":{"start":{"line":109,"column":70},"end":{"line":109,"column":71}},"loc":{"start":{"line":109,"column":86},"end":{"line":116,"column":5}},"line":109},"18":{"name":"(anonymous_18)","decl":{"start":{"line":110,"column":111},"end":{"line":110,"column":112}},"loc":{"start":{"line":110,"column":131},"end":{"line":115,"column":7}},"line":110},"19":{"name":"(anonymous_19)","decl":{"start":{"line":117,"column":76},"end":{"line":117,"column":77}},"loc":{"start":{"line":117,"column":92},"end":{"line":125,"column":5}},"line":117},"20":{"name":"(anonymous_20)","decl":{"start":{"line":118,"column":78},"end":{"line":118,"column":79}},"loc":{"start":{"line":118,"column":98},"end":{"line":124,"column":7}},"line":118},"21":{"name":"(anonymous_21)","decl":{"start":{"line":126,"column":65},"end":{"line":126,"column":66}},"loc":{"start":{"line":126,"column":81},"end":{"line":133,"column":5}},"line":126},"22":{"name":"(anonymous_22)","decl":{"start":{"line":128,"column":126},"end":{"line":128,"column":127}},"loc":{"start":{"line":128,"column":146},"end":{"line":132,"column":7}},"line":128},"23":{"name":"(anonymous_23)","decl":{"start":{"line":134,"column":66},"end":{"line":134,"column":67}},"loc":{"start":{"line":134,"column":82},"end":{"line":141,"column":5}},"line":134},"24":{"name":"(anonymous_24)","decl":{"start":{"line":136,"column":127},"end":{"line":136,"column":128}},"loc":{"start":{"line":136,"column":147},"end":{"line":140,"column":7}},"line":136},"25":{"name":"(anonymous_25)","decl":{"start":{"line":144,"column":32},"end":{"line":144,"column":33}},"loc":{"start":{"line":144,"column":44},"end":{"line":217,"column":3}},"line":144},"26":{"name":"(anonymous_26)","decl":{"start":{"line":145,"column":58},"end":{"line":145,"column":59}},"loc":{"start":{"line":145,"column":74},"end":{"line":153,"column":5}},"line":145},"27":{"name":"(anonymous_27)","decl":{"start":{"line":147,"column":131},"end":{"line":147,"column":132}},"loc":{"start":{"line":147,"column":151},"end":{"line":152,"column":7}},"line":147},"28":{"name":"(anonymous_28)","decl":{"start":{"line":154,"column":49},"end":{"line":154,"column":50}},"loc":{"start":{"line":154,"column":65},"end":{"line":164,"column":5}},"line":154},"29":{"name":"(anonymous_29)","decl":{"start":{"line":156,"column":131},"end":{"line":156,"column":132}},"loc":{"start":{"line":156,"column":151},"end":{"line":163,"column":7}},"line":156},"30":{"name":"(anonymous_30)","decl":{"start":{"line":165,"column":81},"end":{"line":165,"column":82}},"loc":{"start":{"line":165,"column":97},"end":{"line":173,"column":5}},"line":165},"31":{"name":"(anonymous_31)","decl":{"start":{"line":167,"column":137},"end":{"line":167,"column":138}},"loc":{"start":{"line":167,"column":157},"end":{"line":172,"column":7}},"line":167},"32":{"name":"(anonymous_32)","decl":{"start":{"line":174,"column":77},"end":{"line":174,"column":78}},"loc":{"start":{"line":174,"column":93},"end":{"line":185,"column":5}},"line":174},"33":{"name":"(anonymous_33)","decl":{"start":{"line":176,"column":131},"end":{"line":176,"column":132}},"loc":{"start":{"line":176,"column":151},"end":{"line":184,"column":7}},"line":176},"34":{"name":"(anonymous_34)","decl":{"start":{"line":186,"column":80},"end":{"line":186,"column":81}},"loc":{"start":{"line":186,"column":96},"end":{"line":194,"column":5}},"line":186},"35":{"name":"(anonymous_35)","decl":{"start":{"line":188,"column":137},"end":{"line":188,"column":138}},"loc":{"start":{"line":188,"column":157},"end":{"line":193,"column":7}},"line":188},"36":{"name":"(anonymous_36)","decl":{"start":{"line":195,"column":71},"end":{"line":195,"column":72}},"loc":{"start":{"line":195,"column":87},"end":{"line":205,"column":5}},"line":195},"37":{"name":"(anonymous_37)","decl":{"start":{"line":197,"column":131},"end":{"line":197,"column":132}},"loc":{"start":{"line":197,"column":151},"end":{"line":204,"column":7}},"line":197},"38":{"name":"(anonymous_38)","decl":{"start":{"line":206,"column":61},"end":{"line":206,"column":62}},"loc":{"start":{"line":206,"column":77},"end":{"line":216,"column":5}},"line":206},"39":{"name":"(anonymous_39)","decl":{"start":{"line":208,"column":132},"end":{"line":208,"column":133}},"loc":{"start":{"line":208,"column":152},"end":{"line":214,"column":7}},"line":208},"40":{"name":"(anonymous_40)","decl":{"start":{"line":219,"column":33},"end":{"line":219,"column":34}},"loc":{"start":{"line":219,"column":45},"end":{"line":255,"column":3}},"line":219},"41":{"name":"(anonymous_41)","decl":{"start":{"line":220,"column":69},"end":{"line":220,"column":70}},"loc":{"start":{"line":220,"column":85},"end":{"line":229,"column":5}},"line":220},"42":{"name":"(anonymous_42)","decl":{"start":{"line":222,"column":151},"end":{"line":222,"column":152}},"loc":{"start":{"line":222,"column":171},"end":{"line":228,"column":7}},"line":222},"43":{"name":"(anonymous_43)","decl":{"start":{"line":230,"column":94},"end":{"line":230,"column":95}},"loc":{"start":{"line":230,"column":110},"end":{"line":238,"column":5}},"line":230},"44":{"name":"(anonymous_44)","decl":{"start":{"line":232,"column":163},"end":{"line":232,"column":164}},"loc":{"start":{"line":232,"column":183},"end":{"line":237,"column":7}},"line":232},"45":{"name":"(anonymous_45)","decl":{"start":{"line":239,"column":74},"end":{"line":239,"column":75}},"loc":{"start":{"line":239,"column":90},"end":{"line":245,"column":5}},"line":239},"46":{"name":"(anonymous_46)","decl":{"start":{"line":241,"column":146},"end":{"line":241,"column":147}},"loc":{"start":{"line":241,"column":166},"end":{"line":244,"column":7}},"line":241},"47":{"name":"(anonymous_47)","decl":{"start":{"line":246,"column":80},"end":{"line":246,"column":81}},"loc":{"start":{"line":246,"column":96},"end":{"line":254,"column":5}},"line":246},"48":{"name":"(anonymous_48)","decl":{"start":{"line":248,"column":145},"end":{"line":248,"column":146}},"loc":{"start":{"line":248,"column":165},"end":{"line":253,"column":7}},"line":248},"49":{"name":"(anonymous_49)","decl":{"start":{"line":257,"column":34},"end":{"line":257,"column":35}},"loc":{"start":{"line":257,"column":46},"end":{"line":290,"column":3}},"line":257},"50":{"name":"(anonymous_50)","decl":{"start":{"line":258,"column":64},"end":{"line":258,"column":65}},"loc":{"start":{"line":258,"column":80},"end":{"line":264,"column":5}},"line":258},"51":{"name":"(anonymous_51)","decl":{"start":{"line":260,"column":121},"end":{"line":260,"column":122}},"loc":{"start":{"line":260,"column":141},"end":{"line":263,"column":7}},"line":260},"52":{"name":"(anonymous_52)","decl":{"start":{"line":265,"column":60},"end":{"line":265,"column":61}},"loc":{"start":{"line":265,"column":76},"end":{"line":271,"column":5}},"line":265},"53":{"name":"(anonymous_53)","decl":{"start":{"line":267,"column":120},"end":{"line":267,"column":121}},"loc":{"start":{"line":267,"column":140},"end":{"line":270,"column":7}},"line":267},"54":{"name":"(anonymous_54)","decl":{"start":{"line":272,"column":77},"end":{"line":272,"column":78}},"loc":{"start":{"line":272,"column":93},"end":{"line":280,"column":5}},"line":272},"55":{"name":"(anonymous_55)","decl":{"start":{"line":274,"column":124},"end":{"line":274,"column":125}},"loc":{"start":{"line":274,"column":144},"end":{"line":279,"column":7}},"line":274},"56":{"name":"(anonymous_56)","decl":{"start":{"line":281,"column":63},"end":{"line":281,"column":64}},"loc":{"start":{"line":281,"column":79},"end":{"line":289,"column":5}},"line":281},"57":{"name":"(anonymous_57)","decl":{"start":{"line":283,"column":118},"end":{"line":283,"column":119}},"loc":{"start":{"line":283,"column":138},"end":{"line":288,"column":7}},"line":283}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":0,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":0,"140":0,"141":0,"142":0,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":0,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"9950cafa7535719075ca08f761476020d23ba2d4","contentHash":"2831e31d3c9421fa210c6980425495e9_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":49}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"5":{"start":{"line":15,"column":13},"end":{"line":17,"column":2}},"6":{"start":{"line":16,"column":2},"end":{"line":16,"column":63}},"7":{"start":{"line":19,"column":0},"end":{"line":19,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":44},"end":{"line":15,"column":45}},"loc":{"start":{"line":15,"column":56},"end":{"line":17,"column":1}},"line":15}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"type":"binary-expr","locations":[{"start":{"line":13,"column":11},"end":{"line":13,"column":27}},{"start":{"line":13,"column":31},"end":{"line":13,"column":35}}],"line":13}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1},"f":{"0":1,"1":1},"b":{"0":[1,0],"1":[1,1],"2":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"2c3f4d308d6c389ee08f6e68cdad1a35bf84c346","contentHash":"b011e4774c730a6764287d46023c385e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"4":{"start":{"line":13,"column":19},"end":{"line":13,"column":54}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":31}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":24},"end":{"line":19,"column":52}},"8":{"start":{"line":21,"column":25},"end":{"line":21,"column":66}},"9":{"start":{"line":23,"column":14},"end":{"line":23,"column":34}},"10":{"start":{"line":25,"column":15},"end":{"line":25,"column":46}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":10},"end":{"line":29,"column":34}},"13":{"start":{"line":31,"column":0},"end":{"line":31,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":37}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":62}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":43}},"17":{"start":{"line":37,"column":0},"end":{"line":46,"column":3}},"18":{"start":{"line":38,"column":13},"end":{"line":38,"column":21}},"19":{"start":{"line":39,"column":13},"end":{"line":39,"column":18}},"20":{"start":{"line":40,"column":2},"end":{"line":44,"column":4}},"21":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"22":{"start":{"line":41,"column":14},"end":{"line":41,"column":21}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":25}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":16}},"25":{"start":{"line":45,"column":2},"end":{"line":45,"column":9}},"26":{"start":{"line":49,"column":0},"end":{"line":49,"column":37}},"27":{"start":{"line":51,"column":0},"end":{"line":51,"column":22}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":8},"end":{"line":37,"column":9}},"loc":{"start":{"line":37,"column":34},"end":{"line":46,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":13},"end":{"line":40,"column":14}},"loc":{"start":{"line":40,"column":29},"end":{"line":44,"column":3}},"line":40}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27},"2":{"loc":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"type":"if","locations":[{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},{"start":{"line":41,"column":4},"end":{"line":41,"column":21}}],"line":41}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":76,"19":76,"20":76,"21":106,"22":4,"23":102,"24":102,"25":76,"26":1,"27":1},"f":{"0":5,"1":76,"2":106},"b":{"0":[1,4],"1":[5,5],"2":[4,102]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"631ffa56d34b584cfaaf514a9d3aab5ddb9550d2","contentHash":"68477734160cec3adc5d527b8a040a9b_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":31}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":33}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":17},"end":{"line":19,"column":39}},"8":{"start":{"line":21,"column":18},"end":{"line":21,"column":52}},"9":{"start":{"line":23,"column":13},"end":{"line":23,"column":31}},"10":{"start":{"line":25,"column":14},"end":{"line":25,"column":44}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":13},"end":{"line":29,"column":39}},"13":{"start":{"line":32,"column":0},"end":{"line":32,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":40}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":46}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":38}},"17":{"start":{"line":37,"column":0},"end":{"line":37,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1},"f":{"0":5},"b":{"0":[4,1],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"242d65573f043ccce04223bd6f51cdda15503f5f","contentHash":"3a58cb6f4391326b95f0cf67e2d870a0_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":34}},"10":{"start":{"line":30,"column":0},"end":{"line":32,"column":29}},"11":{"start":{"line":34,"column":0},"end":{"line":42,"column":64}},"12":{"start":{"line":44,"column":0},"end":{"line":46,"column":67}},"13":{"start":{"line":48,"column":0},"end":{"line":48,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a4c38addb0d124dbae4b2d5ea8e6e3d38cf94991","contentHash":"b6e317aa7a985adf5a98d45b1aa5fd24_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":20},"end":{"line":11,"column":43}},"4":{"start":{"line":13,"column":21},"end":{"line":13,"column":58}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"8":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"9":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"10":{"start":{"line":25,"column":0},"end":{"line":25,"column":27}},"11":{"start":{"line":27,"column":16},"end":{"line":27,"column":38}},"12":{"start":{"line":28,"column":15},"end":{"line":28,"column":40}},"13":{"start":{"line":29,"column":11},"end":{"line":29,"column":32}},"14":{"start":{"line":30,"column":15},"end":{"line":30,"column":50}},"15":{"start":{"line":39,"column":14},"end":{"line":39,"column":29}},"16":{"start":{"line":40,"column":15},"end":{"line":40,"column":31}},"17":{"start":{"line":41,"column":2},"end":{"line":54,"column":5}},"18":{"start":{"line":45,"column":15},"end":{"line":45,"column":24}},"19":{"start":{"line":46,"column":16},"end":{"line":46,"column":26}},"20":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"21":{"start":{"line":53,"column":4},"end":{"line":53,"column":39}},"22":{"start":{"line":64,"column":2},"end":{"line":64,"column":59}},"23":{"start":{"line":65,"column":2},"end":{"line":65,"column":59}},"24":{"start":{"line":66,"column":2},"end":{"line":66,"column":53}},"25":{"start":{"line":67,"column":2},"end":{"line":67,"column":59}},"26":{"start":{"line":68,"column":2},"end":{"line":68,"column":59}},"27":{"start":{"line":69,"column":2},"end":{"line":69,"column":85}},"28":{"start":{"line":70,"column":15},"end":{"line":70,"column":37}},"29":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"30":{"start":{"line":73,"column":4},"end":{"line":73,"column":45}},"31":{"start":{"line":75,"column":4},"end":{"line":95,"column":7}},"32":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"33":{"start":{"line":79,"column":8},"end":{"line":93,"column":11}},"34":{"start":{"line":86,"column":10},"end":{"line":90,"column":13}},"35":{"start":{"line":92,"column":10},"end":{"line":92,"column":38}},"36":{"start":{"line":106,"column":2},"end":{"line":106,"column":53}},"37":{"start":{"line":107,"column":2},"end":{"line":107,"column":59}},"38":{"start":{"line":108,"column":2},"end":{"line":108,"column":59}},"39":{"start":{"line":110,"column":15},"end":{"line":110,"column":37}},"40":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"41":{"start":{"line":113,"column":4},"end":{"line":113,"column":45}},"42":{"start":{"line":115,"column":4},"end":{"line":147,"column":7}},"43":{"start":{"line":118,"column":25},"end":{"line":118,"column":32}},"44":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"45":{"start":{"line":120,"column":8},"end":{"line":122,"column":63}},"46":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"47":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":125,"column":24},"end":{"line":130,"column":11}},"49":{"start":{"line":131,"column":22},"end":{"line":133,"column":12}},"50":{"start":{"line":134,"column":10},"end":{"line":137,"column":13}},"51":{"start":{"line":139,"column":10},"end":{"line":142,"column":13}},"52":{"start":{"line":146,"column":6},"end":{"line":146,"column":41}},"53":{"start":{"line":158,"column":18},"end":{"line":158,"column":39}},"54":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"55":{"start":{"line":160,"column":4},"end":{"line":162,"column":7}},"56":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"57":{"start":{"line":165,"column":4},"end":{"line":167,"column":7}},"58":{"start":{"line":169,"column":2},"end":{"line":181,"column":5}},"59":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"60":{"start":{"line":176,"column":6},"end":{"line":176,"column":58}},"61":{"start":{"line":178,"column":4},"end":{"line":178,"column":31}},"62":{"start":{"line":180,"column":4},"end":{"line":180,"column":39}},"63":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"64":{"start":{"line":192,"column":4},"end":{"line":194,"column":7}},"65":{"start":{"line":196,"column":15},"end":{"line":196,"column":36}},"66":{"start":{"line":197,"column":2},"end":{"line":225,"column":5}},"67":{"start":{"line":198,"column":4},"end":{"line":224,"column":7}},"68":{"start":{"line":199,"column":6},"end":{"line":223,"column":9}},"69":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"70":{"start":{"line":201,"column":10},"end":{"line":201,"column":69}},"71":{"start":{"line":203,"column":8},"end":{"line":220,"column":11}},"72":{"start":{"line":210,"column":10},"end":{"line":217,"column":13}},"73":{"start":{"line":219,"column":10},"end":{"line":219,"column":45}},"74":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"75":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"76":{"start":{"line":236,"column":4},"end":{"line":238,"column":7}},"77":{"start":{"line":240,"column":2},"end":{"line":252,"column":5}},"78":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"79":{"start":{"line":242,"column":6},"end":{"line":242,"column":65}},"80":{"start":{"line":244,"column":4},"end":{"line":249,"column":7}},"81":{"start":{"line":245,"column":6},"end":{"line":246,"column":57}},"82":{"start":{"line":248,"column":6},"end":{"line":248,"column":41}},"83":{"start":{"line":251,"column":4},"end":{"line":251,"column":39}},"84":{"start":{"line":263,"column":14},"end":{"line":263,"column":29}},"85":{"start":{"line":264,"column":15},"end":{"line":264,"column":31}},"86":{"start":{"line":265,"column":2},"end":{"line":290,"column":5}},"87":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"88":{"start":{"line":267,"column":6},"end":{"line":269,"column":9}},"89":{"start":{"line":271,"column":4},"end":{"line":287,"column":7}},"90":{"start":{"line":278,"column":21},"end":{"line":278,"column":31}},"91":{"start":{"line":279,"column":18},"end":{"line":279,"column":29}},"92":{"start":{"line":281,"column":6},"end":{"line":284,"column":9}},"93":{"start":{"line":286,"column":6},"end":{"line":286,"column":41}},"94":{"start":{"line":289,"column":4},"end":{"line":289,"column":39}},"95":{"start":{"line":293,"column":0},"end":{"line":301,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"getUsers","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":17}},"loc":{"start":{"line":38,"column":28},"end":{"line":55,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":44,"column":10},"end":{"line":44,"column":11}},"loc":{"start":{"line":44,"column":26},"end":{"line":52,"column":3}},"line":44},"3":{"name":"(anonymous_3)","decl":{"start":{"line":52,"column":11},"end":{"line":52,"column":12}},"loc":{"start":{"line":52,"column":28},"end":{"line":54,"column":3}},"line":52},"4":{"name":"createUser","decl":{"start":{"line":63,"column":9},"end":{"line":63,"column":19}},"loc":{"start":{"line":63,"column":30},"end":{"line":97,"column":1}},"line":63},"5":{"name":"(anonymous_5)","decl":{"start":{"line":77,"column":12},"end":{"line":77,"column":13}},"loc":{"start":{"line":77,"column":33},"end":{"line":95,"column":5}},"line":77},"6":{"name":"(anonymous_6)","decl":{"start":{"line":85,"column":16},"end":{"line":85,"column":17}},"loc":{"start":{"line":85,"column":39},"end":{"line":91,"column":9}},"line":85},"7":{"name":"(anonymous_7)","decl":{"start":{"line":91,"column":17},"end":{"line":91,"column":18}},"loc":{"start":{"line":91,"column":34},"end":{"line":93,"column":9}},"line":91},"8":{"name":"login","decl":{"start":{"line":105,"column":9},"end":{"line":105,"column":14}},"loc":{"start":{"line":105,"column":25},"end":{"line":149,"column":1}},"line":105},"9":{"name":"(anonymous_9)","decl":{"start":{"line":117,"column":12},"end":{"line":117,"column":13}},"loc":{"start":{"line":117,"column":28},"end":{"line":145,"column":5}},"line":117},"10":{"name":"(anonymous_10)","decl":{"start":{"line":145,"column":13},"end":{"line":145,"column":14}},"loc":{"start":{"line":145,"column":30},"end":{"line":147,"column":5}},"line":145},"11":{"name":"findUser","decl":{"start":{"line":157,"column":9},"end":{"line":157,"column":17}},"loc":{"start":{"line":157,"column":28},"end":{"line":182,"column":1}},"line":157},"12":{"name":"(anonymous_12)","decl":{"start":{"line":174,"column":10},"end":{"line":174,"column":11}},"loc":{"start":{"line":174,"column":26},"end":{"line":179,"column":3}},"line":174},"13":{"name":"(anonymous_13)","decl":{"start":{"line":179,"column":11},"end":{"line":179,"column":12}},"loc":{"start":{"line":179,"column":28},"end":{"line":181,"column":3}},"line":179},"14":{"name":"updateUser","decl":{"start":{"line":190,"column":9},"end":{"line":190,"column":19}},"loc":{"start":{"line":190,"column":30},"end":{"line":226,"column":1}},"line":190},"15":{"name":"(anonymous_15)","decl":{"start":{"line":197,"column":31},"end":{"line":197,"column":32}},"loc":{"start":{"line":197,"column":52},"end":{"line":225,"column":3}},"line":197},"16":{"name":"(anonymous_16)","decl":{"start":{"line":198,"column":51},"end":{"line":198,"column":52}},"loc":{"start":{"line":198,"column":72},"end":{"line":224,"column":5}},"line":198},"17":{"name":"(anonymous_17)","decl":{"start":{"line":199,"column":33},"end":{"line":199,"column":34}},"loc":{"start":{"line":199,"column":49},"end":{"line":221,"column":7}},"line":199},"18":{"name":"(anonymous_18)","decl":{"start":{"line":209,"column":16},"end":{"line":209,"column":17}},"loc":{"start":{"line":209,"column":39},"end":{"line":218,"column":9}},"line":209},"19":{"name":"(anonymous_19)","decl":{"start":{"line":218,"column":17},"end":{"line":218,"column":18}},"loc":{"start":{"line":218,"column":34},"end":{"line":220,"column":9}},"line":218},"20":{"name":"(anonymous_20)","decl":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"loc":{"start":{"line":221,"column":32},"end":{"line":223,"column":7}},"line":221},"21":{"name":"deleteUser","decl":{"start":{"line":234,"column":9},"end":{"line":234,"column":19}},"loc":{"start":{"line":234,"column":30},"end":{"line":253,"column":1}},"line":234},"22":{"name":"(anonymous_22)","decl":{"start":{"line":240,"column":43},"end":{"line":240,"column":44}},"loc":{"start":{"line":240,"column":59},"end":{"line":250,"column":3}},"line":240},"23":{"name":"(anonymous_23)","decl":{"start":{"line":244,"column":31},"end":{"line":244,"column":32}},"loc":{"start":{"line":244,"column":43},"end":{"line":247,"column":5}},"line":244},"24":{"name":"(anonymous_24)","decl":{"start":{"line":247,"column":13},"end":{"line":247,"column":14}},"loc":{"start":{"line":247,"column":30},"end":{"line":249,"column":5}},"line":247},"25":{"name":"(anonymous_25)","decl":{"start":{"line":250,"column":11},"end":{"line":250,"column":12}},"loc":{"start":{"line":250,"column":28},"end":{"line":252,"column":3}},"line":250},"26":{"name":"getUserDocuments","decl":{"start":{"line":262,"column":9},"end":{"line":262,"column":25}},"loc":{"start":{"line":262,"column":36},"end":{"line":291,"column":1}},"line":262},"27":{"name":"(anonymous_27)","decl":{"start":{"line":265,"column":36},"end":{"line":265,"column":37}},"loc":{"start":{"line":265,"column":52},"end":{"line":288,"column":3}},"line":265},"28":{"name":"(anonymous_28)","decl":{"start":{"line":277,"column":12},"end":{"line":277,"column":13}},"loc":{"start":{"line":277,"column":29},"end":{"line":285,"column":5}},"line":277},"29":{"name":"(anonymous_29)","decl":{"start":{"line":285,"column":13},"end":{"line":285,"column":14}},"loc":{"start":{"line":285,"column":30},"end":{"line":287,"column":5}},"line":285},"30":{"name":"(anonymous_30)","decl":{"start":{"line":288,"column":11},"end":{"line":288,"column":12}},"loc":{"start":{"line":288,"column":28},"end":{"line":290,"column":3}},"line":288}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23},"2":{"loc":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},{"start":{"line":72,"column":2},"end":{"line":96,"column":3}}],"line":72},"3":{"loc":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"type":"if","locations":[{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},{"start":{"line":78,"column":6},"end":{"line":94,"column":7}}],"line":78},"4":{"loc":{"start":{"line":84,"column":18},"end":{"line":84,"column":38}},"type":"binary-expr","locations":[{"start":{"line":84,"column":18},"end":{"line":84,"column":33}},{"start":{"line":84,"column":37},"end":{"line":84,"column":38}}],"line":84},"5":{"loc":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"type":"if","locations":[{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},{"start":{"line":112,"column":2},"end":{"line":148,"column":3}}],"line":112},"6":{"loc":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},{"start":{"line":119,"column":6},"end":{"line":144,"column":7}}],"line":119},"7":{"loc":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},{"start":{"line":123,"column":13},"end":{"line":144,"column":7}}],"line":123},"8":{"loc":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"type":"if","locations":[{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},{"start":{"line":124,"column":8},"end":{"line":143,"column":9}}],"line":124},"9":{"loc":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"type":"if","locations":[{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},{"start":{"line":159,"column":2},"end":{"line":163,"column":3}}],"line":159},"10":{"loc":{"start":{"line":159,"column":6},"end":{"line":159,"column":62}},"type":"binary-expr","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":34}},{"start":{"line":159,"column":38},"end":{"line":159,"column":62}}],"line":159},"11":{"loc":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},{"start":{"line":164,"column":2},"end":{"line":168,"column":3}}],"line":164},"12":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"13":{"loc":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"type":"if","locations":[{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},{"start":{"line":191,"column":2},"end":{"line":195,"column":3}}],"line":191},"14":{"loc":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"type":"if","locations":[{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},{"start":{"line":200,"column":8},"end":{"line":202,"column":9}}],"line":200},"15":{"loc":{"start":{"line":204,"column":20},"end":{"line":204,"column":54}},"type":"binary-expr","locations":[{"start":{"line":204,"column":20},"end":{"line":204,"column":37}},{"start":{"line":204,"column":41},"end":{"line":204,"column":54}}],"line":204},"16":{"loc":{"start":{"line":205,"column":20},"end":{"line":205,"column":54}},"type":"binary-expr","locations":[{"start":{"line":205,"column":20},"end":{"line":205,"column":37}},{"start":{"line":205,"column":41},"end":{"line":205,"column":54}}],"line":205},"17":{"loc":{"start":{"line":206,"column":17},"end":{"line":206,"column":45}},"type":"binary-expr","locations":[{"start":{"line":206,"column":17},"end":{"line":206,"column":31}},{"start":{"line":206,"column":35},"end":{"line":206,"column":45}}],"line":206},"18":{"loc":{"start":{"line":207,"column":20},"end":{"line":207,"column":41}},"type":"binary-expr","locations":[{"start":{"line":207,"column":20},"end":{"line":207,"column":24}},{"start":{"line":207,"column":28},"end":{"line":207,"column":41}}],"line":207},"19":{"loc":{"start":{"line":208,"column":18},"end":{"line":208,"column":48}},"type":"binary-expr","locations":[{"start":{"line":208,"column":18},"end":{"line":208,"column":33}},{"start":{"line":208,"column":37},"end":{"line":208,"column":48}}],"line":208},"20":{"loc":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"type":"if","locations":[{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},{"start":{"line":235,"column":2},"end":{"line":239,"column":3}}],"line":235},"21":{"loc":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},{"start":{"line":241,"column":4},"end":{"line":243,"column":5}}],"line":241},"22":{"loc":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"type":"if","locations":[{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},{"start":{"line":266,"column":4},"end":{"line":270,"column":5}}],"line":266}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":4,"10":1,"11":1,"12":1,"13":1,"14":1,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":0,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":0,"31":1,"32":1,"33":1,"34":1,"35":0,"36":15,"37":15,"38":15,"39":15,"40":15,"41":0,"42":15,"43":15,"44":15,"45":1,"46":14,"47":14,"48":13,"49":13,"50":13,"51":1,"52":0,"53":5,"54":5,"55":0,"56":5,"57":1,"58":4,"59":3,"60":1,"61":3,"62":1,"63":5,"64":2,"65":3,"66":3,"67":3,"68":3,"69":3,"70":0,"71":3,"72":3,"73":0,"74":0,"75":3,"76":1,"77":2,"78":2,"79":1,"80":1,"81":1,"82":0,"83":0,"84":2,"85":2,"86":2,"87":2,"88":1,"89":1,"90":1,"91":1,"92":1,"93":0,"94":0,"95":1},"f":{"0":4,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":15,"9":15,"10":0,"11":5,"12":3,"13":1,"14":5,"15":3,"16":3,"17":3,"18":3,"19":0,"20":0,"21":3,"22":2,"23":1,"24":0,"25":0,"26":2,"27":2,"28":1,"29":0,"30":0},"b":{"0":[0,4],"1":[4,4],"2":[0,1],"3":[1,0],"4":[1,0],"5":[0,15],"6":[1,14],"7":[14,0],"8":[13,1],"9":[0,5],"10":[5,4],"11":[1,4],"12":[1,2],"13":[2,3],"14":[0,3],"15":[3,2],"16":[3,2],"17":[3,2],"18":[3,3],"19":[3,3],"20":[1,2],"21":[1,1],"22":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a873f3a1e83910dd4a7534a9fab6445e85d48e8a","contentHash":"8f158652d1e645800e331a339c32bd94_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":10,"column":1}},"1":{"start":{"line":4,"column":2},"end":{"line":9,"column":4}},"2":{"start":{"line":12,"column":0},"end":{"line":12,"column":55}}},"fnMap":{"0":{"name":"paginationMetaData","decl":{"start":{"line":3,"column":34},"end":{"line":3,"column":52}},"loc":{"start":{"line":3,"column":75},"end":{"line":10,"column":1}},"line":3}},"branchMap":{},"s":{"0":1,"1":6,"2":1},"f":{"0":6},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"4465f4d163a5ad4fee78e39a1eef0f59ca60bcc2","contentHash":"65216cd25fbea3beb9fe0dfec073fc7e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js","statementMap":{"0":{"start":{"line":3,"column":9},"end":{"line":3,"column":22}},"1":{"start":{"line":4,"column":11},"end":{"line":4,"column":26}},"2":{"start":{"line":5,"column":16},"end":{"line":5,"column":36}},"3":{"start":{"line":7,"column":15},"end":{"line":7,"column":45}},"4":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"5":{"start":{"line":9,"column":13},"end":{"line":9,"column":48}},"6":{"start":{"line":11,"column":9},"end":{"line":11,"column":11}},"7":{"start":{"line":13,"column":16},"end":{"line":13,"column":22}},"8":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"9":{"start":{"line":15,"column":2},"end":{"line":15,"column":66}},"10":{"start":{"line":17,"column":2},"end":{"line":17,"column":87}},"11":{"start":{"line":20,"column":0},"end":{"line":25,"column":3}},"12":{"start":{"line":21,"column":2},"end":{"line":21,"column":82}},"13":{"start":{"line":23,"column":14},"end":{"line":23,"column":58}},"14":{"start":{"line":24,"column":2},"end":{"line":24,"column":25}},"15":{"start":{"line":27,"column":0},"end":{"line":31,"column":3}},"16":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"17":{"start":{"line":29,"column":4},"end":{"line":29,"column":32}},"18":{"start":{"line":33,"column":0},"end":{"line":33,"column":25}},"19":{"start":{"line":34,"column":0},"end":{"line":34,"column":25}},"20":{"start":{"line":36,"column":0},"end":{"line":36,"column":20}},"21":{"start":{"line":38,"column":0},"end":{"line":38,"column":25}},"22":{"start":{"line":39,"column":0},"end":{"line":39,"column":25}},"23":{"start":{"line":41,"column":0},"end":{"line":41,"column":20}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":33},"end":{"line":20,"column":34}},"loc":{"start":{"line":20,"column":49},"end":{"line":22,"column":1}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":22,"column":11},"end":{"line":22,"column":12}},"loc":{"start":{"line":22,"column":27},"end":{"line":25,"column":1}},"line":22},"2":{"name":"(anonymous_2)","decl":{"start":{"line":27,"column":24},"end":{"line":27,"column":25}},"loc":{"start":{"line":27,"column":45},"end":{"line":31,"column":1}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"type":"binary-expr","locations":[{"start":{"line":8,"column":10},"end":{"line":8,"column":30}},{"start":{"line":8,"column":34},"end":{"line":8,"column":47}}],"line":8},"1":{"loc":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"type":"if","locations":[{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},{"start":{"line":14,"column":0},"end":{"line":18,"column":1}}],"line":14},"2":{"loc":{"start":{"line":21,"column":9},"end":{"line":21,"column":81}},"type":"binary-expr","locations":[{"start":{"line":21,"column":9},"end":{"line":21,"column":32}},{"start":{"line":21,"column":36},"end":{"line":21,"column":53}},{"start":{"line":21,"column":57},"end":{"line":21,"column":81}}],"line":21},"3":{"loc":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"type":"if","locations":[{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},{"start":{"line":28,"column":2},"end":{"line":30,"column":3}}],"line":28}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":1,"11":1,"12":4,"13":3,"14":3,"15":1,"16":3,"17":3,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1},"f":{"0":4,"1":3,"2":3},"b":{"0":[1,0],"1":[0,1],"2":[4,4,3],"3":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"873e872266ec01d9da7d7ec0d8cff9eeebab65b3","contentHash":"147d2f5ce718f5d34ee69e59b4b18b17_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":27,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a1ab92e502a6f44216fbf97c5e3b416d2cdd1c15","contentHash":"bfdbdb10808231c6b80faf6c05504184_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":30,"column":2}},"1":{"start":{"line":4,"column":17},"end":{"line":22,"column":4}},"2":{"start":{"line":23,"column":2},"end":{"line":28,"column":4}},"3":{"start":{"line":25,"column":4},"end":{"line":27,"column":7}},"4":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":30,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":23,"column":23},"end":{"line":23,"column":24}},"loc":{"start":{"line":23,"column":41},"end":{"line":28,"column":3}},"line":23}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"40f538af399cb910f51ef1c6e4b9fa7626ac8040","contentHash":"ebe8d40228054cd49ad96bbdc1301e25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":18,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":10,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":13,"column":4},"end":{"line":15,"column":7}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":18,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":11,"column":19},"end":{"line":11,"column":20}},"loc":{"start":{"line":11,"column":37},"end":{"line":16,"column":3}},"line":11}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1aba90d94e80bdb0379ea9ddd4c53cf22a593f71","contentHash":"b22cffd605cf93f69a3f2719a0d065e3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":42,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":28,"column":4}},"2":{"start":{"line":29,"column":2},"end":{"line":40,"column":4}},"3":{"start":{"line":31,"column":4},"end":{"line":35,"column":7}},"4":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"5":{"start":{"line":41,"column":2},"end":{"line":41,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":42,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":19},"end":{"line":29,"column":20}},"loc":{"start":{"line":29,"column":37},"end":{"line":40,"column":3}},"line":29}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1296338becccf35da8d16bf6f6a410038393a663","contentHash":"e3e5a8798513104b93e617b86fce0484_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":20},"end":{"line":7,"column":43}},"2":{"start":{"line":9,"column":21},"end":{"line":9,"column":58}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":16},"end":{"line":13,"column":38}},"5":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"6":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"7":{"start":{"line":18,"column":4},"end":{"line":25,"column":7}},"8":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"9":{"start":{"line":20,"column":8},"end":{"line":20,"column":79}},"10":{"start":{"line":22,"column":8},"end":{"line":22,"column":30}},"11":{"start":{"line":23,"column":8},"end":{"line":23,"column":15}},"12":{"start":{"line":27,"column":4},"end":{"line":30,"column":7}},"13":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"14":{"start":{"line":36,"column":4},"end":{"line":36,"column":11}},"15":{"start":{"line":38,"column":4},"end":{"line":40,"column":7}},"16":{"start":{"line":44,"column":0},"end":{"line":44,"column":73}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"verifyToken","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":20}},"loc":{"start":{"line":15,"column":37},"end":{"line":32,"column":1}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":18,"column":52},"end":{"line":18,"column":53}},"loc":{"start":{"line":18,"column":76},"end":{"line":25,"column":5}},"line":18},"3":{"name":"adminAccess","decl":{"start":{"line":34,"column":9},"end":{"line":34,"column":20}},"loc":{"start":{"line":34,"column":37},"end":{"line":42,"column":1}},"line":34}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"type":"binary-expr","locations":[{"start":{"line":16,"column":14},"end":{"line":16,"column":39}},{"start":{"line":16,"column":43},"end":{"line":16,"column":72}}],"line":16},"3":{"loc":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},{"start":{"line":17,"column":2},"end":{"line":31,"column":3}}],"line":17},"4":{"loc":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"type":"if","locations":[{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},{"start":{"line":19,"column":6},"end":{"line":24,"column":7}}],"line":19},"5":{"loc":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},{"start":{"line":35,"column":2},"end":{"line":41,"column":3}}],"line":35}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":60,"6":60,"7":56,"8":56,"9":0,"10":56,"11":56,"12":4,"13":21,"14":15,"15":6,"16":1},"f":{"0":1,"1":60,"2":56,"3":21},"b":{"0":[0,1],"1":[1,1],"2":[60,4],"3":[56,4],"4":[0,56],"5":[15,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ecc14d1e97432b8e57f39e5c505683a335fe6c8b","contentHash":"319c6e9c3dd86dee4e26cb1f933899cc_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":46}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":25,"column":90}},"10":{"start":{"line":27,"column":0},"end":{"line":29,"column":95}},"11":{"start":{"line":31,"column":0},"end":{"line":31,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"68b3619793c37e6d78583f4e6d35dc746e22808b","contentHash":"1708591ee5a07428c3cfae7deaa863aa_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":20},"end":{"line":28,"column":31}},"10":{"start":{"line":29,"column":14},"end":{"line":29,"column":29}},"11":{"start":{"line":30,"column":15},"end":{"line":30,"column":31}},"12":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"13":{"start":{"line":32,"column":4},"end":{"line":34,"column":7}},"14":{"start":{"line":36,"column":2},"end":{"line":58,"column":5}},"15":{"start":{"line":46,"column":15},"end":{"line":46,"column":24}},"16":{"start":{"line":47,"column":16},"end":{"line":47,"column":26}},"17":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"18":{"start":{"line":50,"column":6},"end":{"line":50,"column":65}},"19":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"20":{"start":{"line":57,"column":4},"end":{"line":57,"column":39}},"21":{"start":{"line":69,"column":14},"end":{"line":69,"column":29}},"22":{"start":{"line":70,"column":15},"end":{"line":70,"column":31}},"23":{"start":{"line":71,"column":20},"end":{"line":71,"column":31}},"24":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"25":{"start":{"line":73,"column":4},"end":{"line":75,"column":7}},"26":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"27":{"start":{"line":78,"column":4},"end":{"line":106,"column":7}},"28":{"start":{"line":94,"column":21},"end":{"line":94,"column":31}},"29":{"start":{"line":95,"column":18},"end":{"line":95,"column":29}},"30":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"31":{"start":{"line":98,"column":8},"end":{"line":98,"column":64}},"32":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"33":{"start":{"line":105,"column":6},"end":{"line":105,"column":41}},"34":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"35":{"start":{"line":108,"column":4},"end":{"line":140,"column":7}},"36":{"start":{"line":128,"column":21},"end":{"line":128,"column":31}},"37":{"start":{"line":129,"column":18},"end":{"line":129,"column":29}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"39":{"start":{"line":132,"column":8},"end":{"line":132,"column":64}},"40":{"start":{"line":134,"column":6},"end":{"line":137,"column":9}},"41":{"start":{"line":139,"column":6},"end":{"line":139,"column":41}},"42":{"start":{"line":144,"column":0},"end":{"line":144,"column":79}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"searchUser","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":19}},"loc":{"start":{"line":27,"column":30},"end":{"line":59,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":45,"column":10},"end":{"line":45,"column":11}},"loc":{"start":{"line":45,"column":26},"end":{"line":56,"column":3}},"line":45},"3":{"name":"(anonymous_3)","decl":{"start":{"line":56,"column":11},"end":{"line":56,"column":12}},"loc":{"start":{"line":56,"column":28},"end":{"line":58,"column":3}},"line":56},"4":{"name":"searchDocuments","decl":{"start":{"line":68,"column":9},"end":{"line":68,"column":24}},"loc":{"start":{"line":68,"column":35},"end":{"line":142,"column":1}},"line":68},"5":{"name":"(anonymous_5)","decl":{"start":{"line":93,"column":12},"end":{"line":93,"column":13}},"loc":{"start":{"line":93,"column":29},"end":{"line":104,"column":5}},"line":93},"6":{"name":"(anonymous_6)","decl":{"start":{"line":104,"column":13},"end":{"line":104,"column":14}},"loc":{"start":{"line":104,"column":30},"end":{"line":106,"column":5}},"line":104},"7":{"name":"(anonymous_7)","decl":{"start":{"line":127,"column":12},"end":{"line":127,"column":13}},"loc":{"start":{"line":127,"column":29},"end":{"line":138,"column":5}},"line":127},"8":{"name":"(anonymous_8)","decl":{"start":{"line":138,"column":13},"end":{"line":138,"column":14}},"loc":{"start":{"line":138,"column":30},"end":{"line":140,"column":5}},"line":138}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"type":"if","locations":[{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},{"start":{"line":31,"column":2},"end":{"line":35,"column":3}}],"line":31},"3":{"loc":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"type":"if","locations":[{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},{"start":{"line":49,"column":4},"end":{"line":51,"column":5}}],"line":49},"4":{"loc":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},{"start":{"line":72,"column":2},"end":{"line":76,"column":3}}],"line":72},"5":{"loc":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},{"start":{"line":77,"column":2},"end":{"line":141,"column":3}}],"line":77},"6":{"loc":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"type":"if","locations":[{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},{"start":{"line":97,"column":6},"end":{"line":99,"column":7}}],"line":97},"7":{"loc":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},{"start":{"line":107,"column":9},"end":{"line":141,"column":3}}],"line":107},"8":{"loc":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"type":"if","locations":[{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},{"start":{"line":131,"column":6},"end":{"line":133,"column":7}}],"line":131}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,2],"1":[2,2],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"6efc7327907302db1883f00d2862afff115a5da3","contentHash":"50e871939ef4ea62c58b58df2dfa2014_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":17},"end":{"line":11,"column":52}},"4":{"start":{"line":13,"column":18},"end":{"line":13,"column":52}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":70}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":72}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63cb1e0c24d02fe76a86b13384c3b6510a628d08","contentHash":"befe059d51eace8d5b2b154e0976915f_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":2},"end":{"line":28,"column":53}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":57}},"11":{"start":{"line":30,"column":2},"end":{"line":30,"column":59}},"12":{"start":{"line":32,"column":15},"end":{"line":32,"column":37}},"13":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"14":{"start":{"line":35,"column":4},"end":{"line":35,"column":45}},"15":{"start":{"line":37,"column":4},"end":{"line":59,"column":7}},"16":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"17":{"start":{"line":43,"column":8},"end":{"line":52,"column":11}},"18":{"start":{"line":49,"column":10},"end":{"line":49,"column":56}},"19":{"start":{"line":51,"column":10},"end":{"line":51,"column":45}},"20":{"start":{"line":54,"column":6},"end":{"line":56,"column":9}},"21":{"start":{"line":58,"column":6},"end":{"line":58,"column":41}},"22":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"23":{"start":{"line":71,"column":4},"end":{"line":71,"column":27}},"24":{"start":{"line":73,"column":14},"end":{"line":73,"column":35}},"25":{"start":{"line":74,"column":2},"end":{"line":97,"column":5}},"26":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"27":{"start":{"line":76,"column":6},"end":{"line":78,"column":9}},"28":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"29":{"start":{"line":81,"column":6},"end":{"line":83,"column":9}},"30":{"start":{"line":85,"column":4},"end":{"line":94,"column":7}},"31":{"start":{"line":91,"column":6},"end":{"line":91,"column":44}},"32":{"start":{"line":93,"column":6},"end":{"line":93,"column":41}},"33":{"start":{"line":96,"column":4},"end":{"line":96,"column":39}},"34":{"start":{"line":107,"column":14},"end":{"line":107,"column":29}},"35":{"start":{"line":108,"column":15},"end":{"line":108,"column":31}},"36":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"37":{"start":{"line":110,"column":4},"end":{"line":132,"column":7}},"38":{"start":{"line":123,"column":21},"end":{"line":123,"column":30}},"39":{"start":{"line":124,"column":18},"end":{"line":124,"column":28}},"40":{"start":{"line":126,"column":6},"end":{"line":129,"column":9}},"41":{"start":{"line":131,"column":6},"end":{"line":131,"column":41}},"42":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"43":{"start":{"line":134,"column":4},"end":{"line":160,"column":7}},"44":{"start":{"line":151,"column":21},"end":{"line":151,"column":31}},"45":{"start":{"line":152,"column":18},"end":{"line":152,"column":29}},"46":{"start":{"line":154,"column":6},"end":{"line":157,"column":9}},"47":{"start":{"line":159,"column":6},"end":{"line":159,"column":41}},"48":{"start":{"line":171,"column":2},"end":{"line":203,"column":5}},"49":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"50":{"start":{"line":173,"column":6},"end":{"line":173,"column":62}},"51":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"52":{"start":{"line":176,"column":6},"end":{"line":176,"column":22}},"53":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"54":{"start":{"line":179,"column":6},"end":{"line":179,"column":44}},"55":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"56":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"57":{"start":{"line":183,"column":8},"end":{"line":185,"column":11}},"58":{"start":{"line":187,"column":6},"end":{"line":187,"column":44}},"59":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"60":{"start":{"line":190,"column":6},"end":{"line":199,"column":9}},"61":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"62":{"start":{"line":192,"column":10},"end":{"line":194,"column":13}},"63":{"start":{"line":196,"column":8},"end":{"line":196,"column":46}},"64":{"start":{"line":198,"column":8},"end":{"line":198,"column":43}},"65":{"start":{"line":202,"column":4},"end":{"line":202,"column":39}},"66":{"start":{"line":214,"column":2},"end":{"line":230,"column":5}},"67":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"68":{"start":{"line":216,"column":6},"end":{"line":216,"column":62}},"69":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"70":{"start":{"line":219,"column":6},"end":{"line":221,"column":9}},"71":{"start":{"line":223,"column":4},"end":{"line":227,"column":7}},"72":{"start":{"line":224,"column":6},"end":{"line":224,"column":80}},"73":{"start":{"line":226,"column":6},"end":{"line":226,"column":41}},"74":{"start":{"line":229,"column":4},"end":{"line":229,"column":39}},"75":{"start":{"line":233,"column":0},"end":{"line":238,"column":35}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"createDocument","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":23}},"loc":{"start":{"line":27,"column":34},"end":{"line":61,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":41,"column":12},"end":{"line":41,"column":13}},"loc":{"start":{"line":41,"column":32},"end":{"line":57,"column":5}},"line":41},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":16},"end":{"line":48,"column":17}},"loc":{"start":{"line":48,"column":44},"end":{"line":50,"column":9}},"line":48},"4":{"name":"(anonymous_4)","decl":{"start":{"line":50,"column":17},"end":{"line":50,"column":18}},"loc":{"start":{"line":50,"column":34},"end":{"line":52,"column":9}},"line":50},"5":{"name":"(anonymous_5)","decl":{"start":{"line":57,"column":13},"end":{"line":57,"column":14}},"loc":{"start":{"line":57,"column":30},"end":{"line":59,"column":5}},"line":57},"6":{"name":"updateDocument","decl":{"start":{"line":69,"column":9},"end":{"line":69,"column":23}},"loc":{"start":{"line":69,"column":34},"end":{"line":98,"column":1}},"line":69},"7":{"name":"(anonymous_7)","decl":{"start":{"line":74,"column":39},"end":{"line":74,"column":40}},"loc":{"start":{"line":74,"column":59},"end":{"line":95,"column":3}},"line":74},"8":{"name":"(anonymous_8)","decl":{"start":{"line":90,"column":12},"end":{"line":90,"column":13}},"loc":{"start":{"line":90,"column":24},"end":{"line":92,"column":5}},"line":90},"9":{"name":"(anonymous_9)","decl":{"start":{"line":92,"column":13},"end":{"line":92,"column":14}},"loc":{"start":{"line":92,"column":30},"end":{"line":94,"column":5}},"line":92},"10":{"name":"(anonymous_10)","decl":{"start":{"line":95,"column":11},"end":{"line":95,"column":12}},"loc":{"start":{"line":95,"column":28},"end":{"line":97,"column":3}},"line":95},"11":{"name":"getAllDocument","decl":{"start":{"line":106,"column":9},"end":{"line":106,"column":23}},"loc":{"start":{"line":106,"column":34},"end":{"line":162,"column":1}},"line":106},"12":{"name":"(anonymous_12)","decl":{"start":{"line":122,"column":12},"end":{"line":122,"column":13}},"loc":{"start":{"line":122,"column":28},"end":{"line":130,"column":5}},"line":122},"13":{"name":"(anonymous_13)","decl":{"start":{"line":130,"column":13},"end":{"line":130,"column":14}},"loc":{"start":{"line":130,"column":30},"end":{"line":132,"column":5}},"line":130},"14":{"name":"(anonymous_14)","decl":{"start":{"line":150,"column":12},"end":{"line":150,"column":13}},"loc":{"start":{"line":150,"column":29},"end":{"line":158,"column":5}},"line":150},"15":{"name":"(anonymous_15)","decl":{"start":{"line":158,"column":13},"end":{"line":158,"column":14}},"loc":{"start":{"line":158,"column":30},"end":{"line":160,"column":5}},"line":158},"16":{"name":"findDocument","decl":{"start":{"line":170,"column":9},"end":{"line":170,"column":21}},"loc":{"start":{"line":170,"column":32},"end":{"line":204,"column":1}},"line":170},"17":{"name":"(anonymous_17)","decl":{"start":{"line":171,"column":47},"end":{"line":171,"column":48}},"loc":{"start":{"line":171,"column":67},"end":{"line":201,"column":3}},"line":171},"18":{"name":"(anonymous_18)","decl":{"start":{"line":190,"column":66},"end":{"line":190,"column":67}},"loc":{"start":{"line":190,"column":91},"end":{"line":197,"column":7}},"line":190},"19":{"name":"(anonymous_19)","decl":{"start":{"line":197,"column":15},"end":{"line":197,"column":16}},"loc":{"start":{"line":197,"column":32},"end":{"line":199,"column":7}},"line":197},"20":{"name":"(anonymous_20)","decl":{"start":{"line":201,"column":11},"end":{"line":201,"column":12}},"loc":{"start":{"line":201,"column":28},"end":{"line":203,"column":3}},"line":201},"21":{"name":"deleteDocument","decl":{"start":{"line":213,"column":9},"end":{"line":213,"column":23}},"loc":{"start":{"line":213,"column":34},"end":{"line":231,"column":1}},"line":213},"22":{"name":"(anonymous_22)","decl":{"start":{"line":214,"column":47},"end":{"line":214,"column":48}},"loc":{"start":{"line":214,"column":67},"end":{"line":228,"column":3}},"line":214},"23":{"name":"(anonymous_23)","decl":{"start":{"line":223,"column":35},"end":{"line":223,"column":36}},"loc":{"start":{"line":223,"column":47},"end":{"line":225,"column":5}},"line":223},"24":{"name":"(anonymous_24)","decl":{"start":{"line":225,"column":13},"end":{"line":225,"column":14}},"loc":{"start":{"line":225,"column":30},"end":{"line":227,"column":5}},"line":225},"25":{"name":"(anonymous_25)","decl":{"start":{"line":228,"column":11},"end":{"line":228,"column":12}},"loc":{"start":{"line":228,"column":28},"end":{"line":230,"column":3}},"line":228}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},{"start":{"line":34,"column":2},"end":{"line":60,"column":3}}],"line":34},"3":{"loc":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"type":"if","locations":[{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},{"start":{"line":42,"column":6},"end":{"line":53,"column":7}}],"line":42},"4":{"loc":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"type":"if","locations":[{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},{"start":{"line":70,"column":2},"end":{"line":72,"column":3}}],"line":70},"5":{"loc":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},{"start":{"line":75,"column":4},"end":{"line":79,"column":5}}],"line":75},"6":{"loc":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"type":"if","locations":[{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},{"start":{"line":80,"column":4},"end":{"line":84,"column":5}}],"line":80},"7":{"loc":{"start":{"line":86,"column":13},"end":{"line":86,"column":45}},"type":"binary-expr","locations":[{"start":{"line":86,"column":13},"end":{"line":86,"column":27}},{"start":{"line":86,"column":31},"end":{"line":86,"column":45}}],"line":86},"8":{"loc":{"start":{"line":87,"column":15},"end":{"line":87,"column":51}},"type":"binary-expr","locations":[{"start":{"line":87,"column":15},"end":{"line":87,"column":31}},{"start":{"line":87,"column":35},"end":{"line":87,"column":51}}],"line":87},"9":{"loc":{"start":{"line":88,"column":14},"end":{"line":88,"column":47}},"type":"binary-expr","locations":[{"start":{"line":88,"column":14},"end":{"line":88,"column":28}},{"start":{"line":88,"column":32},"end":{"line":88,"column":47}}],"line":88},"10":{"loc":{"start":{"line":89,"column":14},"end":{"line":89,"column":48}},"type":"binary-expr","locations":[{"start":{"line":89,"column":14},"end":{"line":89,"column":29}},{"start":{"line":89,"column":33},"end":{"line":89,"column":48}}],"line":89},"11":{"loc":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},{"start":{"line":109,"column":2},"end":{"line":161,"column":3}}],"line":109},"12":{"loc":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},{"start":{"line":133,"column":9},"end":{"line":161,"column":3}}],"line":133},"13":{"loc":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},{"start":{"line":172,"column":4},"end":{"line":174,"column":5}}],"line":172},"14":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"15":{"loc":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"type":"if","locations":[{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},{"start":{"line":178,"column":4},"end":{"line":180,"column":5}}],"line":178},"16":{"loc":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"type":"if","locations":[{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},{"start":{"line":181,"column":4},"end":{"line":188,"column":5}}],"line":181},"17":{"loc":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"type":"if","locations":[{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},{"start":{"line":182,"column":6},"end":{"line":186,"column":7}}],"line":182},"18":{"loc":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"type":"if","locations":[{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},{"start":{"line":189,"column":4},"end":{"line":200,"column":5}}],"line":189},"19":{"loc":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"type":"if","locations":[{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},{"start":{"line":191,"column":8},"end":{"line":195,"column":9}}],"line":191},"20":{"loc":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"type":"if","locations":[{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},{"start":{"line":215,"column":4},"end":{"line":217,"column":5}}],"line":215},"21":{"loc":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"type":"if","locations":[{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},{"start":{"line":218,"column":4},"end":{"line":222,"column":5}}],"line":218},"22":{"loc":{"start":{"line":218,"column":8},"end":{"line":218,"column":86}},"type":"binary-expr","locations":[{"start":{"line":218,"column":8},"end":{"line":218,"column":32}},{"start":{"line":218,"column":36},"end":{"line":218,"column":86}}],"line":218}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":2,"10":2,"11":2,"12":2,"13":2,"14":1,"15":1,"16":1,"17":1,"18":1,"19":0,"20":0,"21":0,"22":4,"23":0,"24":4,"25":4,"26":4,"27":1,"28":3,"29":2,"30":1,"31":1,"32":0,"33":0,"34":3,"35":3,"36":3,"37":0,"38":0,"39":0,"40":0,"41":0,"42":3,"43":3,"44":3,"45":3,"46":3,"47":0,"48":7,"49":7,"50":1,"51":7,"52":1,"53":6,"54":1,"55":4,"56":2,"57":1,"58":1,"59":2,"60":2,"61":2,"62":1,"63":1,"64":0,"65":1,"66":4,"67":4,"68":1,"69":4,"70":1,"71":2,"72":2,"73":0,"74":1,"75":1},"f":{"0":2,"1":2,"2":1,"3":1,"4":0,"5":0,"6":4,"7":4,"8":1,"9":0,"10":0,"11":3,"12":0,"13":0,"14":3,"15":0,"16":7,"17":7,"18":2,"19":0,"20":1,"21":4,"22":4,"23":2,"24":0,"25":1},"b":{"0":[0,2],"1":[2,2],"2":[1,1],"3":[1,0],"4":[0,4],"5":[1,3],"6":[2,1],"7":[1,0],"8":[1,1],"9":[1,1],"10":[1,1],"11":[0,3],"12":[3,0],"13":[1,6],"14":[1,6],"15":[1,4],"16":[2,2],"17":[1,1],"18":[2,0],"19":[1,1],"20":[1,3],"21":[1,2],"22":[4,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0a4bf26938869e9b89bab568412c349bc1ff0083","contentHash":"deda95ed23abba3b13e7ef198467fe3e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":90}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":92}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63a3e651f707e94ed97ec659690592a0c340c6bd","contentHash":"85e8e83b7f1e99d944d489a44ed72bce_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":6,"column":13},"end":{"line":6,"column":33}},"2":{"start":{"line":8,"column":11},"end":{"line":8,"column":22}},"3":{"start":{"line":17,"column":2},"end":{"line":17,"column":53}},"4":{"start":{"line":19,"column":15},"end":{"line":19,"column":37}},"5":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"6":{"start":{"line":21,"column":4},"end":{"line":21,"column":45}},"7":{"start":{"line":23,"column":4},"end":{"line":40,"column":7}},"8":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"9":{"start":{"line":27,"column":8},"end":{"line":36,"column":11}},"10":{"start":{"line":30,"column":10},"end":{"line":33,"column":13}},"11":{"start":{"line":35,"column":10},"end":{"line":35,"column":33}},"12":{"start":{"line":39,"column":6},"end":{"line":39,"column":29}},"13":{"start":{"line":51,"column":2},"end":{"line":55,"column":5}},"14":{"start":{"line":52,"column":4},"end":{"line":52,"column":38}},"15":{"start":{"line":54,"column":4},"end":{"line":54,"column":27}},"16":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"17":{"start":{"line":66,"column":4},"end":{"line":68,"column":7}},"18":{"start":{"line":70,"column":4},"end":{"line":79,"column":7}},"19":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"20":{"start":{"line":72,"column":8},"end":{"line":74,"column":11}},"21":{"start":{"line":76,"column":6},"end":{"line":76,"column":33}},"22":{"start":{"line":78,"column":6},"end":{"line":78,"column":41}},"23":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"24":{"start":{"line":91,"column":4},"end":{"line":91,"column":90}},"25":{"start":{"line":93,"column":2},"end":{"line":111,"column":5}},"26":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"27":{"start":{"line":95,"column":6},"end":{"line":97,"column":9}},"28":{"start":{"line":99,"column":4},"end":{"line":108,"column":7}},"29":{"start":{"line":102,"column":6},"end":{"line":105,"column":9}},"30":{"start":{"line":107,"column":6},"end":{"line":107,"column":41}},"31":{"start":{"line":110,"column":4},"end":{"line":110,"column":39}},"32":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"33":{"start":{"line":122,"column":4},"end":{"line":122,"column":90}},"34":{"start":{"line":124,"column":2},"end":{"line":139,"column":5}},"35":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"36":{"start":{"line":126,"column":6},"end":{"line":128,"column":9}},"37":{"start":{"line":130,"column":4},"end":{"line":136,"column":7}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":9}},"39":{"start":{"line":135,"column":6},"end":{"line":135,"column":41}},"40":{"start":{"line":138,"column":4},"end":{"line":138,"column":27}},"41":{"start":{"line":142,"column":0},"end":{"line":142,"column":133}}},"fnMap":{"0":{"name":"createRole","decl":{"start":{"line":16,"column":9},"end":{"line":16,"column":19}},"loc":{"start":{"line":16,"column":30},"end":{"line":42,"column":1}},"line":16},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":12},"end":{"line":25,"column":13}},"loc":{"start":{"line":25,"column":41},"end":{"line":38,"column":5}},"line":25},"2":{"name":"(anonymous_2)","decl":{"start":{"line":29,"column":16},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":32},"end":{"line":34,"column":9}},"line":29},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":17},"end":{"line":34,"column":18}},"loc":{"start":{"line":34,"column":34},"end":{"line":36,"column":9}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":38,"column":13},"end":{"line":38,"column":14}},"loc":{"start":{"line":38,"column":30},"end":{"line":40,"column":5}},"line":38},"5":{"name":"getRoles","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":17}},"loc":{"start":{"line":50,"column":28},"end":{"line":56,"column":1}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":29},"end":{"line":51,"column":30}},"loc":{"start":{"line":51,"column":45},"end":{"line":53,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":53,"column":11},"end":{"line":53,"column":12}},"loc":{"start":{"line":53,"column":28},"end":{"line":55,"column":3}},"line":53},"8":{"name":"findRole","decl":{"start":{"line":64,"column":9},"end":{"line":64,"column":17}},"loc":{"start":{"line":64,"column":28},"end":{"line":81,"column":1}},"line":64},"9":{"name":"(anonymous_9)","decl":{"start":{"line":70,"column":38},"end":{"line":70,"column":39}},"loc":{"start":{"line":70,"column":54},"end":{"line":77,"column":5}},"line":70},"10":{"name":"(anonymous_10)","decl":{"start":{"line":77,"column":13},"end":{"line":77,"column":14}},"loc":{"start":{"line":77,"column":30},"end":{"line":79,"column":5}},"line":77},"11":{"name":"updateRole","decl":{"start":{"line":89,"column":9},"end":{"line":89,"column":19}},"loc":{"start":{"line":89,"column":30},"end":{"line":112,"column":1}},"line":89},"12":{"name":"(anonymous_12)","decl":{"start":{"line":93,"column":43},"end":{"line":93,"column":44}},"loc":{"start":{"line":93,"column":59},"end":{"line":109,"column":3}},"line":93},"13":{"name":"(anonymous_13)","decl":{"start":{"line":101,"column":12},"end":{"line":101,"column":13}},"loc":{"start":{"line":101,"column":24},"end":{"line":106,"column":5}},"line":101},"14":{"name":"(anonymous_14)","decl":{"start":{"line":106,"column":13},"end":{"line":106,"column":14}},"loc":{"start":{"line":106,"column":30},"end":{"line":108,"column":5}},"line":106},"15":{"name":"(anonymous_15)","decl":{"start":{"line":109,"column":11},"end":{"line":109,"column":12}},"loc":{"start":{"line":109,"column":28},"end":{"line":111,"column":3}},"line":109},"16":{"name":"deleteRole","decl":{"start":{"line":120,"column":9},"end":{"line":120,"column":19}},"loc":{"start":{"line":120,"column":30},"end":{"line":140,"column":1}},"line":120},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":43},"end":{"line":124,"column":44}},"loc":{"start":{"line":124,"column":59},"end":{"line":137,"column":3}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":130,"column":31},"end":{"line":130,"column":32}},"loc":{"start":{"line":130,"column":43},"end":{"line":134,"column":5}},"line":130},"19":{"name":"(anonymous_19)","decl":{"start":{"line":134,"column":13},"end":{"line":134,"column":14}},"loc":{"start":{"line":134,"column":30},"end":{"line":136,"column":5}},"line":134},"20":{"name":"(anonymous_20)","decl":{"start":{"line":137,"column":11},"end":{"line":137,"column":12}},"loc":{"start":{"line":137,"column":28},"end":{"line":139,"column":3}},"line":137}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},{"start":{"line":20,"column":2},"end":{"line":41,"column":3}}],"line":20},"1":{"loc":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"type":"if","locations":[{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},{"start":{"line":26,"column":6},"end":{"line":37,"column":7}}],"line":26},"2":{"loc":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"type":"if","locations":[{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},{"start":{"line":65,"column":2},"end":{"line":80,"column":3}}],"line":65},"3":{"loc":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"type":"if","locations":[{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},{"start":{"line":71,"column":6},"end":{"line":75,"column":7}}],"line":71},"4":{"loc":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"type":"if","locations":[{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},{"start":{"line":90,"column":2},"end":{"line":92,"column":3}}],"line":90},"5":{"loc":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},{"start":{"line":94,"column":4},"end":{"line":98,"column":5}}],"line":94},"6":{"loc":{"start":{"line":100,"column":13},"end":{"line":100,"column":41}},"type":"binary-expr","locations":[{"start":{"line":100,"column":13},"end":{"line":100,"column":27}},{"start":{"line":100,"column":31},"end":{"line":100,"column":41}}],"line":100},"7":{"loc":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"type":"if","locations":[{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},{"start":{"line":121,"column":2},"end":{"line":123,"column":3}}],"line":121},"8":{"loc":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"type":"if","locations":[{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},{"start":{"line":125,"column":4},"end":{"line":129,"column":5}}],"line":125}},"s":{"0":1,"1":1,"2":1,"3":3,"4":3,"5":3,"6":0,"7":3,"8":2,"9":2,"10":2,"11":0,"12":1,"13":1,"14":1,"15":0,"16":4,"17":1,"18":3,"19":2,"20":1,"21":1,"22":1,"23":3,"24":0,"25":3,"26":2,"27":1,"28":1,"29":1,"30":0,"31":1,"32":2,"33":0,"34":2,"35":2,"36":1,"37":2,"38":0,"39":1,"40":1,"41":1},"f":{"0":3,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":4,"9":2,"10":1,"11":3,"12":2,"13":1,"14":0,"15":1,"16":2,"17":2,"18":0,"19":1,"20":1},"b":{"0":[0,3],"1":[2,0],"2":[1,3],"3":[1,1],"4":[0,3],"5":[1,1],"6":[1,0],"7":[0,2],"8":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"30145fbb54f2bf78417895e538ec3aa77aa3022b","contentHash":"d0043f60ddb6921c54c62da8d1dd2774_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/mockData.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/mockData.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":26}},"5":{"start":{"line":15,"column":0},"end":{"line":54,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1},"b":{"0":[0,1],"1":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"c665441a3872939aae11e0aaaa2edd23055ddeb5","contentHash":"16d073a0b97072f3cf41cab373a16067_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/role.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/role.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":245,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":101,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":72,"column":7}},"38":{"start":{"line":64,"column":6},"end":{"line":70,"column":9}},"39":{"start":{"line":65,"column":8},"end":{"line":65,"column":41}},"40":{"start":{"line":66,"column":8},"end":{"line":66,"column":43}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":69}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":50}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":76}},"44":{"start":{"line":71,"column":6},"end":{"line":71,"column":13}},"45":{"start":{"line":73,"column":4},"end":{"line":81,"column":7}},"46":{"start":{"line":74,"column":6},"end":{"line":79,"column":9}},"47":{"start":{"line":75,"column":8},"end":{"line":75,"column":41}},"48":{"start":{"line":76,"column":8},"end":{"line":76,"column":43}},"49":{"start":{"line":77,"column":8},"end":{"line":77,"column":69}},"50":{"start":{"line":78,"column":8},"end":{"line":78,"column":50}},"51":{"start":{"line":80,"column":6},"end":{"line":80,"column":13}},"52":{"start":{"line":82,"column":4},"end":{"line":92,"column":7}},"53":{"start":{"line":83,"column":17},"end":{"line":85,"column":7}},"54":{"start":{"line":86,"column":6},"end":{"line":91,"column":9}},"55":{"start":{"line":87,"column":8},"end":{"line":87,"column":41}},"56":{"start":{"line":88,"column":8},"end":{"line":88,"column":43}},"57":{"start":{"line":89,"column":8},"end":{"line":89,"column":66}},"58":{"start":{"line":90,"column":8},"end":{"line":90,"column":15}},"59":{"start":{"line":93,"column":4},"end":{"line":100,"column":7}},"60":{"start":{"line":94,"column":6},"end":{"line":99,"column":9}},"61":{"start":{"line":95,"column":8},"end":{"line":95,"column":41}},"62":{"start":{"line":96,"column":8},"end":{"line":96,"column":43}},"63":{"start":{"line":97,"column":8},"end":{"line":97,"column":69}},"64":{"start":{"line":98,"column":8},"end":{"line":98,"column":15}},"65":{"start":{"line":103,"column":2},"end":{"line":123,"column":5}},"66":{"start":{"line":104,"column":4},"end":{"line":115,"column":7}},"67":{"start":{"line":105,"column":6},"end":{"line":114,"column":9}},"68":{"start":{"line":106,"column":8},"end":{"line":106,"column":41}},"69":{"start":{"line":107,"column":8},"end":{"line":107,"column":43}},"70":{"start":{"line":108,"column":8},"end":{"line":108,"column":42}},"71":{"start":{"line":109,"column":8},"end":{"line":109,"column":41}},"72":{"start":{"line":110,"column":8},"end":{"line":110,"column":50}},"73":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"74":{"start":{"line":112,"column":8},"end":{"line":112,"column":56}},"75":{"start":{"line":113,"column":8},"end":{"line":113,"column":15}},"76":{"start":{"line":116,"column":4},"end":{"line":122,"column":7}},"77":{"start":{"line":117,"column":6},"end":{"line":121,"column":9}},"78":{"start":{"line":118,"column":8},"end":{"line":118,"column":41}},"79":{"start":{"line":119,"column":8},"end":{"line":119,"column":66}},"80":{"start":{"line":120,"column":8},"end":{"line":120,"column":15}},"81":{"start":{"line":125,"column":2},"end":{"line":168,"column":5}},"82":{"start":{"line":126,"column":4},"end":{"line":135,"column":7}},"83":{"start":{"line":127,"column":15},"end":{"line":127,"column":16}},"84":{"start":{"line":128,"column":6},"end":{"line":134,"column":9}},"85":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"86":{"start":{"line":130,"column":8},"end":{"line":130,"column":40}},"87":{"start":{"line":131,"column":8},"end":{"line":131,"column":53}},"88":{"start":{"line":132,"column":8},"end":{"line":132,"column":40}},"89":{"start":{"line":133,"column":8},"end":{"line":133,"column":15}},"90":{"start":{"line":136,"column":4},"end":{"line":143,"column":7}},"91":{"start":{"line":137,"column":15},"end":{"line":137,"column":16}},"92":{"start":{"line":138,"column":6},"end":{"line":142,"column":9}},"93":{"start":{"line":139,"column":8},"end":{"line":139,"column":41}},"94":{"start":{"line":140,"column":8},"end":{"line":140,"column":66}},"95":{"start":{"line":141,"column":8},"end":{"line":141,"column":15}},"96":{"start":{"line":144,"column":4},"end":{"line":151,"column":7}},"97":{"start":{"line":145,"column":15},"end":{"line":145,"column":27}},"98":{"start":{"line":146,"column":6},"end":{"line":150,"column":9}},"99":{"start":{"line":147,"column":8},"end":{"line":147,"column":41}},"100":{"start":{"line":148,"column":8},"end":{"line":148,"column":90}},"101":{"start":{"line":149,"column":8},"end":{"line":149,"column":15}},"102":{"start":{"line":152,"column":4},"end":{"line":159,"column":7}},"103":{"start":{"line":153,"column":15},"end":{"line":153,"column":18}},"104":{"start":{"line":154,"column":6},"end":{"line":158,"column":9}},"105":{"start":{"line":155,"column":8},"end":{"line":155,"column":41}},"106":{"start":{"line":156,"column":8},"end":{"line":156,"column":58}},"107":{"start":{"line":157,"column":8},"end":{"line":157,"column":15}},"108":{"start":{"line":160,"column":4},"end":{"line":167,"column":7}},"109":{"start":{"line":161,"column":15},"end":{"line":161,"column":36}},"110":{"start":{"line":162,"column":6},"end":{"line":166,"column":9}},"111":{"start":{"line":163,"column":8},"end":{"line":163,"column":41}},"112":{"start":{"line":164,"column":8},"end":{"line":164,"column":95}},"113":{"start":{"line":165,"column":8},"end":{"line":165,"column":15}},"114":{"start":{"line":169,"column":2},"end":{"line":207,"column":5}},"115":{"start":{"line":170,"column":4},"end":{"line":179,"column":7}},"116":{"start":{"line":171,"column":15},"end":{"line":171,"column":16}},"117":{"start":{"line":172,"column":6},"end":{"line":178,"column":9}},"118":{"start":{"line":173,"column":8},"end":{"line":173,"column":41}},"119":{"start":{"line":174,"column":8},"end":{"line":174,"column":43}},"120":{"start":{"line":175,"column":8},"end":{"line":175,"column":69}},"121":{"start":{"line":176,"column":8},"end":{"line":176,"column":50}},"122":{"start":{"line":177,"column":8},"end":{"line":177,"column":15}},"123":{"start":{"line":180,"column":4},"end":{"line":188,"column":7}},"124":{"start":{"line":181,"column":15},"end":{"line":181,"column":16}},"125":{"start":{"line":182,"column":6},"end":{"line":187,"column":9}},"126":{"start":{"line":183,"column":8},"end":{"line":183,"column":41}},"127":{"start":{"line":184,"column":8},"end":{"line":184,"column":43}},"128":{"start":{"line":185,"column":8},"end":{"line":185,"column":66}},"129":{"start":{"line":186,"column":8},"end":{"line":186,"column":15}},"130":{"start":{"line":189,"column":4},"end":{"line":197,"column":7}},"131":{"start":{"line":190,"column":15},"end":{"line":190,"column":18}},"132":{"start":{"line":191,"column":6},"end":{"line":196,"column":9}},"133":{"start":{"line":192,"column":8},"end":{"line":192,"column":41}},"134":{"start":{"line":193,"column":8},"end":{"line":193,"column":43}},"135":{"start":{"line":194,"column":8},"end":{"line":194,"column":60}},"136":{"start":{"line":195,"column":8},"end":{"line":195,"column":15}},"137":{"start":{"line":198,"column":4},"end":{"line":206,"column":7}},"138":{"start":{"line":199,"column":15},"end":{"line":199,"column":31}},"139":{"start":{"line":200,"column":6},"end":{"line":205,"column":9}},"140":{"start":{"line":201,"column":8},"end":{"line":201,"column":41}},"141":{"start":{"line":202,"column":8},"end":{"line":202,"column":43}},"142":{"start":{"line":203,"column":8},"end":{"line":203,"column":95}},"143":{"start":{"line":204,"column":8},"end":{"line":204,"column":15}},"144":{"start":{"line":208,"column":2},"end":{"line":244,"column":5}},"145":{"start":{"line":209,"column":4},"end":{"line":216,"column":7}},"146":{"start":{"line":210,"column":15},"end":{"line":210,"column":16}},"147":{"start":{"line":211,"column":6},"end":{"line":214,"column":9}},"148":{"start":{"line":212,"column":8},"end":{"line":212,"column":41}},"149":{"start":{"line":213,"column":8},"end":{"line":213,"column":43}},"150":{"start":{"line":215,"column":6},"end":{"line":215,"column":13}},"151":{"start":{"line":217,"column":4},"end":{"line":225,"column":7}},"152":{"start":{"line":218,"column":15},"end":{"line":218,"column":16}},"153":{"start":{"line":219,"column":6},"end":{"line":224,"column":9}},"154":{"start":{"line":220,"column":8},"end":{"line":220,"column":41}},"155":{"start":{"line":221,"column":8},"end":{"line":221,"column":43}},"156":{"start":{"line":222,"column":8},"end":{"line":222,"column":66}},"157":{"start":{"line":223,"column":8},"end":{"line":223,"column":15}},"158":{"start":{"line":226,"column":4},"end":{"line":234,"column":7}},"159":{"start":{"line":227,"column":15},"end":{"line":227,"column":18}},"160":{"start":{"line":228,"column":6},"end":{"line":233,"column":9}},"161":{"start":{"line":229,"column":8},"end":{"line":229,"column":41}},"162":{"start":{"line":230,"column":8},"end":{"line":230,"column":43}},"163":{"start":{"line":231,"column":8},"end":{"line":231,"column":60}},"164":{"start":{"line":232,"column":8},"end":{"line":232,"column":15}},"165":{"start":{"line":235,"column":4},"end":{"line":243,"column":7}},"166":{"start":{"line":236,"column":15},"end":{"line":236,"column":31}},"167":{"start":{"line":237,"column":6},"end":{"line":242,"column":9}},"168":{"start":{"line":238,"column":8},"end":{"line":238,"column":41}},"169":{"start":{"line":239,"column":8},"end":{"line":239,"column":43}},"170":{"start":{"line":240,"column":8},"end":{"line":240,"column":95}},"171":{"start":{"line":241,"column":8},"end":{"line":241,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":18},"end":{"line":38,"column":19}},"loc":{"start":{"line":38,"column":30},"end":{"line":245,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":25},"end":{"line":62,"column":26}},"loc":{"start":{"line":62,"column":37},"end":{"line":101,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":56},"end":{"line":63,"column":57}},"loc":{"start":{"line":63,"column":72},"end":{"line":72,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":64,"column":136},"end":{"line":64,"column":137}},"loc":{"start":{"line":64,"column":156},"end":{"line":70,"column":7}},"line":64},"12":{"name":"(anonymous_12)","decl":{"start":{"line":73,"column":56},"end":{"line":73,"column":57}},"loc":{"start":{"line":73,"column":72},"end":{"line":81,"column":5}},"line":73},"13":{"name":"(anonymous_13)","decl":{"start":{"line":74,"column":133},"end":{"line":74,"column":134}},"loc":{"start":{"line":74,"column":153},"end":{"line":79,"column":7}},"line":74},"14":{"name":"(anonymous_14)","decl":{"start":{"line":82,"column":61},"end":{"line":82,"column":62}},"loc":{"start":{"line":82,"column":77},"end":{"line":92,"column":5}},"line":82},"15":{"name":"(anonymous_15)","decl":{"start":{"line":86,"column":120},"end":{"line":86,"column":121}},"loc":{"start":{"line":86,"column":140},"end":{"line":91,"column":7}},"line":86},"16":{"name":"(anonymous_16)","decl":{"start":{"line":93,"column":62},"end":{"line":93,"column":63}},"loc":{"start":{"line":93,"column":78},"end":{"line":100,"column":5}},"line":93},"17":{"name":"(anonymous_17)","decl":{"start":{"line":94,"column":131},"end":{"line":94,"column":132}},"loc":{"start":{"line":94,"column":151},"end":{"line":99,"column":7}},"line":94},"18":{"name":"(anonymous_18)","decl":{"start":{"line":103,"column":24},"end":{"line":103,"column":25}},"loc":{"start":{"line":103,"column":36},"end":{"line":123,"column":3}},"line":103},"19":{"name":"(anonymous_19)","decl":{"start":{"line":104,"column":59},"end":{"line":104,"column":60}},"loc":{"start":{"line":104,"column":75},"end":{"line":115,"column":5}},"line":104},"20":{"name":"(anonymous_20)","decl":{"start":{"line":105,"column":106},"end":{"line":105,"column":107}},"loc":{"start":{"line":105,"column":126},"end":{"line":114,"column":7}},"line":105},"21":{"name":"(anonymous_21)","decl":{"start":{"line":116,"column":64},"end":{"line":116,"column":65}},"loc":{"start":{"line":116,"column":80},"end":{"line":122,"column":5}},"line":116},"22":{"name":"(anonymous_22)","decl":{"start":{"line":117,"column":105},"end":{"line":117,"column":106}},"loc":{"start":{"line":117,"column":125},"end":{"line":121,"column":7}},"line":117},"23":{"name":"(anonymous_23)","decl":{"start":{"line":125,"column":28},"end":{"line":125,"column":29}},"loc":{"start":{"line":125,"column":40},"end":{"line":168,"column":3}},"line":125},"24":{"name":"(anonymous_24)","decl":{"start":{"line":126,"column":58},"end":{"line":126,"column":59}},"loc":{"start":{"line":126,"column":74},"end":{"line":135,"column":5}},"line":126},"25":{"name":"(anonymous_25)","decl":{"start":{"line":128,"column":112},"end":{"line":128,"column":113}},"loc":{"start":{"line":128,"column":132},"end":{"line":134,"column":7}},"line":128},"26":{"name":"(anonymous_26)","decl":{"start":{"line":136,"column":70},"end":{"line":136,"column":71}},"loc":{"start":{"line":136,"column":86},"end":{"line":143,"column":5}},"line":136},"27":{"name":"(anonymous_27)","decl":{"start":{"line":138,"column":111},"end":{"line":138,"column":112}},"loc":{"start":{"line":138,"column":131},"end":{"line":142,"column":7}},"line":138},"28":{"name":"(anonymous_28)","decl":{"start":{"line":144,"column":78},"end":{"line":144,"column":79}},"loc":{"start":{"line":144,"column":94},"end":{"line":151,"column":5}},"line":144},"29":{"name":"(anonymous_29)","decl":{"start":{"line":146,"column":112},"end":{"line":146,"column":113}},"loc":{"start":{"line":146,"column":132},"end":{"line":150,"column":7}},"line":146},"30":{"name":"(anonymous_30)","decl":{"start":{"line":152,"column":69},"end":{"line":152,"column":70}},"loc":{"start":{"line":152,"column":85},"end":{"line":159,"column":5}},"line":152},"31":{"name":"(anonymous_31)","decl":{"start":{"line":154,"column":112},"end":{"line":154,"column":113}},"loc":{"start":{"line":154,"column":132},"end":{"line":158,"column":7}},"line":154},"32":{"name":"(anonymous_32)","decl":{"start":{"line":160,"column":68},"end":{"line":160,"column":69}},"loc":{"start":{"line":160,"column":84},"end":{"line":167,"column":5}},"line":160},"33":{"name":"(anonymous_33)","decl":{"start":{"line":162,"column":112},"end":{"line":162,"column":113}},"loc":{"start":{"line":162,"column":132},"end":{"line":166,"column":7}},"line":162},"34":{"name":"(anonymous_34)","decl":{"start":{"line":169,"column":28},"end":{"line":169,"column":29}},"loc":{"start":{"line":169,"column":40},"end":{"line":207,"column":3}},"line":169},"35":{"name":"(anonymous_35)","decl":{"start":{"line":170,"column":66},"end":{"line":170,"column":67}},"loc":{"start":{"line":170,"column":82},"end":{"line":179,"column":5}},"line":170},"36":{"name":"(anonymous_36)","decl":{"start":{"line":172,"column":144},"end":{"line":172,"column":145}},"loc":{"start":{"line":172,"column":164},"end":{"line":178,"column":7}},"line":172},"37":{"name":"(anonymous_37)","decl":{"start":{"line":180,"column":77},"end":{"line":180,"column":78}},"loc":{"start":{"line":180,"column":93},"end":{"line":188,"column":5}},"line":180},"38":{"name":"(anonymous_38)","decl":{"start":{"line":182,"column":135},"end":{"line":182,"column":136}},"loc":{"start":{"line":182,"column":155},"end":{"line":187,"column":7}},"line":182},"39":{"name":"(anonymous_39)","decl":{"start":{"line":189,"column":90},"end":{"line":189,"column":91}},"loc":{"start":{"line":189,"column":106},"end":{"line":197,"column":5}},"line":189},"40":{"name":"(anonymous_40)","decl":{"start":{"line":191,"column":136},"end":{"line":191,"column":137}},"loc":{"start":{"line":191,"column":156},"end":{"line":196,"column":7}},"line":191},"41":{"name":"(anonymous_41)","decl":{"start":{"line":198,"column":96},"end":{"line":198,"column":97}},"loc":{"start":{"line":198,"column":112},"end":{"line":206,"column":5}},"line":198},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":139},"end":{"line":200,"column":140}},"loc":{"start":{"line":200,"column":159},"end":{"line":205,"column":7}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":31},"end":{"line":208,"column":32}},"loc":{"start":{"line":208,"column":43},"end":{"line":244,"column":3}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":209,"column":63},"end":{"line":209,"column":64}},"loc":{"start":{"line":209,"column":79},"end":{"line":216,"column":5}},"line":209},"45":{"name":"(anonymous_45)","decl":{"start":{"line":211,"column":115},"end":{"line":211,"column":116}},"loc":{"start":{"line":211,"column":135},"end":{"line":214,"column":7}},"line":211},"46":{"name":"(anonymous_46)","decl":{"start":{"line":217,"column":74},"end":{"line":217,"column":75}},"loc":{"start":{"line":217,"column":90},"end":{"line":225,"column":5}},"line":217},"47":{"name":"(anonymous_47)","decl":{"start":{"line":219,"column":114},"end":{"line":219,"column":115}},"loc":{"start":{"line":219,"column":134},"end":{"line":224,"column":7}},"line":219},"48":{"name":"(anonymous_48)","decl":{"start":{"line":226,"column":79},"end":{"line":226,"column":80}},"loc":{"start":{"line":226,"column":95},"end":{"line":234,"column":5}},"line":226},"49":{"name":"(anonymous_49)","decl":{"start":{"line":228,"column":115},"end":{"line":228,"column":116}},"loc":{"start":{"line":228,"column":135},"end":{"line":233,"column":7}},"line":228},"50":{"name":"(anonymous_50)","decl":{"start":{"line":235,"column":99},"end":{"line":235,"column":100}},"loc":{"start":{"line":235,"column":115},"end":{"line":243,"column":5}},"line":235},"51":{"name":"(anonymous_51)","decl":{"start":{"line":237,"column":115},"end":{"line":237,"column":116}},"loc":{"start":{"line":237,"column":135},"end":{"line":242,"column":7}},"line":237}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":0,"49":0,"50":0,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":0,"63":0,"64":0,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":0,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":1,"139":1,"140":1,"141":1,"142":1,"143":0,"144":1,"145":1,"146":1,"147":1,"148":1,"149":0,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":0,"167":0,"168":0,"169":0,"170":0,"171":0},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":0,"51":0},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d9c57213fc2a56b5354ab1d6480399426f8d3d21","contentHash":"e9ffe18e982a467134829351068b6216_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/search.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/search.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":21},"end":{"line":33,"column":27}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":106,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":78,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":69,"column":7}},"38":{"start":{"line":64,"column":18},"end":{"line":64,"column":20}},"39":{"start":{"line":65,"column":6},"end":{"line":68,"column":9}},"40":{"start":{"line":66,"column":8},"end":{"line":66,"column":41}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":62}},"42":{"start":{"line":70,"column":4},"end":{"line":77,"column":7}},"43":{"start":{"line":71,"column":18},"end":{"line":71,"column":24}},"44":{"start":{"line":72,"column":6},"end":{"line":76,"column":9}},"45":{"start":{"line":73,"column":8},"end":{"line":73,"column":41}},"46":{"start":{"line":74,"column":8},"end":{"line":74,"column":53}},"47":{"start":{"line":75,"column":8},"end":{"line":75,"column":52}},"48":{"start":{"line":79,"column":2},"end":{"line":105,"column":5}},"49":{"start":{"line":80,"column":4},"end":{"line":86,"column":7}},"50":{"start":{"line":81,"column":18},"end":{"line":81,"column":20}},"51":{"start":{"line":82,"column":6},"end":{"line":85,"column":9}},"52":{"start":{"line":83,"column":8},"end":{"line":83,"column":41}},"53":{"start":{"line":84,"column":8},"end":{"line":84,"column":86}},"54":{"start":{"line":87,"column":4},"end":{"line":97,"column":7}},"55":{"start":{"line":88,"column":18},"end":{"line":88,"column":24}},"56":{"start":{"line":89,"column":6},"end":{"line":96,"column":9}},"57":{"start":{"line":90,"column":8},"end":{"line":90,"column":41}},"58":{"start":{"line":91,"column":8},"end":{"line":91,"column":54}},"59":{"start":{"line":92,"column":8},"end":{"line":92,"column":84}},"60":{"start":{"line":93,"column":8},"end":{"line":93,"column":96}},"61":{"start":{"line":94,"column":8},"end":{"line":94,"column":56}},"62":{"start":{"line":95,"column":8},"end":{"line":95,"column":78}},"63":{"start":{"line":98,"column":4},"end":{"line":104,"column":7}},"64":{"start":{"line":99,"column":18},"end":{"line":99,"column":22}},"65":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"66":{"start":{"line":101,"column":8},"end":{"line":101,"column":41}},"67":{"start":{"line":102,"column":8},"end":{"line":102,"column":84}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":18},"end":{"line":38,"column":19}},"loc":{"start":{"line":38,"column":30},"end":{"line":106,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":38},"end":{"line":62,"column":39}},"loc":{"start":{"line":62,"column":50},"end":{"line":78,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":63},"end":{"line":63,"column":64}},"loc":{"start":{"line":63,"column":75},"end":{"line":69,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":65,"column":126},"end":{"line":65,"column":127}},"loc":{"start":{"line":65,"column":146},"end":{"line":68,"column":7}},"line":65},"12":{"name":"(anonymous_12)","decl":{"start":{"line":70,"column":76},"end":{"line":70,"column":77}},"loc":{"start":{"line":70,"column":88},"end":{"line":77,"column":5}},"line":70},"13":{"name":"(anonymous_13)","decl":{"start":{"line":72,"column":126},"end":{"line":72,"column":127}},"loc":{"start":{"line":72,"column":146},"end":{"line":76,"column":7}},"line":72},"14":{"name":"(anonymous_14)","decl":{"start":{"line":79,"column":36},"end":{"line":79,"column":37}},"loc":{"start":{"line":79,"column":48},"end":{"line":105,"column":3}},"line":79},"15":{"name":"(anonymous_15)","decl":{"start":{"line":80,"column":63},"end":{"line":80,"column":64}},"loc":{"start":{"line":80,"column":75},"end":{"line":86,"column":5}},"line":80},"16":{"name":"(anonymous_16)","decl":{"start":{"line":82,"column":129},"end":{"line":82,"column":130}},"loc":{"start":{"line":82,"column":149},"end":{"line":85,"column":7}},"line":82},"17":{"name":"(anonymous_17)","decl":{"start":{"line":87,"column":67},"end":{"line":87,"column":68}},"loc":{"start":{"line":87,"column":79},"end":{"line":97,"column":5}},"line":87},"18":{"name":"(anonymous_18)","decl":{"start":{"line":89,"column":130},"end":{"line":89,"column":131}},"loc":{"start":{"line":89,"column":150},"end":{"line":96,"column":7}},"line":89},"19":{"name":"(anonymous_19)","decl":{"start":{"line":98,"column":70},"end":{"line":98,"column":71}},"loc":{"start":{"line":98,"column":82},"end":{"line":104,"column":5}},"line":98},"20":{"name":"(anonymous_20)","decl":{"start":{"line":100,"column":130},"end":{"line":100,"column":131}},"loc":{"start":{"line":100,"column":150},"end":{"line":103,"column":7}},"line":100}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":0,"33":1,"34":1,"35":1,"36":1,"37":1,"38":0,"39":0,"40":0,"41":0,"42":1,"43":0,"44":0,"45":0,"46":0,"47":0,"48":1,"49":1,"50":0,"51":0,"52":0,"53":0,"54":1,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":1,"64":0,"65":0,"66":0,"67":0},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":0,"11":0,"12":0,"13":0,"14":1,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a316d6b4cf5da750d781196c11f29a87e0f7c33b","contentHash":"dd9562f69019012ae13dbefda8bb9d25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/user.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/user.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":15},"end":{"line":35,"column":42}},"20":{"start":{"line":36,"column":13},"end":{"line":36,"column":38}},"21":{"start":{"line":37,"column":12},"end":{"line":37,"column":36}},"22":{"start":{"line":38,"column":12},"end":{"line":38,"column":36}},"23":{"start":{"line":41,"column":0},"end":{"line":314,"column":3}},"24":{"start":{"line":42,"column":2},"end":{"line":47,"column":5}},"25":{"start":{"line":43,"column":4},"end":{"line":46,"column":7}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":34}},"27":{"start":{"line":45,"column":6},"end":{"line":45,"column":13}},"28":{"start":{"line":48,"column":2},"end":{"line":53,"column":5}},"29":{"start":{"line":49,"column":4},"end":{"line":52,"column":7}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":33}},"31":{"start":{"line":51,"column":6},"end":{"line":51,"column":13}},"32":{"start":{"line":54,"column":2},"end":{"line":59,"column":5}},"33":{"start":{"line":55,"column":4},"end":{"line":58,"column":7}},"34":{"start":{"line":56,"column":6},"end":{"line":56,"column":39}},"35":{"start":{"line":57,"column":6},"end":{"line":57,"column":13}},"36":{"start":{"line":60,"column":2},"end":{"line":63,"column":5}},"37":{"start":{"line":61,"column":4},"end":{"line":61,"column":76}},"38":{"start":{"line":62,"column":4},"end":{"line":62,"column":11}},"39":{"start":{"line":65,"column":2},"end":{"line":313,"column":5}},"40":{"start":{"line":66,"column":4},"end":{"line":74,"column":7}},"41":{"start":{"line":67,"column":6},"end":{"line":73,"column":9}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":41}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":62}},"44":{"start":{"line":70,"column":8},"end":{"line":70,"column":82}},"45":{"start":{"line":71,"column":8},"end":{"line":71,"column":47}},"46":{"start":{"line":72,"column":8},"end":{"line":72,"column":15}},"47":{"start":{"line":76,"column":4},"end":{"line":84,"column":7}},"48":{"start":{"line":77,"column":6},"end":{"line":83,"column":9}},"49":{"start":{"line":78,"column":8},"end":{"line":78,"column":41}},"50":{"start":{"line":79,"column":8},"end":{"line":79,"column":62}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":82}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":47}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":15}},"54":{"start":{"line":86,"column":4},"end":{"line":93,"column":7}},"55":{"start":{"line":87,"column":6},"end":{"line":92,"column":9}},"56":{"start":{"line":88,"column":8},"end":{"line":88,"column":41}},"57":{"start":{"line":89,"column":8},"end":{"line":89,"column":60}},"58":{"start":{"line":90,"column":8},"end":{"line":90,"column":46}},"59":{"start":{"line":91,"column":8},"end":{"line":91,"column":15}},"60":{"start":{"line":95,"column":4},"end":{"line":105,"column":7}},"61":{"start":{"line":96,"column":6},"end":{"line":104,"column":9}},"62":{"start":{"line":97,"column":8},"end":{"line":103,"column":11}},"63":{"start":{"line":98,"column":10},"end":{"line":98,"column":43}},"64":{"start":{"line":99,"column":10},"end":{"line":99,"column":79}},"65":{"start":{"line":100,"column":10},"end":{"line":100,"column":48}},"66":{"start":{"line":101,"column":10},"end":{"line":101,"column":79}},"67":{"start":{"line":102,"column":10},"end":{"line":102,"column":17}},"68":{"start":{"line":107,"column":4},"end":{"line":142,"column":7}},"69":{"start":{"line":108,"column":6},"end":{"line":115,"column":9}},"70":{"start":{"line":109,"column":8},"end":{"line":114,"column":11}},"71":{"start":{"line":110,"column":10},"end":{"line":110,"column":43}},"72":{"start":{"line":111,"column":10},"end":{"line":111,"column":45}},"73":{"start":{"line":112,"column":10},"end":{"line":112,"column":64}},"74":{"start":{"line":113,"column":10},"end":{"line":113,"column":17}},"75":{"start":{"line":116,"column":6},"end":{"line":123,"column":9}},"76":{"start":{"line":117,"column":8},"end":{"line":122,"column":11}},"77":{"start":{"line":118,"column":10},"end":{"line":118,"column":43}},"78":{"start":{"line":119,"column":10},"end":{"line":119,"column":45}},"79":{"start":{"line":120,"column":10},"end":{"line":120,"column":68}},"80":{"start":{"line":121,"column":10},"end":{"line":121,"column":17}},"81":{"start":{"line":124,"column":6},"end":{"line":131,"column":9}},"82":{"start":{"line":125,"column":8},"end":{"line":130,"column":11}},"83":{"start":{"line":126,"column":10},"end":{"line":126,"column":43}},"84":{"start":{"line":127,"column":10},"end":{"line":127,"column":45}},"85":{"start":{"line":128,"column":10},"end":{"line":128,"column":64}},"86":{"start":{"line":129,"column":10},"end":{"line":129,"column":17}},"87":{"start":{"line":132,"column":6},"end":{"line":141,"column":9}},"88":{"start":{"line":133,"column":20},"end":{"line":133,"column":21}},"89":{"start":{"line":134,"column":8},"end":{"line":140,"column":11}},"90":{"start":{"line":135,"column":10},"end":{"line":135,"column":43}},"91":{"start":{"line":136,"column":10},"end":{"line":136,"column":45}},"92":{"start":{"line":137,"column":10},"end":{"line":137,"column":66}},"93":{"start":{"line":138,"column":10},"end":{"line":138,"column":61}},"94":{"start":{"line":139,"column":10},"end":{"line":139,"column":17}},"95":{"start":{"line":143,"column":4},"end":{"line":204,"column":7}},"96":{"start":{"line":144,"column":6},"end":{"line":156,"column":9}},"97":{"start":{"line":145,"column":17},"end":{"line":145,"column":18}},"98":{"start":{"line":146,"column":8},"end":{"line":155,"column":11}},"99":{"start":{"line":147,"column":10},"end":{"line":147,"column":43}},"100":{"start":{"line":148,"column":10},"end":{"line":148,"column":41}},"101":{"start":{"line":149,"column":10},"end":{"line":149,"column":60}},"102":{"start":{"line":150,"column":10},"end":{"line":150,"column":43}},"103":{"start":{"line":151,"column":10},"end":{"line":151,"column":54}},"104":{"start":{"line":152,"column":10},"end":{"line":152,"column":60}},"105":{"start":{"line":153,"column":10},"end":{"line":153,"column":47}},"106":{"start":{"line":154,"column":10},"end":{"line":154,"column":17}},"107":{"start":{"line":157,"column":6},"end":{"line":169,"column":9}},"108":{"start":{"line":158,"column":17},"end":{"line":158,"column":18}},"109":{"start":{"line":159,"column":8},"end":{"line":168,"column":11}},"110":{"start":{"line":160,"column":10},"end":{"line":160,"column":43}},"111":{"start":{"line":161,"column":10},"end":{"line":161,"column":41}},"112":{"start":{"line":162,"column":10},"end":{"line":162,"column":60}},"113":{"start":{"line":163,"column":10},"end":{"line":163,"column":40}},"114":{"start":{"line":164,"column":10},"end":{"line":164,"column":54}},"115":{"start":{"line":165,"column":10},"end":{"line":165,"column":60}},"116":{"start":{"line":166,"column":10},"end":{"line":166,"column":47}},"117":{"start":{"line":167,"column":10},"end":{"line":167,"column":17}},"118":{"start":{"line":170,"column":6},"end":{"line":177,"column":9}},"119":{"start":{"line":171,"column":17},"end":{"line":171,"column":29}},"120":{"start":{"line":172,"column":8},"end":{"line":176,"column":11}},"121":{"start":{"line":173,"column":10},"end":{"line":173,"column":43}},"122":{"start":{"line":174,"column":10},"end":{"line":174,"column":112}},"123":{"start":{"line":175,"column":10},"end":{"line":175,"column":17}},"124":{"start":{"line":178,"column":6},"end":{"line":186,"column":9}},"125":{"start":{"line":179,"column":17},"end":{"line":179,"column":18}},"126":{"start":{"line":180,"column":8},"end":{"line":184,"column":11}},"127":{"start":{"line":181,"column":10},"end":{"line":181,"column":43}},"128":{"start":{"line":182,"column":10},"end":{"line":182,"column":53}},"129":{"start":{"line":183,"column":10},"end":{"line":183,"column":65}},"130":{"start":{"line":185,"column":8},"end":{"line":185,"column":15}},"131":{"start":{"line":187,"column":6},"end":{"line":195,"column":9}},"132":{"start":{"line":188,"column":17},"end":{"line":188,"column":20}},"133":{"start":{"line":189,"column":8},"end":{"line":194,"column":11}},"134":{"start":{"line":190,"column":10},"end":{"line":190,"column":43}},"135":{"start":{"line":191,"column":10},"end":{"line":191,"column":55}},"136":{"start":{"line":192,"column":10},"end":{"line":192,"column":60}},"137":{"start":{"line":193,"column":10},"end":{"line":193,"column":17}},"138":{"start":{"line":196,"column":6},"end":{"line":203,"column":9}},"139":{"start":{"line":197,"column":17},"end":{"line":197,"column":35}},"140":{"start":{"line":198,"column":8},"end":{"line":202,"column":11}},"141":{"start":{"line":199,"column":10},"end":{"line":199,"column":43}},"142":{"start":{"line":200,"column":10},"end":{"line":200,"column":119}},"143":{"start":{"line":201,"column":10},"end":{"line":201,"column":17}},"144":{"start":{"line":205,"column":4},"end":{"line":254,"column":7}},"145":{"start":{"line":206,"column":6},"end":{"line":215,"column":9}},"146":{"start":{"line":207,"column":17},"end":{"line":207,"column":18}},"147":{"start":{"line":208,"column":8},"end":{"line":214,"column":11}},"148":{"start":{"line":209,"column":10},"end":{"line":209,"column":43}},"149":{"start":{"line":210,"column":10},"end":{"line":210,"column":45}},"150":{"start":{"line":211,"column":10},"end":{"line":211,"column":40}},"151":{"start":{"line":212,"column":10},"end":{"line":212,"column":55}},"152":{"start":{"line":213,"column":10},"end":{"line":213,"column":17}},"153":{"start":{"line":216,"column":6},"end":{"line":225,"column":9}},"154":{"start":{"line":217,"column":17},"end":{"line":217,"column":18}},"155":{"start":{"line":218,"column":8},"end":{"line":224,"column":11}},"156":{"start":{"line":219,"column":10},"end":{"line":219,"column":43}},"157":{"start":{"line":220,"column":10},"end":{"line":220,"column":45}},"158":{"start":{"line":221,"column":10},"end":{"line":221,"column":40}},"159":{"start":{"line":222,"column":10},"end":{"line":222,"column":62}},"160":{"start":{"line":223,"column":10},"end":{"line":223,"column":17}},"161":{"start":{"line":226,"column":6},"end":{"line":235,"column":9}},"162":{"start":{"line":227,"column":17},"end":{"line":227,"column":18}},"163":{"start":{"line":228,"column":8},"end":{"line":234,"column":11}},"164":{"start":{"line":229,"column":10},"end":{"line":229,"column":43}},"165":{"start":{"line":230,"column":10},"end":{"line":230,"column":45}},"166":{"start":{"line":231,"column":10},"end":{"line":231,"column":40}},"167":{"start":{"line":232,"column":10},"end":{"line":232,"column":56}},"168":{"start":{"line":233,"column":10},"end":{"line":233,"column":17}},"169":{"start":{"line":236,"column":6},"end":{"line":244,"column":9}},"170":{"start":{"line":237,"column":17},"end":{"line":237,"column":18}},"171":{"start":{"line":238,"column":8},"end":{"line":243,"column":11}},"172":{"start":{"line":239,"column":10},"end":{"line":239,"column":43}},"173":{"start":{"line":240,"column":10},"end":{"line":240,"column":45}},"174":{"start":{"line":241,"column":10},"end":{"line":241,"column":88}},"175":{"start":{"line":242,"column":10},"end":{"line":242,"column":17}},"176":{"start":{"line":245,"column":6},"end":{"line":253,"column":9}},"177":{"start":{"line":246,"column":17},"end":{"line":246,"column":21}},"178":{"start":{"line":247,"column":8},"end":{"line":252,"column":11}},"179":{"start":{"line":248,"column":10},"end":{"line":248,"column":43}},"180":{"start":{"line":249,"column":10},"end":{"line":249,"column":45}},"181":{"start":{"line":250,"column":10},"end":{"line":250,"column":88}},"182":{"start":{"line":251,"column":10},"end":{"line":251,"column":17}},"183":{"start":{"line":255,"column":4},"end":{"line":280,"column":7}},"184":{"start":{"line":256,"column":6},"end":{"line":262,"column":9}},"185":{"start":{"line":257,"column":17},"end":{"line":257,"column":18}},"186":{"start":{"line":258,"column":8},"end":{"line":261,"column":11}},"187":{"start":{"line":259,"column":10},"end":{"line":259,"column":43}},"188":{"start":{"line":260,"column":10},"end":{"line":260,"column":17}},"189":{"start":{"line":263,"column":6},"end":{"line":270,"column":9}},"190":{"start":{"line":264,"column":17},"end":{"line":264,"column":18}},"191":{"start":{"line":265,"column":8},"end":{"line":269,"column":11}},"192":{"start":{"line":266,"column":10},"end":{"line":266,"column":43}},"193":{"start":{"line":267,"column":10},"end":{"line":267,"column":89}},"194":{"start":{"line":268,"column":10},"end":{"line":268,"column":17}},"195":{"start":{"line":271,"column":6},"end":{"line":279,"column":9}},"196":{"start":{"line":272,"column":17},"end":{"line":272,"column":19}},"197":{"start":{"line":273,"column":8},"end":{"line":278,"column":11}},"198":{"start":{"line":274,"column":10},"end":{"line":274,"column":43}},"199":{"start":{"line":275,"column":10},"end":{"line":275,"column":45}},"200":{"start":{"line":276,"column":10},"end":{"line":276,"column":60}},"201":{"start":{"line":277,"column":10},"end":{"line":277,"column":17}},"202":{"start":{"line":281,"column":4},"end":{"line":312,"column":7}},"203":{"start":{"line":282,"column":6},"end":{"line":290,"column":9}},"204":{"start":{"line":283,"column":21},"end":{"line":283,"column":22}},"205":{"start":{"line":284,"column":8},"end":{"line":289,"column":11}},"206":{"start":{"line":285,"column":10},"end":{"line":285,"column":43}},"207":{"start":{"line":286,"column":10},"end":{"line":286,"column":42}},"208":{"start":{"line":287,"column":10},"end":{"line":287,"column":60}},"209":{"start":{"line":288,"column":10},"end":{"line":288,"column":17}},"210":{"start":{"line":291,"column":6},"end":{"line":300,"column":9}},"211":{"start":{"line":292,"column":21},"end":{"line":292,"column":22}},"212":{"start":{"line":293,"column":8},"end":{"line":299,"column":11}},"213":{"start":{"line":294,"column":10},"end":{"line":294,"column":43}},"214":{"start":{"line":295,"column":10},"end":{"line":295,"column":42}},"215":{"start":{"line":296,"column":10},"end":{"line":296,"column":64}},"216":{"start":{"line":297,"column":10},"end":{"line":297,"column":49}},"217":{"start":{"line":298,"column":10},"end":{"line":298,"column":17}},"218":{"start":{"line":301,"column":6},"end":{"line":311,"column":9}},"219":{"start":{"line":302,"column":21},"end":{"line":302,"column":22}},"220":{"start":{"line":303,"column":8},"end":{"line":310,"column":11}},"221":{"start":{"line":304,"column":10},"end":{"line":304,"column":43}},"222":{"start":{"line":305,"column":10},"end":{"line":305,"column":42}},"223":{"start":{"line":306,"column":10},"end":{"line":306,"column":56}},"224":{"start":{"line":307,"column":10},"end":{"line":307,"column":68}},"225":{"start":{"line":308,"column":10},"end":{"line":308,"column":85}},"226":{"start":{"line":309,"column":10},"end":{"line":309,"column":17}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":41,"column":18},"end":{"line":41,"column":19}},"loc":{"start":{"line":41,"column":30},"end":{"line":314,"column":1}},"line":41},"2":{"name":"(anonymous_2)","decl":{"start":{"line":42,"column":9},"end":{"line":42,"column":10}},"loc":{"start":{"line":42,"column":25},"end":{"line":47,"column":3}},"line":42},"3":{"name":"(anonymous_3)","decl":{"start":{"line":43,"column":90},"end":{"line":43,"column":91}},"loc":{"start":{"line":43,"column":110},"end":{"line":46,"column":5}},"line":43},"4":{"name":"(anonymous_4)","decl":{"start":{"line":48,"column":9},"end":{"line":48,"column":10}},"loc":{"start":{"line":48,"column":25},"end":{"line":53,"column":3}},"line":48},"5":{"name":"(anonymous_5)","decl":{"start":{"line":49,"column":91},"end":{"line":49,"column":92}},"loc":{"start":{"line":49,"column":111},"end":{"line":52,"column":5}},"line":49},"6":{"name":"(anonymous_6)","decl":{"start":{"line":54,"column":9},"end":{"line":54,"column":10}},"loc":{"start":{"line":54,"column":25},"end":{"line":59,"column":3}},"line":54},"7":{"name":"(anonymous_7)","decl":{"start":{"line":55,"column":136},"end":{"line":55,"column":137}},"loc":{"start":{"line":55,"column":156},"end":{"line":58,"column":5}},"line":55},"8":{"name":"(anonymous_8)","decl":{"start":{"line":60,"column":8},"end":{"line":60,"column":9}},"loc":{"start":{"line":60,"column":24},"end":{"line":63,"column":3}},"line":60},"9":{"name":"(anonymous_9)","decl":{"start":{"line":65,"column":31},"end":{"line":65,"column":32}},"loc":{"start":{"line":65,"column":43},"end":{"line":313,"column":3}},"line":65},"10":{"name":"(anonymous_10)","decl":{"start":{"line":66,"column":75},"end":{"line":66,"column":76}},"loc":{"start":{"line":66,"column":91},"end":{"line":74,"column":5}},"line":66},"11":{"name":"(anonymous_11)","decl":{"start":{"line":67,"column":92},"end":{"line":67,"column":93}},"loc":{"start":{"line":67,"column":112},"end":{"line":73,"column":7}},"line":67},"12":{"name":"(anonymous_12)","decl":{"start":{"line":76,"column":59},"end":{"line":76,"column":60}},"loc":{"start":{"line":76,"column":75},"end":{"line":84,"column":5}},"line":76},"13":{"name":"(anonymous_13)","decl":{"start":{"line":77,"column":92},"end":{"line":77,"column":93}},"loc":{"start":{"line":77,"column":112},"end":{"line":83,"column":7}},"line":77},"14":{"name":"(anonymous_14)","decl":{"start":{"line":86,"column":50},"end":{"line":86,"column":51}},"loc":{"start":{"line":86,"column":66},"end":{"line":93,"column":5}},"line":86},"15":{"name":"(anonymous_15)","decl":{"start":{"line":87,"column":92},"end":{"line":87,"column":93}},"loc":{"start":{"line":87,"column":112},"end":{"line":92,"column":7}},"line":87},"16":{"name":"(anonymous_16)","decl":{"start":{"line":95,"column":34},"end":{"line":95,"column":35}},"loc":{"start":{"line":95,"column":46},"end":{"line":105,"column":5}},"line":95},"17":{"name":"(anonymous_17)","decl":{"start":{"line":96,"column":37},"end":{"line":96,"column":38}},"loc":{"start":{"line":96,"column":53},"end":{"line":104,"column":7}},"line":96},"18":{"name":"(anonymous_18)","decl":{"start":{"line":97,"column":92},"end":{"line":97,"column":93}},"loc":{"start":{"line":97,"column":112},"end":{"line":103,"column":9}},"line":97},"19":{"name":"(anonymous_19)","decl":{"start":{"line":107,"column":27},"end":{"line":107,"column":28}},"loc":{"start":{"line":107,"column":39},"end":{"line":142,"column":5}},"line":107},"20":{"name":"(anonymous_20)","decl":{"start":{"line":108,"column":58},"end":{"line":108,"column":59}},"loc":{"start":{"line":108,"column":74},"end":{"line":115,"column":7}},"line":108},"21":{"name":"(anonymous_21)","decl":{"start":{"line":109,"column":110},"end":{"line":109,"column":111}},"loc":{"start":{"line":109,"column":130},"end":{"line":114,"column":9}},"line":109},"22":{"name":"(anonymous_22)","decl":{"start":{"line":116,"column":74},"end":{"line":116,"column":75}},"loc":{"start":{"line":116,"column":90},"end":{"line":123,"column":7}},"line":116},"23":{"name":"(anonymous_23)","decl":{"start":{"line":117,"column":109},"end":{"line":117,"column":110}},"loc":{"start":{"line":117,"column":129},"end":{"line":122,"column":9}},"line":117},"24":{"name":"(anonymous_24)","decl":{"start":{"line":124,"column":66},"end":{"line":124,"column":67}},"loc":{"start":{"line":124,"column":82},"end":{"line":131,"column":7}},"line":124},"25":{"name":"(anonymous_25)","decl":{"start":{"line":125,"column":75},"end":{"line":125,"column":76}},"loc":{"start":{"line":125,"column":95},"end":{"line":130,"column":9}},"line":125},"26":{"name":"(anonymous_26)","decl":{"start":{"line":132,"column":63},"end":{"line":132,"column":64}},"loc":{"start":{"line":132,"column":79},"end":{"line":141,"column":7}},"line":132},"27":{"name":"(anonymous_27)","decl":{"start":{"line":134,"column":123},"end":{"line":134,"column":124}},"loc":{"start":{"line":134,"column":143},"end":{"line":140,"column":9}},"line":134},"28":{"name":"(anonymous_28)","decl":{"start":{"line":143,"column":32},"end":{"line":143,"column":33}},"loc":{"start":{"line":143,"column":44},"end":{"line":204,"column":5}},"line":143},"29":{"name":"(anonymous_29)","decl":{"start":{"line":144,"column":54},"end":{"line":144,"column":55}},"loc":{"start":{"line":144,"column":70},"end":{"line":156,"column":7}},"line":144},"30":{"name":"(anonymous_30)","decl":{"start":{"line":146,"column":116},"end":{"line":146,"column":117}},"loc":{"start":{"line":146,"column":136},"end":{"line":155,"column":9}},"line":146},"31":{"name":"(anonymous_31)","decl":{"start":{"line":157,"column":74},"end":{"line":157,"column":75}},"loc":{"start":{"line":157,"column":90},"end":{"line":169,"column":7}},"line":157},"32":{"name":"(anonymous_32)","decl":{"start":{"line":159,"column":115},"end":{"line":159,"column":116}},"loc":{"start":{"line":159,"column":135},"end":{"line":168,"column":9}},"line":159},"33":{"name":"(anonymous_33)","decl":{"start":{"line":170,"column":69},"end":{"line":170,"column":70}},"loc":{"start":{"line":170,"column":85},"end":{"line":177,"column":7}},"line":170},"34":{"name":"(anonymous_34)","decl":{"start":{"line":172,"column":116},"end":{"line":172,"column":117}},"loc":{"start":{"line":172,"column":136},"end":{"line":176,"column":9}},"line":172},"35":{"name":"(anonymous_35)","decl":{"start":{"line":178,"column":74},"end":{"line":178,"column":75}},"loc":{"start":{"line":178,"column":90},"end":{"line":186,"column":7}},"line":178},"36":{"name":"(anonymous_36)","decl":{"start":{"line":180,"column":117},"end":{"line":180,"column":118}},"loc":{"start":{"line":180,"column":137},"end":{"line":184,"column":9}},"line":180},"37":{"name":"(anonymous_37)","decl":{"start":{"line":187,"column":65},"end":{"line":187,"column":66}},"loc":{"start":{"line":187,"column":81},"end":{"line":195,"column":7}},"line":187},"38":{"name":"(anonymous_38)","decl":{"start":{"line":189,"column":116},"end":{"line":189,"column":117}},"loc":{"start":{"line":189,"column":136},"end":{"line":194,"column":9}},"line":189},"39":{"name":"(anonymous_39)","decl":{"start":{"line":196,"column":64},"end":{"line":196,"column":65}},"loc":{"start":{"line":196,"column":80},"end":{"line":203,"column":7}},"line":196},"40":{"name":"(anonymous_40)","decl":{"start":{"line":198,"column":116},"end":{"line":198,"column":117}},"loc":{"start":{"line":198,"column":136},"end":{"line":202,"column":9}},"line":198},"41":{"name":"(anonymous_41)","decl":{"start":{"line":205,"column":39},"end":{"line":205,"column":40}},"loc":{"start":{"line":205,"column":51},"end":{"line":254,"column":5}},"line":205},"42":{"name":"(anonymous_42)","decl":{"start":{"line":206,"column":73},"end":{"line":206,"column":74}},"loc":{"start":{"line":206,"column":89},"end":{"line":215,"column":7}},"line":206},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":146},"end":{"line":208,"column":147}},"loc":{"start":{"line":208,"column":166},"end":{"line":214,"column":9}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":216,"column":69},"end":{"line":216,"column":70}},"loc":{"start":{"line":216,"column":85},"end":{"line":225,"column":7}},"line":216},"45":{"name":"(anonymous_45)","decl":{"start":{"line":218,"column":153},"end":{"line":218,"column":154}},"loc":{"start":{"line":218,"column":173},"end":{"line":224,"column":9}},"line":218},"46":{"name":"(anonymous_46)","decl":{"start":{"line":226,"column":72},"end":{"line":226,"column":73}},"loc":{"start":{"line":226,"column":88},"end":{"line":235,"column":7}},"line":226},"47":{"name":"(anonymous_47)","decl":{"start":{"line":228,"column":147},"end":{"line":228,"column":148}},"loc":{"start":{"line":228,"column":167},"end":{"line":234,"column":9}},"line":228},"48":{"name":"(anonymous_48)","decl":{"start":{"line":236,"column":102},"end":{"line":236,"column":103}},"loc":{"start":{"line":236,"column":118},"end":{"line":244,"column":7}},"line":236},"49":{"name":"(anonymous_49)","decl":{"start":{"line":238,"column":153},"end":{"line":238,"column":154}},"loc":{"start":{"line":238,"column":173},"end":{"line":243,"column":9}},"line":238},"50":{"name":"(anonymous_50)","decl":{"start":{"line":245,"column":99},"end":{"line":245,"column":100}},"loc":{"start":{"line":245,"column":115},"end":{"line":253,"column":7}},"line":245},"51":{"name":"(anonymous_51)","decl":{"start":{"line":247,"column":153},"end":{"line":247,"column":154}},"loc":{"start":{"line":247,"column":173},"end":{"line":252,"column":9}},"line":247},"52":{"name":"(anonymous_52)","decl":{"start":{"line":255,"column":35},"end":{"line":255,"column":36}},"loc":{"start":{"line":255,"column":47},"end":{"line":280,"column":5}},"line":255},"53":{"name":"(anonymous_53)","decl":{"start":{"line":256,"column":65},"end":{"line":256,"column":66}},"loc":{"start":{"line":256,"column":81},"end":{"line":262,"column":7}},"line":256},"54":{"name":"(anonymous_54)","decl":{"start":{"line":258,"column":119},"end":{"line":258,"column":120}},"loc":{"start":{"line":258,"column":139},"end":{"line":261,"column":9}},"line":258},"55":{"name":"(anonymous_55)","decl":{"start":{"line":263,"column":73},"end":{"line":263,"column":74}},"loc":{"start":{"line":263,"column":89},"end":{"line":270,"column":7}},"line":263},"56":{"name":"(anonymous_56)","decl":{"start":{"line":265,"column":118},"end":{"line":265,"column":119}},"loc":{"start":{"line":265,"column":138},"end":{"line":269,"column":9}},"line":265},"57":{"name":"(anonymous_57)","decl":{"start":{"line":271,"column":62},"end":{"line":271,"column":63}},"loc":{"start":{"line":271,"column":78},"end":{"line":279,"column":7}},"line":271},"58":{"name":"(anonymous_58)","decl":{"start":{"line":273,"column":119},"end":{"line":273,"column":120}},"loc":{"start":{"line":273,"column":139},"end":{"line":278,"column":9}},"line":273},"59":{"name":"(anonymous_59)","decl":{"start":{"line":281,"column":51},"end":{"line":281,"column":52}},"loc":{"start":{"line":281,"column":63},"end":{"line":312,"column":5}},"line":281},"60":{"name":"(anonymous_60)","decl":{"start":{"line":282,"column":68},"end":{"line":282,"column":69}},"loc":{"start":{"line":282,"column":84},"end":{"line":290,"column":7}},"line":282},"61":{"name":"(anonymous_61)","decl":{"start":{"line":284,"column":134},"end":{"line":284,"column":135}},"loc":{"start":{"line":284,"column":154},"end":{"line":289,"column":9}},"line":284},"62":{"name":"(anonymous_62)","decl":{"start":{"line":291,"column":70},"end":{"line":291,"column":71}},"loc":{"start":{"line":291,"column":86},"end":{"line":300,"column":7}},"line":291},"63":{"name":"(anonymous_63)","decl":{"start":{"line":293,"column":100},"end":{"line":293,"column":101}},"loc":{"start":{"line":293,"column":120},"end":{"line":299,"column":9}},"line":293},"64":{"name":"(anonymous_64)","decl":{"start":{"line":301,"column":69},"end":{"line":301,"column":70}},"loc":{"start":{"line":301,"column":85},"end":{"line":311,"column":7}},"line":301},"65":{"name":"(anonymous_65)","decl":{"start":{"line":303,"column":134},"end":{"line":303,"column":135}},"loc":{"start":{"line":303,"column":154},"end":{"line":310,"column":9}},"line":303}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":0,"129":0,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":1,"139":1,"140":1,"141":1,"142":1,"143":0,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1,"197":1,"198":1,"199":1,"200":1,"201":1,"202":1,"203":1,"204":1,"205":1,"206":1,"207":1,"208":1,"209":1,"210":1,"211":1,"212":1,"213":1,"214":1,"215":1,"216":1,"217":1,"218":1,"219":1,"220":1,"221":1,"222":1,"223":1,"224":1,"225":1,"226":1},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"713a643645eedc6218cd0bff22af62fbb26e9d38","contentHash":"f3d48e125f75eafa9592af49762a9de6_11.0.3"}} \ No newline at end of file diff --git a/coverage/auth.spec.js.html b/coverage/auth.spec.js.html new file mode 100644 index 0000000..0bf1156 --- /dev/null +++ b/coverage/auth.spec.js.html @@ -0,0 +1,383 @@ + + + + Code coverage report for auth.spec.js + + + + + + + +
+
+

+ All files auth.spec.js +

+
+
+ 12.5% + Statements + 8/64 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/20 +
+
+ 12.7% + Lines + 8/63 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +1071x +1x +1x +1x +1x +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
process.NODE_ENV = 'test';
+const chai = require('chai');
+require('dotenv').config();
+const chaiHttp = require('chai-http');
+const expect = chai.expect;
+const EventEmitter = require('events').EventEmitter;
+const httpMocks = require('node-mocks-http');
+const samples = require('../apiEndpoints/mockdata');
+const server = require('../../../index');
+const auth = require('../../middlewares/auth');
+ 
+chai.use(chaiHttp);
+let adminToken, userToken;
+describe('Authentication', () => {
+  before((done) => {
+    chai.request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'johnbosco.ohia@andela.com', password: process.env.PASSWORD })
+      .end((err, res) => {
+        adminToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    chai.request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'testdoe@andela.com', password: 'jamestest' })
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('VerifyToken', () => {
+    it('Should check if the token is provided with request', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents',
+      });
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.verifyToken(request, response, nextCallBack);
+      expect(response._getData().message).to.equal('No token provided.');
+      done();
+    });
+  it('Should provide access if the token is provided and valid', (done) => {
+    const request = httpMocks.createRequest({
+      method: 'GET',
+      url: '/api/v1/documents',
+      headers: { 'x-access-token': adminToken }
+    });
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyJwtToken(request, response, nextCallBack);
+    expect(response._getData().message).to.equal(undefined);
+    done();
+  });
+  it('Should deny access if the token is invalid', (done) => {
+    const request = httpMocks.createRequest({
+      method: 'GET',
+      url: '/api/v1/documents/',
+      headers: { 'x-access-token': 'themaniscoming' }
+    });
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyJwtToken(request, response, nextCallBack);
+ 
+    response.on('end', () => {
+      expect(response._getData().success).to.equal(false);
+    });
+    done();
+  });
+  });
+  describe('AdminAcess', () => {
+    it('Should deny access if the user is not admin', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents/',
+        headers: { 'x-access-token': userToken }
+      });
+      request.decoded = { roleId: 2 };
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.adminAccess(request, response, nextCallBack);
+      response.on('end', () => {
+        expect(response._getData().message).to.equal('You are not authorized');
+      });
+      done();
+    });
+    it('Should grant access if the user is an admin', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents/',
+        headers: { 'x-access-token': adminToken }
+      });
+      request.decoded = { roleId: 1 };
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.adminAccess(request, response, nextCallBack);
+      response.on('end', () => {
+        expect(response._getData().message).to.equal(undefined);
+      });
+      done();
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/base.css b/coverage/base.css new file mode 100644 index 0000000..417c7ad --- /dev/null +++ b/coverage/base.css @@ -0,0 +1,212 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } + + +.medium .chart { border:1px solid #666; } +.medium .cover-fill { background: #666; } + +.cbranch-no { background: yellow !important; color: #111; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } +.medium { background: #eaeaea; } + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html new file mode 100644 index 0000000..eb98eb7 --- /dev/null +++ b/coverage/document-manager/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for document-manager + + + + + + + +
+
+

+ All files document-manager +

+
+
+ 100% + Statements + 4/4 +
+
+ 100% + Branches + 2/2 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 4/4 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.js
100%4/4100%2/2100%1/1100%4/4
+
+
+ + + + + + + diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html new file mode 100644 index 0000000..4255d98 --- /dev/null +++ b/coverage/document-manager/index.js.html @@ -0,0 +1,92 @@ + + + + Code coverage report for document-manager/index.js + + + + + + + +
+
+

+ All files / document-manager index.js +

+
+
+ 100% + Statements + 4/4 +
+
+ 100% + Branches + 2/2 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 4/4 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +101x +  +1x +  +1x +1x +  +  +  + 
import app from './server/config/express';
+ 
+const port = process.env.PORT || 3000;
+ 
+const server = app.listen(port, () => {
+  console.log('API Server started and listening on port 3000');
+});
+ 
+export default server;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html new file mode 100644 index 0000000..053bc6d --- /dev/null +++ b/coverage/document-manager/server/config/config.js.html @@ -0,0 +1,140 @@ + + + + Code coverage report for document-manager/server/config/config.js + + + + + + + +
+
+

+ All files / document-manager/server/config config.js +

+
+
+ 100% + Statements + 1/1 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 1/1 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +261x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
module.exports = {
+  development: {
+    username: 'andeladeveloper',
+    password: null,
+    database: 'docmanager-dev',
+    host: '127.0.0.1',
+    port: 5432,
+    dialect: 'postgres'
+  },
+  test: {
+    username: 'andeladeveloper',
+    password: null,
+    database: 'docmanager-test',
+    host: '127.0.0.1',
+    port: 5432,
+    dialect: 'postgres'
+  },
+  production: {
+    username: 'root',
+    password: null,
+    database: 'database_production',
+    host: '127.0.0.1',
+    dialect: 'postgres'
+  }
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html new file mode 100644 index 0000000..d3ee812 --- /dev/null +++ b/coverage/document-manager/server/config/express.js.html @@ -0,0 +1,155 @@ + + + + Code coverage report for document-manager/server/config/express.js + + + + + + + +
+
+

+ All files / document-manager/server/config express.js +

+
+
+ 100% + Statements + 20/20 +
+
+ 100% + Branches + 2/2 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 19/19 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +311x +1x +1x +1x +1x +  +1x +  +1x +  +1x +1x +1x +  +1x +76x +76x +76x +106x +102x +102x +  +76x +  +  +  +1x +  +  +  + 
import express from 'express';
+import bodyParser from 'body-parser';
+import logger from 'morgan';
+import expressValidator from 'express-validator';
+import routes from '../routes';
+ 
+const app = express();
+ 
+app.use(logger('dev'));
+ 
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: false }));
+app.use(expressValidator());
+ 
+app.use((req, res, next) => {
+  const send = res.send;
+  let sent = false;
+  res.send = (data) => {
+    if (sent) return;
+    send.bind(res)(data);
+    sent = true;
+  };
+  next();
+});
+ 
+// mount all routes on /api path
+app.use('/api/v1', routes);
+ 
+ 
+export default app;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html new file mode 100644 index 0000000..fb72392 --- /dev/null +++ b/coverage/document-manager/server/config/index.html @@ -0,0 +1,106 @@ + + + + Code coverage report for document-manager/server/config + + + + + + + +
+
+

+ All files document-manager/server/config +

+
+
+ 100% + Statements + 21/21 +
+
+ 100% + Branches + 2/2 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 20/20 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
config.js
100%1/1100%0/0100%0/0100%1/1
express.js
100%20/20100%2/2100%2/2100%19/19
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html new file mode 100644 index 0000000..29ea6cc --- /dev/null +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -0,0 +1,737 @@ + + + + Code coverage report for document-manager/server/controllers/documents.js + + + + + + + +
+
+

+ All files / document-manager/server/controllers documents.js +

+
+
+ 81.16% + Statements + 56/69 +
+
+ 85.71% + Branches + 36/42 +
+
+ 64% + Functions + 16/25 +
+
+ 81.16% + Lines + 56/69 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +2251x +1x +  +1x +1x +1x +  +  +  +  +  +  +  +  +2x +2x +2x +  +2x +  +2x +1x +  +1x +  +  +  +  +1x +1x +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +  +  +4x +4x +  +4x +1x +  +  +  +3x +2x +  +  +  +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +3x +3x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +6x +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +7x +  +7x +1x +  +7x +1x +  +6x +1x +  +4x +2x +1x +  +  +  +1x +  +2x +2x +  +  +2x +  +  +1x +  +  +  +1x +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +4x +  +4x +1x +  +4x +  +  +  +1x +  +  +  +2x +  +2x +  +  +  +1x +  +  +  +  +  +  +  +  + 
import helper from '../helpers/helper';
+import models from '../models';
+ 
+const Document = models.Document;
+const User = models.User;
+const metaData = helper.paginationMetaData;
+ 
+/**
+ * Create documents for users
+ * @param {object} req - document to be created
+ * @param {object} res - created document
+ * @returns {object} - created document
+ */
+function createDocument(req, res) {
+  req.check('title', 'Title is required').notEmpty();
+  req.check('content', 'Content is required').notEmpty();
+  req.check('access', 'accessType is required').notEmpty();
+ 
+  const errors = req.validationErrors();
+ 
+  if (errors) {
+    res.status(400).json({ errors });
+  } else {
+    Document.findAll({
+      where: {
+        title: req.body.title
+      }
+    }).then((document) => {
+      Eif (document.length === 0) {
+        return Document.create({
+          title: req.body.title,
+          content: req.body.content,
+          access: req.body.value,
+          userId: req.body.userId
+        })
+      .then(documentResponse => res.status(201).send(documentResponse))
+      .catch(error => res.status(400).send(error));
+      }
+      return res.status(403).json({
+        title: 'Document already exists'
+      });
+    }).catch(error => res.status(400).send(error));
+  }
+}
+ 
+/**
+ * Update user document.
+ * @param {number} req - request id of the document to be updated
+ * @param {object} res - object of the updated document
+ * @returns {object} - updated document
+ */
+function updateDocument(req, res) {
+  Iif (isNaN(req.params.id)) {
+    return res.status(400);
+  }
+  const docId = Number(req.params.id);
+  return Document.findById(docId)
+    .then((document) => {
+      if (!document) {
+        return res.status(404).send({
+          message: 'Document Not Found'
+        });
+      }
+      if (Number(document.userId) !== Number(req.decoded.id)) {
+        return res.status(401).json({
+          message: 'You are not authorized to edit this document'
+        });
+      }
+      return document
+        .update({
+          title: req.body.title || document.title,
+          content: req.body.content || document.content,
+          access: req.body.value || document.access,
+          userId: req.body.userId || document.userId
+        })
+        .then(() => res.status(200).send(document))
+        .catch(error => res.status(400).send(error));
+    })
+    .catch(error => res.status(400).send(error));
+}
+ 
+/**
+ *  Get all documents
+ * @param {object} req - contains an object of the query, limits and offset
+ * @param {array} res - array of documents with pagination
+ * @returns {array} - array of documents
+ */
+function getAllDocument(req, res) {
+  const limit = req.query.limit;
+  const offset = req.query.offset;
+  Iif (req.decoded.roleId === 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      where: {
+        access: {
+          $ne: 'private'
+        }
+      },
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId']
+        }
+      ]
+    })
+    .then(({ rows: document, count }) => {
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  } else Eif (req.decoded.roleId !== 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId'],
+          where: {
+            roleId: req.decoded.roleId
+          },
+        },
+      ],
+      where: {
+        access: {
+          $ne: 'private'
+        }
+      },
+ 
+    })
+    .then(({ rows: document, count }) => {
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  }
+}
+ 
+/**
+   * Find a document by Id
+   * @param {number} req - id of the requested document
+   * @param {object} res - object containg the requested document
+   * @returns {object} requested document
+   */
+function findDocument(req, res) {
+  return Document.findById(req.params.id)
+    .then((document) => {
+      if (!document) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      if (req.decoded.roleId === 1) {
+        return document;
+      }
+      if (document.access === 'public') {
+        return res.status(200).send(document);
+      }
+      if (document.access === 'private') {
+        if (document.userId !== req.decoded.id) {
+          return res.status(401).json({
+            message: 'You are not authorized to view this document'
+          });
+        }
+        return res.status(200).send(document);
+      }
+      Eif (document.access === 'role') {
+        return models.User
+          .findById(document.userId)
+          .then((documentOwner) => {
+            if (
+              Number(documentOwner.roleId) !== Number(req.decoded.roleId)
+            ) {
+              return res.status(401).json({
+                message: 'You are not authorized to view this document'
+              });
+            }
+            return res.status(200).send(document);
+          })
+          .catch(error => res.status(400).send(error));
+      }
+    })
+    .catch(error => res.status(400).send(error));
+}
+ 
+/**
+ *
+ * Delete a document by Id
+ * @param {number} req - id of the requested document
+ * @param {object} res - message
+ * @returns {object} - message
+ */
+function deleteDocument(req, res) {
+  return Document.findById(req.params.id)
+    .then((document) => {
+      if (!document) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      if (
+        req.decoded.roleId !== 1 &&
+        Number(document.userId) !== Number(req.decoded.id)
+      ) {
+        return res.status(401).json({
+          message: 'You are not authorized to delete this document'
+        });
+      }
+      return document
+        .destroy()
+        .then(() => res.status(204)
+          .send({ message: 'Document deleted successfully' }))
+        .catch(error => res.status(400).send(error));
+    })
+    .catch(error => res.status(400).send(error));
+}
+ 
+export default {
+  createDocument,
+  updateDocument,
+  getAllDocument,
+  findDocument,
+  deleteDocument };
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html new file mode 100644 index 0000000..6b24c05 --- /dev/null +++ b/coverage/document-manager/server/controllers/index.html @@ -0,0 +1,132 @@ + + + + Code coverage report for document-manager/server/controllers + + + + + + + +
+
+

+ All files document-manager/server/controllers +

+
+
+ 72.73% + Statements + 168/231 +
+
+ 72.41% + Branches + 84/116 +
+
+ 64.29% + Functions + 54/84 +
+
+ 72.73% + Lines + 168/231 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
documents.js
81.16%56/6985.71%36/4264%16/2581.16%56/69
roles.js
82.5%33/4072.22%13/1880.95%17/2182.5%33/40
search.js
14.29%5/350%0/140%0/814.29%5/35
users.js
85.06%74/8783.33%35/4270%21/3085.06%74/87
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html new file mode 100644 index 0000000..6bdbfc9 --- /dev/null +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -0,0 +1,467 @@ + + + + Code coverage report for document-manager/server/controllers/roles.js + + + + + + + +
+
+

+ All files / document-manager/server/controllers roles.js +

+
+
+ 82.5% + Statements + 33/40 +
+
+ 72.22% + Branches + 13/18 +
+
+ 80.95% + Functions + 17/21 +
+
+ 82.5% + Lines + 33/40 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +1351x +  +1x +  +  +  +  +  +  +  +  +3x +  +3x +3x +  +  +3x +  +  +2x +2x +  +  +2x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +1x +  +1x +  +  +  +  +  +  +  +  +  +  +4x +1x +  +  +  +3x +  +  +2x +1x +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +  +3x +  +  +  +3x +  +  +2x +1x +  +  +  +1x +  +  +  +1x +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +2x +  +  +  +2x +  +2x +1x +  +  +  +2x +  +  +  +  +  +1x +1x +  +  +  + 
const models = require('../models');
+ 
+const Role = models.Role;
+ 
+/**
+ * Creates a new Role.
+ * @param {object} req - role to be created
+ * @param {object} res - new created role
+ * @returns {object} - newly created role
+ */
+function createRole(req, res) {
+  req.check('title', 'Title is required').notEmpty();
+ 
+  const errors = req.validationErrors();
+  Iif (errors) {
+    res.status(400).json({ errors });
+  } else {
+    Role.findAll({
+      where: { title: req.body.title }
+    }).then((err, existingRole) => {
+      Eif (!existingRole) {
+        Role.create({
+          title: req.body.title
+        }).then((role) => {
+          res.status(201).send({
+            message: 'Role successfully created',
+            role
+          });
+        }).catch((error) => {
+          res.json(error.errors);
+        });
+      }
+    }).catch(error => res.json(error));
+  }
+}
+ 
+/**
+ * Get all roles.
+ * @param {void} req - no request body attached
+ * @param {array} res - an array of roles and their id
+ * @returns {array} array of roles
+ */
+function getRoles(req, res) {
+  return Role
+    .findAll()
+    .then(role => res.status(200).json(role))
+    .catch(error => res.json(error));
+}
+ 
+/**
+ * Find roles by Id.
+ * @param {number} req - requested role
+ * @param {object} res - role found by id
+ * @returns {object} - role found by id
+ */
+function findRole(req, res) {
+  if (isNaN(req.params.id)) {
+    return res.status(401).json({
+      message: `invalid input syntax for integer: "${req.params.id}"`
+    });
+  } else {
+    Role
+      .findById(req.params.id)
+      .then((role) => {
+        if (!role) {
+          return res.status(404).json({
+            message: 'Role not found'
+          });
+        }
+        res.status(200).json(role);
+      }).catch(error => res.status(400).json(error));
+  }
+}
+ 
+/**
+ * Update role.
+ * @param {number} req - requested role by id
+ * @param {object} res - updated role
+ * @returns {object} - updated role status
+ */
+function updateRole(req, res) {
+  Iif (req.decoded.roleId !== 1) {
+    return res.status(401)
+      .json({ message: 'You are not authorized to access the role' });
+  }
+  return Role
+    .findById(req.params.id)
+    .then((role) => {
+      if (!role) {
+        return res.status(404).json({
+          message: 'Role not found'
+        });
+      }
+      return role
+        .update({
+          title: req.body.title || role.title
+        })
+        .then(() => res.status(200).json({
+          message: 'Role updated successfully',
+          role
+        }))
+        .catch(error => res.status(400).json(error));
+    }).catch(error => res.status(400).json(error));
+}
+ 
+/**
+ * Delete roles by Id.
+ * @param {number} req - role to be deleted by id
+ * @param {object} res - deleted role
+ * @returns {object} - message
+ */
+function deleteRole(req, res) {
+  Iif (req.decoded.roleId !== 1) {
+    return res.status(401)
+      .json({ message: 'You are not authorized to access the role' });
+  }
+  return Role.findById(req.params.id)
+    .then((role) => {
+      if (!role) {
+        res.status(404).json({
+          message: 'Role not found'
+        });
+      }
+      return role
+        .destroy()
+        .then(() => res.status(204)
+          .json({
+            message: 'Role deleted successfully'
+          }))
+          .catch(error => res.status(400).send(error));
+    }).catch(error => res.json(error));
+}
+ 
+export default { createRole, getRoles, findRole, updateRole, deleteRole };
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html new file mode 100644 index 0000000..d3f8d61 --- /dev/null +++ b/coverage/document-manager/server/controllers/search.js.html @@ -0,0 +1,440 @@ + + + + Code coverage report for document-manager/server/controllers/search.js + + + + + + + +
+
+

+ All files / document-manager/server/controllers search.js +

+
+
+ 14.29% + Statements + 5/35 +
+
+ 0% + Branches + 0/14 +
+
+ 0% + Functions + 0/8 +
+
+ 14.29% + Lines + 5/35 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +1261x +1x +  +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import helper from '../helpers/helper';
+import models from '../models';
+ 
+const Document = models.Document;
+const User = models.User;
+const metaData = helper.paginationMetaData;
+ 
+/**
+ * Search for user using a query string
+ * @param {string} req - search query of string
+ * @param {array} res - array of users
+ * @returns {array} - array users searched
+ */
+function searchUser(req, res) {
+  const searchQuery = req.query.q,
+    limit = req.query.limit,
+    offset = req.query.offset;
+  if (!searchQuery) {
+    return res.status(400).json({
+      message: 'Invalid search input'
+    });
+  }
+  return User
+  .findAndCountAll({
+    limit,
+    offset,
+    attributes: { exclude: ['password'] },
+    where: {
+      userName: {
+        $like: `%${searchQuery}%`,
+      }
+    }
+  }).then(({ rows: user, count }) => {
+    if (count === 0) {
+      return res.status(404).json({ message: 'User not found' });
+    }
+    res.status(200).send({
+      user,
+      pagination: metaData(count, limit, offset)
+    });
+  }).catch(error => res.status(400).send(error));
+}
+ 
+/**
+   *
+   * Search for documents by title
+   * @param {string} req - an object containing the query, offset and limit
+   * @param {array} res - an array containing searched document
+   * @returns {array} - searched document
+   */
+function searchDocuments(req, res) {
+  const limit = req.query.limit,
+    offset = req.query.offset,
+    queryString = req.query.q;
+  if (!queryString) {
+    return res.status(400).json({
+      message: 'Invalid search input'
+    });
+  }
+  if (req.decoded.roleId === 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      where: {
+        access: {
+          $ne: 'private'
+        },
+        title: {
+          $like: `%${queryString}%`
+        }
+      },
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId']
+        }
+      ]
+    })
+    .then(({ rows: document, count }) => {
+      if (count === 0) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  } else if (req.decoded.roleId !== 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId'],
+          where: {
+            roleId: req.decoded.roleId
+          },
+        },
+      ],
+      where: {
+        access: {
+          $ne: 'private'
+        },
+        title: {
+          $like: `%${queryString}%`
+        }
+      },
+ 
+    })
+    .then(({ rows: document, count }) => {
+      if (count === 0) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  }
+}
+ 
+export default { searchUser, searchDocuments };
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/searches.js.html b/coverage/document-manager/server/controllers/searches.js.html new file mode 100644 index 0000000..029411e --- /dev/null +++ b/coverage/document-manager/server/controllers/searches.js.html @@ -0,0 +1,440 @@ + + + + Code coverage report for document-manager/server/controllers/searches.js + + + + + + + +
+
+

+ All files / document-manager/server/controllers searches.js +

+
+
+ 14.29% + Statements + 5/35 +
+
+ 0% + Branches + 0/14 +
+
+ 0% + Functions + 0/8 +
+
+ 14.29% + Lines + 5/35 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +1261x +1x +  +1x +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import helper from '../helpers/helper';
+import models from '../models';
+ 
+const Document = models.Document;
+const User = models.User;
+const metaData = helper.paginationMetaData;
+ 
+/**
+ * Search for user using a query string
+ * @param {string} req - search query of string
+ * @param {array} res - array of users
+ * @returns {array} - array users searched
+ */
+function searchUser(req, res) {
+  const searchQuery = req.query.q,
+    limit = req.query.limit,
+    offset = req.query.offset;
+  if (!searchQuery) {
+    return res.status(400).json({
+      message: 'Invalid search input'
+    });
+  }
+  return User
+  .findAndCountAll({
+    limit,
+    offset,
+    attributes: { exclude: ['password'] },
+    where: {
+      userName: {
+        $like: `%${searchQuery}%`,
+      }
+    }
+  }).then(({ rows: user, count }) => {
+    if (count === 0) {
+      return res.status(404).json({ message: 'User not found' });
+    }
+    res.status(200).send({
+      user,
+      pagination: metaData(count, limit, offset)
+    });
+  }).catch(error => res.status(400).send(error));
+}
+ 
+/**
+   *
+   * Search for documents by title
+   * @param {string} req - an object containing the query, offset and limit
+   * @param {array} res - an array containing searched document
+   * @returns {array} - searched document
+   */
+function searchDocuments(req, res) {
+  const limit = req.query.limit,
+    offset = req.query.offset,
+    queryString = req.query.q;
+  if (!queryString) {
+    return res.status(400).json({
+      message: 'Invalid search input'
+    });
+  }
+  if (req.decoded.roleId === 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      where: {
+        access: {
+          $ne: 'private'
+        },
+        title: {
+          $like: `%${queryString}%`
+        }
+      },
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId']
+        }
+      ]
+    })
+    .then(({ rows: document, count }) => {
+      if (count === 0) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  } else if (req.decoded.roleId !== 1) {
+    return Document.findAndCountAll({
+      limit,
+      offset,
+      include: [
+        {
+          model: User,
+          attributes: ['userName', 'roleId'],
+          where: {
+            roleId: req.decoded.roleId
+          },
+        },
+      ],
+      where: {
+        access: {
+          $ne: 'private'
+        },
+        title: {
+          $like: `%${queryString}%`
+        }
+      },
+ 
+    })
+    .then(({ rows: document, count }) => {
+      if (count === 0) {
+        res.status(404).json({ message: 'Document not found' });
+      }
+      res.status(200).send({
+        document,
+        pagination: metaData(count, limit, offset),
+      });
+    })
+    .catch(error => res.status(400).send(error));
+  }
+}
+ 
+export default { searchUser, searchDocuments };
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html new file mode 100644 index 0000000..dd0541b --- /dev/null +++ b/coverage/document-manager/server/controllers/users.js.html @@ -0,0 +1,917 @@ + + + + Code coverage report for document-manager/server/controllers/users.js + + + + + + + +
+
+

+ All files / document-manager/server/controllers users.js +

+
+
+ 85.06% + Statements + 74/87 +
+
+ 83.33% + Branches + 35/42 +
+
+ 70% + Functions + 21/30 +
+
+ 85.06% + Lines + 74/87 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +2851x +1x +  +1x +1x +  +1x +  +1x +1x +1x +1x +  +  +  +  +  +  +  +  +2x +2x +2x +  +  +  +  +  +4x +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +1x +1x +1x +1x +  +1x +  +1x +  +  +1x +  +  +1x +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +15x +15x +15x +  +15x +  +15x +  +  +15x +  +  +  +15x +15x +1x +  +  +14x +14x +  +13x +  +  +  +  +  +  +13x +  +  +13x +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +5x +5x +  +  +  +  +5x +1x +  +  +  +4x +  +  +  +  +  +  +  +3x +1x +  +3x +  +1x +  +  +  +  +  +  +  +  +  +5x +2x +  +  +  +3x +3x +3x +3x +  +  +3x +  +  +3x +  +  +  +  +  +  +  +  +3x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +3x +1x +  +  +  +2x +  +  +2x +1x +  +1x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +2x +2x +  +2x +1x +  +  +  +1x +  +  +  +  +  +  +2x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import bcrypt from 'bcrypt';
+import jwt from 'jsonwebtoken';
+ 
+import helper from '../helpers/helper';
+import models from '../models';
+ 
+require('dotenv').config();
+ 
+const jwtSecret = process.env.JWT_SECRET;
+const Document = models.Document;
+const User = models.User;
+const metaData = helper.paginationMetaData;
+ 
+/**
+ * Get all users
+ * @param {number} req - limit and offset for getting all user
+ * @param {array} res - array of users or error
+ * @returns {array} - an array of users
+ */
+function getUsers(req, res) {
+  const limit = req.query.limit;
+  const offset = req.query.offset;
+  return User
+  .findAndCountAll(
+    { limit,
+      offset,
+      attributes: { exclude: ['password'] }
+    })
+  .then(({ rows: user, count }) => {
+    res.status(200).send({
+      user,
+      pagination: metaData(count, limit, offset)
+    });
+  })
+  .catch(error => res.status(400).send(error));
+}
+ 
+/**
+ * Create a user
+ * @param {object} req - request from user
+ * @param {object} res - newly created user or error
+ * @returns {object} - an object of a created user
+ */
+function createUser(req, res) {
+  req.check('fullName', 'FullName is required').notEmpty();
+  req.check('userName', 'userName is required').notEmpty();
+  req.check('email', 'Email is required').notEmpty();
+  req.check('email', 'Please put a valid email').isEmail();
+  req.check('password', 'Password is required').notEmpty();
+  req.check('password', 'Password must be a mininum of 4 character')
+  .isLength(4, 50);
+  const errors = req.validationErrors();
+ 
+  Iif (errors) {
+    res.status(400).json({ errors });
+  } else {
+    User.findAll({
+      where: { email: req.body.email }
+    }).then((err, user) => {
+      Eif (!user) {
+        User.create({
+          fullName: req.body.fullName,
+          userName: req.body.userName,
+          email: req.body.email,
+          password: bcrypt.hashSync(req.body.password, bcrypt.genSaltSync(10)),
+          roleId: req.body.roleId || 2
+        }).then((userDetails) => {
+          res.status(200).json({
+            userDetails,
+            success: true,
+            message: 'You have successfully registered.'
+          });
+        }).catch((error) => {
+          res.status(400).json(error);
+        });
+      }
+    });
+  }
+}
+ 
+/**
+ * Log In user with JWT
+ * @param {object} req - request from log in user
+ * @param {object} res - authenicated user details
+ * @returns {object} - an object of the logged in user and a token
+ */
+function login(req, res) {
+  req.check('email', 'Email is required').notEmpty();
+  req.check('email', 'Please put a valid email').isEmail();
+  req.check('password', 'Password is required').notEmpty();
+ 
+  const errors = req.validationErrors();
+ 
+  Iif (errors) {
+    res.status(400).json({ errors });
+  } else {
+    User.findAll({
+      where: { email: req.body.email }
+    })
+    .then((user) => {
+      const existingUser = user[0];
+      if (!existingUser) {
+        res.status(400).json({
+          success: false,
+          message: 'Authentication failed. User not found.' });
+      } else Eif (existingUser) {
+        if (bcrypt.compareSync(req.body.password, existingUser.password)) {
+          const payLoad = (
+            {
+              email: existingUser.email,
+              id: existingUser.id,
+              fullName: existingUser.fullName,
+              roleId: existingUser.roleId,
+            }
+          );
+          const token = jwt.sign(payLoad, jwtSecret, {
+            expiresIn: 60 * 60 * 24
+          });
+          res.status(201).json({
+            success: true,
+            token,
+          });
+        } else {
+          res.status(401).json({
+            success: false,
+            message: 'Authentication failed. Wrong password.'
+          });
+        }
+      }
+    }).catch(error => res.status(400).send(error));
+  }
+}
+ 
+/**
+ * Find a user by Id
+ * @param {number} req - request for user using the id of the user
+ * @param {object} res - an object of the user(s) found or error
+ * @returns {object} - an object of found user
+ */
+function findUser(req, res) {
+  const userQuery = Number(req.params.id);
+  Iif ((req.decoded.id !== userQuery) && (req.decoded.roleId !== 1)) {
+    return res.status(401).json({
+      message: 'Unauthorized Access'
+    });
+  }
+  if (isNaN(userQuery)) {
+    return res.status(401).json({
+      message: `invalid input syntax for integer: "${req.params.id}"`
+    });
+  }
+  return User
+    .findAll({
+      where: {
+        id: req.params.id,
+      },
+      attributes: { exclude: ['password'] }
+    })
+    .then((user) => {
+      if (!user.length) {
+        res.status(404).json({ message: 'User not found' });
+      }
+      res.status(200).send(user);
+    })
+    .catch(error => res.status(400).send(error));
+}
+ 
+/**
+ *Update a user by Id
+ * @param {object} req - updated user object
+ * @param {object} res - updated user object or error
+ * @returns {object} - return an object of the updated user
+ */
+function updateUser(req, res) {
+  if (Number(req.decoded.id) !== Number(req.params.id)) {
+    return res.status(401).json({
+      message: 'You are not authorized to access this user'
+    });
+  }
+  const userId = Number(req.params.id);
+  bcrypt.genSalt(10, (err, salt) => {
+    bcrypt.hash(req.body.password, salt, (err, hash) => {
+      User
+      .findById(userId)
+      .then((user) => {
+        Iif (!user) {
+          return res.status(404).json({ message: 'User not found' });
+        }
+        return user
+          .update({
+            fullName: req.body.fullName || user.fullName,
+            userName: req.body.userName || user.userName,
+            email: req.body.email || user.email,
+            password: hash || user.password,
+            roleId: req.body.roleId || user.roleId
+          })
+          .then((updatedUser) => {
+            res.status(200).send({
+              id: updatedUser.id,
+              fullName: updatedUser.fullName,
+              userName: updatedUser.userName,
+              email: updatedUser.email,
+              roleId: updatedUser.roleId,
+              message: 'Details successfully updated.'
+            });
+          })
+          .catch(error => res.status(400).send(error));
+      })
+      .catch(error => res.status(400).send(error));
+    });
+  });
+}
+ 
+/**
+ * Delete a user by Id
+ * @param {number} req - delete user with an id
+ * @param {object} res - message
+ * @returns {object} - null
+ */
+function deleteUser(req, res) {
+  if (req.decoded.roleId !== 1) {
+    return res.status(401).json({
+      message: 'You are not authorized to access this field'
+    });
+  }
+  return User
+  .findById(req.params.id)
+  .then((user) => {
+    if (!user) {
+      return res.status(404).json({ message: 'User not found' });
+    }
+    return user
+      .destroy()
+      .then(() => res.status(204).json({
+        message: 'User has been deleted successfully' }))
+      .catch(error => res.status(400).send(error));
+  })
+  .catch(error => res.status(400).send(error));
+}
+ 
+/**
+ *
+ * Get documents for specific user
+ * @param {object} req - request object containing limit query and offset
+ * @param {array} res - array of documents for the requested user
+ * @return {array} - array of requested user's document
+ */
+function getUserDocuments(req, res) {
+  const limit = req.query.limit;
+  const offset = req.query.offset;
+  User.findById(req.params.id)
+    .then((user) => {
+      if (!user) {
+        return res.status(404).json({
+          message: 'User not found'
+        });
+      }
+      return Document.findAndCountAll({
+        limit,
+        offset,
+        where: {
+          userId: user.id
+        }
+      })
+        .then(({ rows: document, count }) => {
+          res.status(200).send({
+            document,
+            pagination: metaData(count, limit, offset),
+          });
+        })
+        .catch(error => res.status(400).send(error));
+    })
+    .catch(error => res.status(400).send(error));
+}
+ 
+export default {
+  getUsers,
+  createUser,
+  login,
+  findUser,
+  updateUser,
+  deleteUser,
+  getUserDocuments
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html new file mode 100644 index 0000000..48bb521 --- /dev/null +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -0,0 +1,89 @@ + + + + Code coverage report for document-manager/server/helpers/helper.js + + + + + + + +
+
+

+ All files / document-manager/server/helpers helper.js +

+
+
+ 100% + Statements + 3/3 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +96x +  +  +  +  +  +  +1x + 
const paginationMetaData = (count, limit, offset) => ({
+  totalCount: count,
+  pageCount: Math.ceil(count / limit),
+  page: Math.floor(offset / limit) + 1,
+  pageSize: limit
+});
+ 
+module.exports.paginationMetaData = paginationMetaData;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html new file mode 100644 index 0000000..1c02c5e --- /dev/null +++ b/coverage/document-manager/server/helpers/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for document-manager/server/helpers + + + + + + + +
+
+

+ All files document-manager/server/helpers +

+
+
+ 100% + Statements + 3/3 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 1/1 +
+
+ 100% + Lines + 2/2 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
helper.js
100%3/3100%0/0100%1/1100%2/2
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html new file mode 100644 index 0000000..da5ce39 --- /dev/null +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -0,0 +1,170 @@ + + + + Code coverage report for document-manager/server/middlewares/auth.js + + + + + + + +
+
+

+ All files / document-manager/server/middlewares auth.js +

+
+
+ 92.31% + Statements + 12/13 +
+
+ 87.5% + Branches + 7/8 +
+
+ 100% + Functions + 3/3 +
+
+ 92.31% + Lines + 12/13 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +361x +  +1x +  +  +  +60x +60x +56x +56x +  +  +56x +56x +  +  +  +4x +  +  +  +  +  +  +  +21x +15x +  +6x +  +  +  +  +  +  + 
import jwt from 'jsonwebtoken';
+ 
+const jwtSecret = process.env.JWT_SECRET;
+ 
+ 
+function verifyToken(req, res, next) {
+  const token = req.headers.authorization || req.headers['x-access-token'];
+  if (token) {
+    jwt.verify(token, jwtSecret, (err, decoded) => {
+      Iif (err) {
+        res.json({ success: false, message: 'Failed to authenticate token.' });
+      } else {
+        req.decoded = decoded;
+        next();
+      }
+    });
+  } else {
+    return res.status(403).send({
+      success: false,
+      message: 'No token provided.'
+    });
+  }
+}
+ 
+function adminAccess(req, res, next) {
+  if (req.decoded.roleId === 1) {
+    next();
+  } else {
+    return res.status(401).json({
+      message: 'You are not authorized',
+    });
+  }
+}
+ 
+export default { verifyToken, adminAccess };
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html new file mode 100644 index 0000000..5443129 --- /dev/null +++ b/coverage/document-manager/server/middlewares/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for document-manager/server/middlewares + + + + + + + +
+
+

+ All files document-manager/server/middlewares +

+
+
+ 92.31% + Statements + 12/13 +
+
+ 87.5% + Branches + 7/8 +
+
+ 100% + Functions + 3/3 +
+
+ 92.31% + Lines + 12/13 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
auth.js
92.31%12/1387.5%7/8100%3/392.31%12/13
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html new file mode 100644 index 0000000..340a973 --- /dev/null +++ b/coverage/document-manager/server/models/document.js.html @@ -0,0 +1,152 @@ + + + + Code coverage report for document-manager/server/models/document.js + + + + + + + +
+
+

+ All files / document-manager/server/models document.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30  +1x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +1x +  +  +  +1x +  + 
 
+module.exports = (sequelize, DataTypes) => {
+  const Document = sequelize.define('Document', {
+    title: {
+      type: DataTypes.STRING,
+      allowNull: false
+    },
+    content: {
+      type: DataTypes.TEXT,
+      allowNull: false
+    },
+    userId: {
+      type: DataTypes.INTEGER,
+      unique: true,
+      allowNull: false
+    },
+    access: {
+      type: DataTypes.ENUM,
+      values: ['public', 'private', 'role']
+    }
+  });
+  Document.associate = (models) => {
+    // associations can be defined here
+    Document.belongsTo(models.User, {
+      foreignKey: 'userId'
+    });
+  };
+  return Document;
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html new file mode 100644 index 0000000..28dc52a --- /dev/null +++ b/coverage/document-manager/server/models/index.html @@ -0,0 +1,132 @@ + + + + Code coverage report for document-manager/server/models + + + + + + + +
+
+

+ All files document-manager/server/models +

+
+
+ 97.5% + Statements + 39/40 +
+
+ 66.67% + Branches + 6/9 +
+
+ 100% + Functions + 9/9 +
+
+ 97.5% + Lines + 39/40 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
document.js
100%5/5100%0/0100%2/2100%5/5
index.js
95.83%23/2466.67%6/9100%3/395.83%23/24
role.js
100%5/5100%0/0100%2/2100%5/5
user.js
100%6/6100%0/0100%2/2100%6/6
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html new file mode 100644 index 0000000..6d63c9e --- /dev/null +++ b/coverage/document-manager/server/models/index.js.html @@ -0,0 +1,200 @@ + + + + Code coverage report for document-manager/server/models/index.js + + + + + + + +
+
+

+ All files / document-manager/server/models index.js +

+
+
+ 95.83% + Statements + 23/24 +
+
+ 66.67% + Branches + 6/9 +
+
+ 100% + Functions + 3/3 +
+
+ 95.83% + Lines + 23/24 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +461x +1x +1x +  +1x +1x +1x +  +1x +  +1x +1x +  +  +1x +  +  +  +  +1x +  +4x +  +  +  +  +3x +3x +  +  +1x +3x +3x +  +  +  +1x +1x +  +1x +  +1x +1x +  +1x + 
const fs = require('fs');
+const path = require('path');
+const Sequelize = require('sequelize');
+ 
+const basename = path.basename(module.filename);
+const env = process.env.NODE_ENV || 'development';
+const config = require('../config/config.js')[env];
+ 
+const db = {};
+ 
+let sequelize;
+Iif (config.use_env_variable) {
+  sequelize = new Sequelize(process.env[config.use_env_variable]);
+} else {
+  sequelize = new Sequelize(
+    config.database, config.username, config.password, config
+  );
+}
+ 
+fs
+  .readdirSync(__dirname)
+  .filter(file =>
+    (file.indexOf('.') !== 0) &&
+    (file !== basename) &&
+    (file.slice(-3) === '.js'))
+  .forEach((file) => {
+    const model = sequelize.import(path.join(__dirname, file));
+    db[model.name] = model;
+  });
+ 
+Object.keys(db).forEach((modelName) => {
+  Eif (db[modelName].associate) {
+    db[modelName].associate(db);
+  }
+});
+ 
+db.sequelize = sequelize;
+db.Sequelize = Sequelize;
+ 
+module.exports = db;
+ 
+db.sequelize = sequelize;
+db.Sequelize = Sequelize;
+ 
+module.exports = db;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html new file mode 100644 index 0000000..3452507 --- /dev/null +++ b/coverage/document-manager/server/models/role.js.html @@ -0,0 +1,116 @@ + + + + Code coverage report for document-manager/server/models/role.js + + + + + + + +
+
+

+ All files / document-manager/server/models role.js +

+
+
+ 100% + Statements + 5/5 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 5/5 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18  +1x +1x +  +  +  +  +  +  +1x +  +1x +  +  +  +1x +  + 
 
+module.exports = (sequelize, DataTypes) => {
+  const Role = sequelize.define('Role', {
+    title: {
+      type: DataTypes.STRING,
+      allowNull: false,
+      unique: true
+    }
+  });
+  Role.associate = (models) => {
+    // associations can be defined here
+    Role.hasMany(models.User, {
+      foreignKey: 'roleId'
+    });
+  };
+  return Role;
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html new file mode 100644 index 0000000..5993531 --- /dev/null +++ b/coverage/document-manager/server/models/user.js.html @@ -0,0 +1,185 @@ + + + + Code coverage report for document-manager/server/models/user.js + + + + + + + +
+
+

+ All files / document-manager/server/models user.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 2/2 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +411x +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +1x +  +  +  +  +1x +  +  +  +  +1x +  + 
module.exports = (sequelize, DataTypes) => {
+  const User = sequelize.define('User', {
+    fullName: {
+      type: DataTypes.STRING,
+      allowNull: false
+    },
+    userName: {
+      type: DataTypes.STRING,
+      allowNull: false,
+      unique: true
+    },
+    email: {
+      type: DataTypes.STRING,
+      allowNull: false,
+      unique: true
+    },
+    password: {
+      type: DataTypes.STRING,
+      allowNull: false
+    },
+    roleId: {
+      type: DataTypes.INTEGER,
+      allowNull: false,
+      defaultvalue: 2
+    }
+  });
+  User.associate = (models) => {
+    // associations can be defined here
+    User.hasMany(models.Document, {
+      foreignKey: 'userId',
+      onDelete: 'CASCADE',
+      hooks: true
+    });
+    User.belongsTo(models.Role, {
+      foreignKey: 'roleId',
+      onDelete: 'CASCADE'
+    });
+  };
+  return User;
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html new file mode 100644 index 0000000..9926d4d --- /dev/null +++ b/coverage/document-manager/server/routes/documents.js.html @@ -0,0 +1,137 @@ + + + + Code coverage report for document-manager/server/routes/documents.js + + + + + + + +
+
+

+ All files / document-manager/server/routes documents.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +251x +1x +1x +  +1x +  +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  + 
import express from 'express';
+import documentController from '../controllers/documents';
+import auth from '../middlewares/auth';
+ 
+const router = express.Router();
+ 
+router.route('/')
+  /** GET /api/v1/documents - Get all documents */
+  .get(auth.verifyToken, documentController.getAllDocument)
+ 
+  /** POST /api/v1/documents - Create document */
+  .post(auth.verifyToken, documentController.createDocument);
+ 
+router.route('/:id')
+  /** PUT /api/v1/documents/id - Create document */
+  .put(auth.verifyToken, documentController.updateDocument)
+ 
+  /** GET /api/v1/documents/id - find document */
+  .get(auth.verifyToken, documentController.findDocument)
+ 
+  /** GET /api/v1/documents/id - find document */
+  .delete(auth.verifyToken, documentController.deleteDocument);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html new file mode 100644 index 0000000..b2b92d0 --- /dev/null +++ b/coverage/document-manager/server/routes/index.html @@ -0,0 +1,145 @@ + + + + Code coverage report for document-manager/server/routes + + + + + + + +
+
+

+ All files document-manager/server/routes +

+
+
+ 100% + Statements + 36/36 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 36/36 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
documents.js
100%6/6100%0/0100%0/0100%6/6
index.js
100%10/10100%0/0100%0/0100%10/10
roles.js
100%6/6100%0/0100%0/0100%6/6
search.js
100%6/6100%0/0100%0/0100%6/6
users.js
100%8/8100%0/0100%0/0100%8/8
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html new file mode 100644 index 0000000..02905fb --- /dev/null +++ b/coverage/document-manager/server/routes/index.js.html @@ -0,0 +1,113 @@ + + + + Code coverage report for document-manager/server/routes/index.js + + + + + + + +
+
+

+ All files / document-manager/server/routes index.js +

+
+
+ 100% + Statements + 10/10 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 10/10 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +171x +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +1x +1x +  +  + 
import express from 'express';
+import userRoutes from './users';
+import searchRoutes from './search';
+import documentRoutes from './documents';
+import roleRoutes from './roles';
+ 
+ 
+const router = express.Router();
+ 
+/** GET /api-status - Check service status **/
+router.use('/users', userRoutes);
+router.use('/search', searchRoutes);
+router.use('/documents', documentRoutes);
+router.use('/roles', roleRoutes);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html new file mode 100644 index 0000000..6c9f27a --- /dev/null +++ b/coverage/document-manager/server/routes/roles.js.html @@ -0,0 +1,137 @@ + + + + Code coverage report for document-manager/server/routes/roles.js + + + + + + + +
+
+

+ All files / document-manager/server/routes roles.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +251x +1x +1x +  +1x +  +1x +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  + 
import express from 'express';
+import roleController from '../controllers/roles';
+import auth from '../middlewares/auth';
+ 
+const router = express.Router();
+ 
+router.route('/')
+  /** GET /api/roles - Get list of roles */
+  .get(auth.verifyToken, auth.adminAccess, roleController.getRoles)
+ 
+  /** POST /api/roles - Create roles */
+  .post(auth.verifyToken, auth.adminAccess, roleController.createRole);
+ 
+router.route('/:id')
+  /** GET /api/users/roles - Find roles */
+  .get(auth.verifyToken, auth.adminAccess, roleController.findRole)
+ 
+  /** PUT /api/users/id - update roles */
+  .put(auth.verifyToken, auth.adminAccess, roleController.updateRole)
+ 
+  /** DELETE /api/users/id - delete roles */
+  .delete(auth.verifyToken, auth.adminAccess, roleController.deleteRole);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html new file mode 100644 index 0000000..e6e99b5 --- /dev/null +++ b/coverage/document-manager/server/routes/search.js.html @@ -0,0 +1,110 @@ + + + + Code coverage report for document-manager/server/routes/search.js + + + + + + + +
+
+

+ All files / document-manager/server/routes search.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +161x +1x +1x +  +1x +  +1x +  +  +  +1x +  +  +  +  + 
import express from 'express';
+import searchController from '../controllers/search';
+import auth from '../middlewares/auth';
+ 
+const router = express.Router();
+ 
+router.route('/users')
+  /** GET /api/users - Get list of users */
+  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
+ 
+router.route('/documents')
+  /** GET /api/documents - Get list of users */
+  .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/searches.js.html b/coverage/document-manager/server/routes/searches.js.html new file mode 100644 index 0000000..1787a66 --- /dev/null +++ b/coverage/document-manager/server/routes/searches.js.html @@ -0,0 +1,110 @@ + + + + Code coverage report for document-manager/server/routes/searches.js + + + + + + + +
+
+

+ All files / document-manager/server/routes searches.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +161x +1x +1x +  +1x +  +1x +  +  +  +1x +  +  +  +  + 
import express from 'express';
+import searchController from '../controllers/searches';
+import auth from '../middlewares/auth';
+ 
+const router = express.Router();
+ 
+router.route('/users')
+  /** GET /api/users - Get list of users */
+  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
+ 
+router.route('/documents')
+  /** GET /api/documents - Get list of users */
+  .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html new file mode 100644 index 0000000..cddcc51 --- /dev/null +++ b/coverage/document-manager/server/routes/users.js.html @@ -0,0 +1,161 @@ + + + + Code coverage report for document-manager/server/routes/users.js + + + + + + + +
+
+

+ All files / document-manager/server/routes users.js +

+
+
+ 100% + Statements + 8/8 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 8/8 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +331x +1x +1x +  +1x +  +1x +  +  +  +  +  +  +1x +  +  +  +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  + 
import express from 'express';
+import userController from '../controllers/users';
+import auth from '../middlewares/auth';
+ 
+const router = express.Router();
+ 
+router.route('/')
+  /** GET /api/users - Get list of users */
+  .get(auth.verifyToken, auth.adminAccess, userController.getUsers)
+ 
+  /** POST /api/users - Create/Signup users */
+  .post(userController.createUser);
+ 
+router.route('/login')
+  /** POST /api/users/login - Login users */
+  .post(userController.login);
+ 
+router.route('/:id')
+  /** GET /api/users/id - Find users */
+  .get(auth.verifyToken, userController.findUser)
+ 
+  /** PUT /api/users/id - update users */
+  .put(auth.verifyToken, userController.updateUser)
+ 
+  /** DELETE /api/users/id - delete users */
+  .delete(auth.verifyToken, userController.deleteUser);
+ 
+router.route('/:id/documents')
+  /** GET /api/users/id/documents - get user document */
+  .get(auth.verifyToken, userController.getUserDocuments);
+ 
+export default router;
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/document.spec.js.html b/coverage/document-manager/server/test/document.spec.js.html new file mode 100644 index 0000000..1204526 --- /dev/null +++ b/coverage/document-manager/server/test/document.spec.js.html @@ -0,0 +1,1151 @@ + + + + Code coverage report for document-manager/server/test/document.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test document.spec.js +

+
+
+ 96.81% + Statements + 182/188 +
+
+ 100% + Branches + 0/0 +
+
+ 98.25% + Functions + 56/57 +
+
+ 96.77% + Lines + 180/186 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +3631x +1x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +  +1x +  +  +  +  +1x +1x +1x +1x +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +1x +  +  +  +1x +  +  +  +1x +  +1x +  +  +  +  +  +1x +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +1x +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../index';
+import models from '../models';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Documents', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+ 
+  describe('/POST Document', () => {
+    it('should add a new document if the user is authenticated', (done) => {
+      const document = {
+        title: 'boromir-team',
+        content: 'Andela is really awesome!!!',
+        access: 'public',
+        userId: 2,
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .send(document)
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(201);
+        expect(res.body).to.be.a('object');
+        expect(res.body).to.have.property('id');
+        expect(res.body.title).to.eql('boromir-team');
+        expect(res.body.content).to.eql('Andela is really awesome!!!');
+        expect(res.body.access).to.equal('public');
+        done();
+      });
+    });
+ 
+    it('Should fail if document already exist', () => {
+      const document = {
+        title: 'John team',
+        content: 'eze goes to school',
+        access: 'public',
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body.message).to.eql('Document already exists');
+      });
+    });
+    it('should fail to add a new document if the user is not authenticated',
+    (done) => {
+      const document = {
+        title: 'boromir-team',
+        content: 'Andela is really awesome !!!',
+        value: 'private',
+        userId: 2,
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .send(document)
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('No token provided.');
+        done();
+      });
+    });
+  });
+ 
+  describe('/GET Documents', () => {
+    it('Should get all documents for the user that is authenticated',
+    (done) => {
+      request(server)
+      .get('/api/v1/documents')
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body).to.be.a('object');
+        expect(res.body).to.have.keys(['document', 'pagination']);
+        done();
+      });
+    });
+    it('should fail to get all documents if the user is not authenticated',
+    (done) => {
+      request(server)
+      .get('/api/v1/documents/')
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).be.eql('No token provided.');
+        expect(res.body.success).to.eql(false);
+        done();
+      });
+    });
+    it('Should get all documents with correct limit as a query', (done) => {
+      const limit = 1;
+      request(server)
+        .get(`/api/v1/documents?limit=${limit}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          done();
+        });
+    });
+    it('Should get all documents with correct offset as a query', (done) => {
+      const offset = 0;
+      request(server)
+        .get(`/api/v1/documents?limit=${offset}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET/:id Document', () => {
+    it('Should fail to get document if it doesn`t exist', (done) => {
+      const documentId = 8;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document not found');
+          done();
+        });
+    });
+    it('Should get all public regardless of id', (done) => {
+      const documentId = 4;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(4);
+          expect(res.body.title).to.equal('boromir-team');
+          expect(res.body.access).to.equal('public');
+          done();
+        });
+    });
+    it('Should fail to get a private document if the requester does not own it',
+    (done) => {
+      const documentId = 2;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to view this document');
+          done();
+        });
+    });
+    it('Should get a private document the where the requester is the owner',
+    (done) => {
+      const documentId = 2;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.access).to.eql('private');
+          expect(res.body.title).to.eql('John naddddd');
+          expect(res.body.id).to.eql(2);
+          expect(res.body.userId).to.eql(2);
+          done();
+        });
+    });
+    it('Should fail get a role document if the users are not on the same role',
+    (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to view this document');
+          done();
+        });
+    });
+    it('Should get a role document if the users are on the same role',
+    (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(3);
+          expect(res.body.title).to.eql('James Hannn');
+          expect(res.body.access).to.eql('role');
+          done();
+        });
+    });
+    it('Should get a role document if the user is an admin', (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(3);
+          expect(res.body.title).to.eql('James Hannn');
+          expect(res.body.access).to.eql('role');
+        });
+      done();
+    });
+  });
+ 
+  describe('/PUT/:id, Document', () => {
+    it('Should update a document by id if the user has the same id',
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: userToken })
+          .send({ title: 'wreck it ralph' })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.id).to.eql(2);
+            expect(res.body.title).to.eql('wreck it ralph');
+            done();
+          });
+      });
+    it(`Should fail to update a document by
+      id if the user does not have the same id`,
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: sampleUserToken })
+          .send({ title: 'spiderman Homecoming' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to edit this document');
+            done();
+          });
+      });
+    it('Should not update a document by id if the user has admin access',
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: adminToken })
+          .send({ title: 'wreck it' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            done();
+          });
+      });
+    it('Should fail to update a document by id if the document does not exist',
+      (done) => {
+        const id = 10;
+        request(server)
+        .put(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .send({ title: 'Deadpool' })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document Not Found');
+          done();
+        });
+      });
+  });
+ 
+  describe('DELETE/:id Document', () => {
+    it('Should delete a document if the user has admin access', (done) => {
+      const id = 3;
+      request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          done();
+        });
+    });
+    it('Should delete a document if the user is the owner', (done) => {
+      const id = 2;
+      request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          done();
+        });
+    });
+    it('Should fail to delete the document given the user is not the owner',
+    (done) => {
+      const id = 1;
+      chai.request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to delete this document');
+          done();
+        });
+    });
+    it('Should fail to delete if the document does not exist', (done) => {
+      const id = 234;
+      chai.request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document not found');
+          done();
+        });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/index.html b/coverage/document-manager/server/test/index.html new file mode 100644 index 0000000..3b356d5 --- /dev/null +++ b/coverage/document-manager/server/test/index.html @@ -0,0 +1,145 @@ + + + + Code coverage report for document-manager/server/test + + + + + + + +
+
+

+ All files document-manager/server/test +

+
+
+ 92.03% + Statements + 577/627 +
+
+ 100% + Branches + 0/0 +
+
+ 93.26% + Functions + 180/193 +
+
+ 91.92% + Lines + 569/619 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
document.spec.js
96.81%182/188100%0/098.25%56/5796.77%180/186
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
90.8%148/163100%0/096.08%49/5190.68%146/161
search.spec.js
55.93%33/59100%0/050%10/2054.39%31/57
user.spec.js
98.6%212/215100%0/0100%65/6598.59%210/213
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/index.spec.js.html b/coverage/document-manager/server/test/index.spec.js.html new file mode 100644 index 0000000..ca3eb5d --- /dev/null +++ b/coverage/document-manager/server/test/index.spec.js.html @@ -0,0 +1,89 @@ + + + + Code coverage report for document-manager/server/test/index.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test index.spec.js +

+
+
+ 100% + Statements + 6/6 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 6/6 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +91x +1x +1x +1x +  +1x +  +1x + 
process.env.NODE_ENV = 'test';
+const chai = require('chai');
+const chaiHttp = require('chai-http');
+const server = require('../../index');
+ 
+let expect = chai.expect();
+ 
+chai.use(chaiHttp);
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/middlewares/auth.spec.js.html b/coverage/document-manager/server/test/middlewares/auth.spec.js.html new file mode 100644 index 0000000..7fe8f43 --- /dev/null +++ b/coverage/document-manager/server/test/middlewares/auth.spec.js.html @@ -0,0 +1,383 @@ + + + + Code coverage report for document-manager/server/test/middlewares/auth.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test/middlewares auth.spec.js +

+
+
+ 79.69% + Statements + 51/64 +
+
+ 100% + Branches + 0/0 +
+
+ 60% + Functions + 12/20 +
+
+ 79.37% + Lines + 50/63 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +1071x +1x +1x +1x +1x +1x +1x +1x +1x +1x +  +1x +1x +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +  +  +  +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +  +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +  +  +  +  + 
process.NODE_ENV = 'test';
+const chai = require('chai');
+require('dotenv').config();
+const chaiHttp = require('chai-http');
+const expect = chai.expect;
+const EventEmitter = require('events').EventEmitter;
+const httpMocks = require('node-mocks-http');
+const samples = require('../mockData');
+const server = require('../../../index');
+const auth = require('../../middlewares/auth');
+ 
+chai.use(chaiHttp);
+let adminToken, userToken;
+describe('Authentication', () => {
+  before((done) => {
+    chai.request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'johnbosco.ohia@andela.com', password: process.env.PASSWORD })
+      .end((err, res) => {
+        adminToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    chai.request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'testdoe@andela.com', password: 'jamestest' })
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('VerifyToken', () => {
+    it('Should check if the token is provided with request', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents',
+      });
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.verifyToken(request, response, nextCallBack);
+      expect(response._getData().message).to.equal('No token provided.');
+      done();
+    });
+  it('Should provide access if the token is provided and valid', (done) => {
+    const request = httpMocks.createRequest({
+      method: 'GET',
+      url: '/api/v1/documents',
+      headers: { 'x-access-token': adminToken }
+    });
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyToken(request, response, nextCallBack);
+    expect(response._getData().message).to.equal(undefined);
+    done();
+  });
+  it('Should deny access if the token is invalid', (done) => {
+    const request = httpMocks.createRequest({
+      method: 'GET',
+      url: '/api/v1/documents/',
+      headers: { 'x-access-token': 'themaniscoming' }
+    });
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyToken(request, response, nextCallBack);
+ 
+    response.on('end', () => {
+      expect(response._getData().success).to.equal(false);
+    });
+    done();
+  });
+  });
+  describe('AdminAcess', () => {
+    it('Should deny access if the user is not admin', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents/',
+        headers: { 'x-access-token': userToken }
+      });
+      request.decoded = { roleId: 2 };
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.adminAccess(request, response, nextCallBack);
+      response.on('end', () => {
+        expect(response._getData().message).to.equal('You are not authorized');
+      });
+      done();
+    });
+    it('Should grant access if the user is an admin', (done) => {
+      const request = httpMocks.createRequest({
+        method: 'GET',
+        url: '/api/v1/documents/',
+        headers: { 'x-access-token': adminToken }
+      });
+      request.decoded = { roleId: 1 };
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.adminAccess(request, response, nextCallBack);
+      response.on('end', () => {
+        expect(response._getData().message).to.equal(undefined);
+      });
+      done();
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/middlewares/index.html b/coverage/document-manager/server/test/middlewares/index.html new file mode 100644 index 0000000..82e75be --- /dev/null +++ b/coverage/document-manager/server/test/middlewares/index.html @@ -0,0 +1,93 @@ + + + + Code coverage report for document-manager/server/test/middlewares + + + + + + + +
+
+

+ All files document-manager/server/test/middlewares +

+
+
+ 79.69% + Statements + 51/64 +
+
+ 100% + Branches + 0/0 +
+
+ 60% + Functions + 12/20 +
+
+ 79.37% + Lines + 50/63 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
auth.spec.js
79.69%51/64100%0/060%12/2079.37%50/63
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/mockData.js.html b/coverage/document-manager/server/test/mockData.js.html new file mode 100644 index 0000000..33ecd39 --- /dev/null +++ b/coverage/document-manager/server/test/mockData.js.html @@ -0,0 +1,197 @@ + + + + Code coverage report for document-manager/server/test/mockData.js + + + + + + + +
+
+

+ All files / document-manager/server/test mockData.js +

+
+
+ 100% + Statements + 2/2 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +451x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import dotenv from 'dotenv';
+ 
+dotenv.config();
+ 
+export default {
+  admin: {
+    email: 'baas@test.com',
+    password: process.env.TEST_ADMIN_PASSWORD
+  },
+  fellow: {
+    email: 'john@test.com',
+    password: process.env.TEST_FELLOW_PASSWORD
+  },
+  faciliatator: {
+    email: 'blessing@test.com',
+    password: process.env.TEST_FACILITATOR_PASSWORD
+  },
+  user2: {
+    email: 'baas@test.com',
+    password: 'test'
+  },
+  user1: {
+    email: 'test@test123.com',
+    password: 'test'
+  },
+  fakeBass: {
+    fullName: 'Baasbank Adams',
+    userName: 'tiaandela',
+    email: 'name@example.com',
+    password: 'pass123',
+    roleId: 1,
+    createdAt: new Date(),
+    updatedAt: new Date()
+  },
+  fakeUserDetails: {
+    fullName: 'Daniel Cfh',
+    userName: 'cfh',
+    email: 'cfh@example.com',
+    password: 'pass123',
+    roleId: 2,
+    createdAt: 'date',
+    updatedAt: new Date()
+  },
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/role.js.html b/coverage/document-manager/server/test/role.js.html new file mode 100644 index 0000000..a81a819 --- /dev/null +++ b/coverage/document-manager/server/test/role.js.html @@ -0,0 +1,950 @@ + + + + Code coverage report for document-manager/server/test/role.js + + + + + + + +
+
+

+ All files / document-manager/server/test role.js +

+
+
+ 92.02% + Statements + 150/163 +
+
+ 100% + Branches + 0/0 +
+
+ 96.08% + Functions + 49/51 +
+
+ 91.93% + Lines + 148/161 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +2961x +1x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +1x +  +1x +1x +  +  +  +  +1x +  +  +  +  +1x +  +1x +1x +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +  +  +1x +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../index';
+import models from '../models';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Roles', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+ 
+  describe('/POST Role', () => {
+  it('should add a new role if the user is an admin', (done) => {
+    request(server)
+    .post('/api/v1/roles')
+    .send({ title: 'boromir' })
+    .set({ authorization: adminToken })
+    .end((err, res) => {
+      expect(res.status).to.equal(201);
+      expect(res.body).to.be.a('object');
+      expect(res.body).to.have.property('message').to.equal('Role successfully created');
+      expect(res.body).to.have.property('role');
+      expect(res.body.role).to.have.property('title').to.equal('kiba');
+    });
+    done();
+  });
+  it('should add a new role if the user is an admin', (done) => {
+    request(server)
+    .post('/api/v1/roles')
+    .send({ title: 'king' })
+    .set({ authorization: adminToken })
+    .end((err, res) => {
+      expect(res.status).to.equal(204);
+      expect(res.body).to.be.a('object');
+      expect(res.body).to.have.property('message').to.equal('Role successfully created');
+      expect(res.body).to.have.property('role');
+    });
+    done();
+  });
+  it('Should fail if a non-admin wants to add a new role', (done) => {
+    const role = {
+      title: 'boromir-team'
+    };
+    request(server)
+      .post('/api/v1/roles/')
+      .set({ authorization: userToken })
+    .send(role)
+    .end((err, res) => {
+      expect(res.status).to.equal(401);
+      expect(res.body).to.be.a('object');
+      expect(res.body).to.have.property('message').to.equal('You are not authorized');
+      done();
+    });
+  });
+  it('Should return an error if the title is not a string', (done) => {
+    chai.request(server)
+      .post('/api/v1/roles')
+      .set({ authorization: adminToken })
+      .send({ title: 358583 })
+      .end((err, res) => {
+        expect(res.status).to.equal(400);
+        expect(res.body).to.be.a('object');
+        expect(res.body).to.have.property('message').to.equal('Invalid input credentials');
+        done();
+      });
+  });
+});
+ 
+describe('/GET Role', () => {
+  it('Should get all the roles if the user is an admin', (done) => {
+    chai.request(server)
+      .get('/api/v1/roles')
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body).to.have.length(5);
+        expect(res.body).to.be.a('array');
+        expect(res.body[0]).to.have.property('id').to.equal(1);
+        expect(res.body[0]).to.have.property('title').to.equal('admin')
+        expect(res.body[1]).to.have.property('id').to.equal(2);
+        expect(res.body[1]).to.have.property('title').to.equal('facilitator');
+        done();
+      });
+  });
+  it('Should fail to get the roles if the user is not admin', (done) => {
+    chai.request(server)
+      .get('/api/v1/roles')
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(401);
+        expect(res.body).to.be.have.property('message').to.equal('You are not authorized');
+        done();
+      });
+  });
+});
+ 
+describe('/GET/:id Role', () => {
+  it('Should get a role by id if the user is an admin', (done) => {
+    const id = 2;
+    chai.request(server)
+      .get(`/api/v1/roles/${id}`)
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body).be.a('object');
+        expect(res.body).to.have.property('title').to.equal('facilitator');
+        expect(res.body).to.have.property('id').to.equal(2);
+        done();
+      });
+  });
+  it('Should fail to get a role by id if the user is not an admin', (done) => {
+    const id = 2;
+    chai.request(server)
+      .get(`/api/v1/roles/${id}`)
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(401);
+        expect(res.body).to.have.property('message').to.equal('You are not authorized');
+        done();
+      });
+  });
+  it('Should fail to get a role by id if the user enters an invalid input', (done) => {
+    const id = 'fddjsdcdjn';
+    chai.request(server)
+      .get(`/api/v1/roles/${id}`)
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(400);
+        expect(res.body).to.have.property('message').to.equal(`invalid input syntax for integer: "${id}"`);
+        done();
+      });
+  });
+  it('Should fail to get a role by id if the role does not exist', (done) => {
+    const id = 250;
+    chai.request(server)
+      .get(`/api/v1/roles/${id}`)
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(404);
+        expect(res.body).to.have.property('message').to.equal('Role not found');
+        done();
+      });
+  });
+  it('Should fail to get a role by id if the id is out of range', (done) => {
+    const id = 500000000000000000000;
+    chai.request(server)
+      .get(`/api/v1/roles/${id}`)
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(400);
+        expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
+        done();
+      });
+  });
+});
+  describe('/PUT/:id Role', () => {
+    it('Should update a role by id if the user has admin access', (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal('Role updated successfully');
+          expect(res.body).to.have.property('role');
+          done();
+        });
+    });
+    it('Should fail to update a role by id if the user has no admin access', (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: userToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to update a role by id if the admin enters an invalid input'
+      , (done) => {
+        const id = 200;
+        chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal('Role not found');
+          done();
+        });
+      });
+    it('Should fail to update a role by id if the admin enters an id that is out range', (done) => {
+      const id = 2000000000000000;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'regular' })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+  describe('/DELETE/:id Role', () => {
+    it('Should delete a role given the user has admin access', (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          expect(res.body).to.be.a('object');
+        });
+       done();
+    });
+    it('Should fail to delete a role given the user has no admin access', (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to delete a role given the admin enters an invalid input', (done) => {
+      const id = 300;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal('Role not found');
+          done();
+        });
+    });
+    it('Should fail to delete a role given the admin enters an input that is out of range', (done) => {
+      const id = 3000000000000000;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/role.spec.js.html b/coverage/document-manager/server/test/role.spec.js.html new file mode 100644 index 0000000..15bb0c0 --- /dev/null +++ b/coverage/document-manager/server/test/role.spec.js.html @@ -0,0 +1,992 @@ + + + + Code coverage report for document-manager/server/test/role.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test role.spec.js +

+
+
+ 90.8% + Statements + 148/163 +
+
+ 100% + Branches + 0/0 +
+
+ 96.08% + Functions + 49/51 +
+
+ 90.68% + Lines + 146/161 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +3101x +1x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +1x +  +1x +1x +  +  +  +  +1x +  +  +  +  +1x +  +1x +1x +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +1x +  +  +  +  +1x +  +  +  +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +  +  +1x +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../index';
+import models from '../models';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Roles', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+ 
+  describe('/POST Role', () => {
+    it('should add a new role if the user is an admin', (done) => {
+      request(server)
+      .post('/api/v1/roles')
+      .send({ title: 'boromir' })
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(201);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('Role successfully created');
+        expect(res.body).to.have.property('role');
+        expect(res.body.role).to.have.property('title').to.equal('boromir');
+      });
+      done();
+    });
+    it('should add a new role if the user is an admin', (done) => {
+      request(server)
+      .post('/api/v1/roles')
+      .send({ title: 'king' })
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(204);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('Role successfully created');
+        expect(res.body).to.have.property('role');
+      });
+      done();
+    });
+    it('Should fail if a non-admin wants to add a new role', (done) => {
+      const role = {
+        title: 'boromir-team'
+      };
+      request(server)
+        .post('/api/v1/roles/')
+        .set({ authorization: userToken })
+      .send(role)
+      .end((err, res) => {
+        expect(res.status).to.equal(401);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('You are not authorized');
+        done();
+      });
+    });
+    it('Should return an error if the title is not a string', (done) => {
+      chai.request(server)
+        .post('/api/v1/roles')
+        .set({ authorization: adminToken })
+        .send({ title: 358583 })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Invalid input credentials');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET Role', () => {
+    it('Should get all the roles if the user is an admin', (done) => {
+      chai.request(server)
+        .get('/api/v1/roles')
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.have.length(5);
+          expect(res.body).to.be.a('array');
+          expect(res.body[0].id).to.eql(1);
+          expect(res.body[0].title).to.eql('admin');
+          expect(res.body[1].id).to.eql(2);
+          expect(res.body[1].title).to.eql('facilitator');
+          done();
+        });
+    });
+    it('Should fail to get the roles if the user is not admin', (done) => {
+      chai.request(server)
+        .get('/api/v1/roles')
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message)
+          .to.eql('You are not authorized');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET/:id Role', () => {
+    it('Should get a role by id if the user is an admin', (done) => {
+      const id = 2;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).be.a('object');
+          expect(res.body.title).to.eql('facilitator');
+          expect(res.body.id).to.equal(2);
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the user is not an admin',
+    (done) => {
+      const id = 2;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the user enters an invalid input',
+    (done) => {
+      const id = 'fddjsdcdjn';
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message)
+          .to.eql(`invalid input syntax for integer: "${id}"`);
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the role does not exist', (done) => {
+      const id = 250;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body.message).to.eql('Role not found');
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the id is out of range', (done) => {
+      const id = 500000000000000000000;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body.message)
+          .to.eql(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+  describe('/PUT/:id Role', () => {
+    it('Should update a role by id if the user has admin access', (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'boromir-team' })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Role updated successfully');
+          expect(res.body).to.have.property('role');
+          done();
+        });
+    });
+    it('Should fail to update a role by id if the user has no admin access',
+    (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: userToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it(`Should fail to update a
+       role by id if the admin enters an invalid input`,
+      (done) => {
+        const id = 200;
+        chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.equal('Role not found');
+          done();
+        });
+      });
+    it(`Should fail to update a role by
+      id if the admin enters an id that is out range`,
+      (done) => {
+        const id = 2000000000000000;
+        chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+          .set({ authorization: adminToken })
+          .send({ title: 'regular' })
+          .end((err, res) => {
+            expect(res.status).to.equal(400);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql(`value "${id}" is out of range for type integer`);
+            done();
+          });
+      });
+  });
+  describe('/DELETE/:id Role', () => {
+    it('Should delete a role given the user has admin access', (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          expect(res.body).to.be.a('object');
+        });
+      done();
+    });
+    it('Should fail to delete a role given the user has no admin access',
+    (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to delete a role given the admin enters an invalid input',
+    (done) => {
+      const id = 300;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.equal('Role not found');
+          done();
+        });
+    });
+    it(`Should fail to delete a role given
+      the admin enters an input that is out of range`, (done) => {
+      const id = 3000000000000000;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/search.spec.js.html b/coverage/document-manager/server/test/search.spec.js.html new file mode 100644 index 0000000..8ca2533 --- /dev/null +++ b/coverage/document-manager/server/test/search.spec.js.html @@ -0,0 +1,386 @@ + + + + Code coverage report for document-manager/server/test/search.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test search.spec.js +

+
+
+ 55.93% + Statements + 33/59 +
+
+ 100% + Branches + 0/0 +
+
+ 50% + Functions + 10/20 +
+
+ 54.39% + Lines + 31/57 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +1081x +1x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +  +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../index';
+import models from '../models';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToke;
+const { admin, fellow } = data;
+ 
+describe('Users', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+ 
+ 
+  describe('/SEARCH/users/?q={name}', () => {
+    it('Should return an error if no querystring is provided', () => {
+      const query = '';
+      request(server)
+        .get(`/api/v1/search/users/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body.message).to.eql('Inval search input');
+        });
+    });
+    it('Should return a search list response of the required search input',
+    () => {
+      const query = 'jame';
+      request(server)
+      .get(`/api/v1/search/users/?q=${query}`)
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body.fullName).to.eql('jame doe');
+        expect(res.body.userName).to.eql('testdoe');
+      });
+    });
+  });
+  describe('/SEARCH/documents/?q=', () => {
+    it('Should return an error if no querystring is provided', () => {
+      const query = '';
+      request(server)
+        .get(`/api/v1/search/document/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.have.property('message').to.equal('Invalid search input')
+        });
+      });
+     it('Should return a search list of the required search input', () => {
+       const query = 'John';
+       request(server)
+        .get(`/api/v1/search/documents/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.have.property('document');
+          expect(res.body.document[0]).to.have.property('title').to.equal('John Doe');
+          expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school');
+          expect(res.body).to.have.property('pagination');
+          expect(res.body.paginaton).to.have.property('totalCount').to.equal(1);
+        });
+     });
+     it('Should throw an error if the searched document is not found', () => {
+       const query = 'jk';
+       request(server)
+        .get(`/api/v1/search/documents/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.have.property('message').to.equal('Document not found');
+        });
+     });
+   });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/user.spec.js.html b/coverage/document-manager/server/test/user.spec.js.html new file mode 100644 index 0000000..139c062 --- /dev/null +++ b/coverage/document-manager/server/test/user.spec.js.html @@ -0,0 +1,1247 @@ + + + + Code coverage report for document-manager/server/test/user.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test user.spec.js +

+
+
+ 98.6% + Statements + 212/215 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 65/65 +
+
+ 98.59% + Lines + 210/213 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +3951x +1x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +1x +1x +  +1x +  +  +  +1x +1x +1x +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +1x +1x +  +  +  +1x +1x +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +  +1x +1x +  +1x +1x +  +1x +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +  +  +  +1x +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +  +  +  +  +1x +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +1x +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../index';
+import models from '../models';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fakeBass, fellow, user1, user2 } = data;
+ 
+describe('Users', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+ 
+  describe('/POST User login', () => {
+    it('Should fail if the user enters incorrect crendentials upon login',
+    (done) => {
+      request(server)
+        .post('/api/v1/users/login')
+        .send(user1)
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.have.keys(['message', 'success']);
+          expect(res.body.message)
+          .to.eql('Authentication failed. User not found.');
+          expect(res.body.success).to.eql(false);
+          done();
+        });
+    });
+ 
+    it('Should fail if the user provide a wrong password', (done) => {
+      request(server)
+        .post('/api/v1/users/login')
+        .send(user2)
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.have.keys(['message', 'success']);
+          expect(res.body.message)
+          .to.eql('Authentication failed. Wrong password.');
+          expect(res.body.success).to.eql(false);
+          done();
+        });
+    });
+ 
+    it('should log in a user and return a token', (done) => {
+      request(server)
+        .post('/api/v1/users/login').send(admin).end((err, res) => {
+          expect(res.status).to.equal(201);
+          expect(res.body).to.have.keys(['success', 'token']);
+          expect(res.body.success).to.eql(true);
+          done();
+        });
+    });
+ 
+    describe('/POST User Signup', () => {
+      it('should create a new user', (done) => {
+        request(server)
+          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body)
+              .to.have.keys(['message', 'success', 'userDetails']);
+            expect(res.body.success).to.eql(true);
+            expect(res.body.message)
+            .to.eql('You have successfully registered.');
+            done();
+          });
+      });
+    });
+ 
+    describe('#GET Users', () => {
+      it('Should get all users if the user is an admin ', (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body).to.have.keys(['user', 'pagination']);
+            done();
+          });
+      });
+      it('Should fail to get all users if the user has no admin access ',
+      (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('You are not authorized');
+            done();
+          });
+      });
+      it('Should fail to get all users if no token was provided', (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .end((err, res) => {
+            expect(res.status).to.equal(403);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('No token provided.');
+            done();
+          });
+      });
+      it('Should get all users with correct limit as a query', (done) => {
+        const limit = 1;
+        chai.request(server)
+          .get(`/api/v1/users?limit=${limit}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.user[0].fullName).to.equal('Baas Bank');
+            expect(res.body.user[0].userName).to.equal('bank');
+            done();
+          });
+      });
+    });
+    describe('#GET User by Id', () => {
+      it('Should get a user if the user is an admin', (done) => {
+        const id = 2;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('array');
+            expect(res.body[0].fullName).to.eql('John Bosco');
+            expect(res.body[0].id).to.eql(2);
+            expect(res.body[0].userName).to.eql('john');
+            expect(res.body[0].email).to.eql('john@test.com');
+            expect(res.body[0].roleId).to.eql(2);
+            done();
+          });
+      });
+      it('Should get the user if the requested user is the current user',
+      (done) => {
+        const id = 2;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('array');
+            expect(res.body[0].fullName).to.eql('John Bosco');
+            expect(res.body[0].id).eql(2);
+            expect(res.body[0].userName).to.eql('john');
+            expect(res.body[0].email).to.eql('john@test.com');
+            expect(res.body[0].roleId).to.eql(2);
+            done();
+          });
+      });
+      it('Should fail to get a user if an invalid input is entered',
+      (done) => {
+        const id = 'fddjsdcdjn';
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.have.property('message')
+            .to.eql(`invalid input syntax for integer: "${id}"`);
+            done();
+          });
+      });
+      it('should fail to get the user if the requester is not the owner',
+      (done) => {
+        const id = 2;
+        request(server)
+          .get(`api/users/${id}`)
+          .set({ authorization: sampleUserToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.have.keys(['message']);
+            expect(res.body.message).to.eql('Unauthorized access');
+          });
+        done();
+      });
+      it('Should fail to get a user if the user does not exist',
+      (done) => {
+        const id = 250;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).to.have.property('message');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+      it('Should fail to get a user if the id is out of range',
+      (done) => {
+        const id = 500000000000000000;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(400);
+            expect(res.body).to.have.property('message')
+            .to.equal(`value "${id}" is out of range for type integer`);
+            done();
+          });
+      });
+    });
+    describe('#PUT Update user by Id', () => {
+      it('Should update a user`s full name if the user has the same id',
+        (done) => {
+          const id = 2;
+          request(server)
+            .put(`/api/v1/users/${id}`)
+            .set({ authorization: userToken })
+            .send({ fullName: 'jake doe' })
+            .end((err, res) => {
+              expect(res.status).to.equal(200);
+              expect(res.body).to.be.a('object');
+              expect(res.body.id).to.eql(2);
+              expect(res.body.fullName).to.eql('jake doe');
+              done();
+            });
+        });
+      it('Should update a user`s email if the user has the same id', (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.id).to.eql(2);
+            expect(res.body.email).to.eql('jakedoe@andela.com');
+            done();
+          });
+      });
+      it('Should update a user`s username if the user has the same id',
+        (done) => {
+          const id = 2;
+          request(server)
+            .put(`/api/v1/users/${id}`)
+            .set({ authorization: userToken })
+            .send({ userName: 'jakedoe12' })
+            .end((err, res) => {
+              expect(res.status).to.equal(200);
+              expect(res.body).to.be.a('object');
+              expect(res.body.id).to.eql(2);
+              expect(res.body.userName).to.eql('jakedoe12');
+              done();
+            });
+        });
+      it(`Should fail to update a user's
+      details if the user does not have the same user id`,
+      (done) => {
+        const id = 3;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this user');
+            done();
+          });
+      });
+      it(`Should fail to update a user's
+        details if the user enters an invalid user id`,
+      (done) => {
+        const id = 2302;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this user');
+            done();
+          });
+      });
+    });
+    describe('#DELETE /:id Users', () => {
+      it('Should delete a user given the user has admin access', (done) => {
+        const id = 3;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(204);
+            done();
+          });
+      });
+      it('Should fail to delete a user if the user has no admin access',
+      (done) => {
+        const id = 3;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this field');
+            done();
+          });
+      });
+      it('Should give a User not found if user don\'t exist', (done) => {
+        const id = 23;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+    });
+    describe('/GET/users/:id/documents Documents', () => {
+      it('Should fail to get documents if the user does not exist', (done) => {
+        const userId = 9;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).be.a('object');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+      it('Should fail to get documents if there is no token present',
+      (done) => {
+        const userId = 2;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .end((err, res) => {
+            expect(res.status).to.equal(403);
+            expect(res.body).be.a('object');
+            expect(res.body.message).to.eql('No token provided.');
+            expect(res.body.success).to.eql(false);
+            done();
+          });
+      });
+      it('Should get documents for the user with its unique userId', (done) => {
+        const userId = 2;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('object');
+            expect(res.body.document[1].userId).to.eql(2);
+            expect(res.body.document[1].title).to.eql('boromir-team');
+            expect(res.body.document[1].content)
+            .to.eql('Andela is really awesome!!!');
+            done();
+          });
+      });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/index.html b/coverage/index.html new file mode 100644 index 0000000..22b9602 --- /dev/null +++ b/coverage/index.html @@ -0,0 +1,184 @@ + + + + Code coverage report for All files + + + + + + + +
+
+

+ All files +

+
+
+ 88.21% + Statements + 860/975 +
+
+ 73.72% + Branches + 101/137 +
+
+ 85.32% + Functions + 250/293 +
+
+ 88.08% + Lines + 850/965 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
document-manager
100%4/4100%2/2100%1/1100%4/4
document-manager/server/config
100%21/21100%2/2100%2/2100%20/20
document-manager/server/controllers
72.73%168/23172.41%84/11664.29%54/8472.73%168/231
document-manager/server/helpers
100%3/3100%0/0100%1/1100%2/2
document-manager/server/middlewares
92.31%12/1387.5%7/8100%3/392.31%12/13
document-manager/server/models
97.5%39/4066.67%6/9100%9/997.5%39/40
document-manager/server/routes
100%36/36100%0/0100%0/0100%36/36
document-manager/server/test
92.03%577/627100%0/093.26%180/19391.92%569/619
+
+
+ + + + + + + diff --git a/coverage/mockData.js.html b/coverage/mockData.js.html new file mode 100644 index 0000000..5965671 --- /dev/null +++ b/coverage/mockData.js.html @@ -0,0 +1,197 @@ + + + + Code coverage report for mockData.js + + + + + + + +
+
+

+ All files mockData.js +

+
+
+ 100% + Statements + 2/2 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +451x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import dotenv from 'dotenv';
+ 
+dotenv.config();
+ 
+export default {
+  admin: {
+    email: 'baas@test.com',
+    password: process.env.TEST_ADMIN_PASSWORD
+  },
+  fellow: {
+    email: 'john@test.com',
+    password: process.env.TEST_FELLOW_PASSWORD
+  },
+  faciliatator: {
+    email: 'blessing@test.com',
+    password: process.env.TEST_FACILITATOR_PASSWORD
+  },
+  user2: {
+    email: 'baas@test.com',
+    password: 'test'
+  },
+  user1: {
+    email: 'test@test123.com',
+    password: 'test'
+  },
+  fakeBass: {
+    fullName: 'Baasbank Adams',
+    userName: 'tiaandela',
+    email: 'name@example.com',
+    password: 'pass123',
+    roleId: 1,
+    createdAt: new Date(),
+    updatedAt: new Date()
+  },
+  fakeUserDetails: {
+    fullName: 'Daniel Cfh',
+    userName: 'cfh',
+    email: 'cfh@example.com',
+    password: 'pass123',
+    roleId: 2,
+    createdAt: 'date',
+    updatedAt: new Date()
+  },
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/prettify.css b/coverage/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js new file mode 100644 index 0000000..ef51e03 --- /dev/null +++ b/coverage/prettify.js @@ -0,0 +1 @@ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..03f704a609c6fd0dbfdac63466a7d7c958b5cbf3 GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jii$m5978H@?Fn+^JD|Y9yzj{W`447Gxa{7*dM7nnnD-Lb z6^}Hx2)'; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function (a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function (a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i =0 ; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/coverage/user.spec.js.html b/coverage/user.spec.js.html new file mode 100644 index 0000000..c42313f --- /dev/null +++ b/coverage/user.spec.js.html @@ -0,0 +1,179 @@ + + + + Code coverage report for user.spec.js + + + + + + + +
+
+

+ All files user.spec.js +

+
+
+ 6.67% + Statements + 1/15 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/5 +
+
+ 6.67% + Lines + 1/15 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +391x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import models from '../../models/';
+import data from '../mockData';
+ 
+ 
+const expect = chai.expect;
+chai.use(http);
+ 
+const { admin, incompleteLoginCredentials, fakeEsther } = data;
+// , superUser, regularUser, fakeEsther, fakeUserDetails
+ 
+describe('Users', () => {
+  after((done) => {
+    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
+    done();
+  });
+  describe('user login endpoint', () => {
+    it('should log in a user and return a token', (done) => {
+      chai.request(app)
+        .post('/api/v1/users/login').send(admin).end((err, res) => {
+          expect(res.status).to.equal(201);
+          expect(res.body).to.have.keys(['message', 'token']);
+          expect(res.body.message).to.eql('login successful');
+          done();
+        });
+    });
+  // describe('user sign up endpoint', () => {
+  //   it('should create a new user', (done) => {
+  //     chai.request(app)
+  //       .post('/api/v1/users/').send(fakeEsther).end((err, res) => {
+  //         console.log("here?", res.status);
+  //         expect(res.status).to.equal(201);
+  //         expect(res.body).to.have.keys(['message', 'user', 'token']);
+  //         expect(res.body.message).to.eql('signup successful');
+  //         done();
+  //       });
+  //   });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/dist/coverage/prettify.js b/dist/coverage/prettify.js new file mode 100644 index 0000000..17e401d --- /dev/null +++ b/dist/coverage/prettify.js @@ -0,0 +1,363 @@ +"use strict"; + +window.PR_SHOULD_USE_CONTINUATION = true;(function () { + var h = ["break,continue,do,else,for,if,return,while"];var u = [h, "auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p = [u, "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l = [p, "alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x = [p, "abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R = [x, "as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r = "all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w = [p, "debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I = [h, "and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f = [h, "alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H = [h, "case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A = [l, R, w, s + I, f, H];var e = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C = "str";var z = "kwd";var j = "com";var O = "typ";var G = "lit";var L = "pun";var F = "pln";var m = "tag";var E = "dec";var J = "src";var P = "atn";var n = "atv";var N = "nocode";var M = "(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z) { + var ad = 0;var S = false;var ac = false;for (var V = 0, U = Z.length; V < U; ++V) { + var ae = Z[V];if (ae.ignoreCase) { + ac = true; + } else { + if (/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ""))) { + S = true;ac = false;break; + } + } + }var Y = { b: 8, t: 9, n: 10, v: 11, f: 12, r: 13 };function ab(ah) { + var ag = ah.charCodeAt(0);if (ag !== 92) { + return ag; + }var af = ah.charAt(1);ag = Y[af];if (ag) { + return ag; + } else { + if ("0" <= af && af <= "7") { + return parseInt(ah.substring(1), 8); + } else { + if (af === "u" || af === "x") { + return parseInt(ah.substring(2), 16); + } else { + return ah.charCodeAt(1); + } + } + } + }function T(af) { + if (af < 32) { + return (af < 16 ? "\\x0" : "\\x") + af.toString(16); + }var ag = String.fromCharCode(af);if (ag === "\\" || ag === "-" || ag === "[" || ag === "]") { + ag = "\\" + ag; + }return ag; + }function X(am) { + var aq = am.substring(1, am.length - 1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));var ak = [];var af = [];var ao = aq[0] === "^";for (var ar = ao ? 1 : 0, aj = aq.length; ar < aj; ++ar) { + var ah = aq[ar];if (/\\[bdsw]/i.test(ah)) { + ak.push(ah); + } else { + var ag = ab(ah);var al;if (ar + 2 < aj && "-" === aq[ar + 1]) { + al = ab(aq[ar + 2]);ar += 2; + } else { + al = ag; + }af.push([ag, al]);if (!(al < 65 || ag > 122)) { + if (!(al < 65 || ag > 90)) { + af.push([Math.max(65, ag) | 32, Math.min(al, 90) | 32]); + }if (!(al < 97 || ag > 122)) { + af.push([Math.max(97, ag) & ~32, Math.min(al, 122) & ~32]); + } + } + } + }af.sort(function (av, au) { + return av[0] - au[0] || au[1] - av[1]; + });var ai = [];var ap = [NaN, NaN];for (var ar = 0; ar < af.length; ++ar) { + var at = af[ar];if (at[0] <= ap[1] + 1) { + ap[1] = Math.max(ap[1], at[1]); + } else { + ai.push(ap = at); + } + }var an = ["["];if (ao) { + an.push("^"); + }an.push.apply(an, ak);for (var ar = 0; ar < ai.length; ++ar) { + var at = ai[ar];an.push(T(at[0]));if (at[1] > at[0]) { + if (at[1] + 1 > at[0]) { + an.push("-"); + }an.push(T(at[1])); + } + }an.push("]");return an.join(""); + }function W(al) { + var aj = al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g"));var ah = aj.length;var an = [];for (var ak = 0, am = 0; ak < ah; ++ak) { + var ag = aj[ak];if (ag === "(") { + ++am; + } else { + if ("\\" === ag.charAt(0)) { + var af = +ag.substring(1);if (af && af <= am) { + an[af] = -1; + } + } + } + }for (var ak = 1; ak < an.length; ++ak) { + if (-1 === an[ak]) { + an[ak] = ++ad; + } + }for (var ak = 0, am = 0; ak < ah; ++ak) { + var ag = aj[ak];if (ag === "(") { + ++am;if (an[am] === undefined) { + aj[ak] = "(?:"; + } + } else { + if ("\\" === ag.charAt(0)) { + var af = +ag.substring(1);if (af && af <= am) { + aj[ak] = "\\" + an[am]; + } + } + } + }for (var ak = 0, am = 0; ak < ah; ++ak) { + if ("^" === aj[ak] && "^" !== aj[ak + 1]) { + aj[ak] = ""; + } + }if (al.ignoreCase && S) { + for (var ak = 0; ak < ah; ++ak) { + var ag = aj[ak];var ai = ag.charAt(0);if (ag.length >= 2 && ai === "[") { + aj[ak] = X(ag); + } else { + if (ai !== "\\") { + aj[ak] = ag.replace(/[a-zA-Z]/g, function (ao) { + var ap = ao.charCodeAt(0);return "[" + String.fromCharCode(ap & ~32, ap | 32) + "]"; + }); + } + } + } + }return aj.join(""); + }var aa = [];for (var V = 0, U = Z.length; V < U; ++V) { + var ae = Z[V];if (ae.global || ae.multiline) { + throw new Error("" + ae); + }aa.push("(?:" + W(ae) + ")"); + }return new RegExp(aa.join("|"), ac ? "gi" : "g"); + }function a(V) { + var U = /(?:^|\s)nocode(?:\s|$)/;var X = [];var T = 0;var Z = [];var W = 0;var S;if (V.currentStyle) { + S = V.currentStyle.whiteSpace; + } else { + if (window.getComputedStyle) { + S = document.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); + } + }var Y = S && "pre" === S.substring(0, 3);function aa(ab) { + switch (ab.nodeType) {case 1: + if (U.test(ab.className)) { + return; + }for (var ae = ab.firstChild; ae; ae = ae.nextSibling) { + aa(ae); + }var ad = ab.nodeName;if ("BR" === ad || "LI" === ad) { + X[W] = "\n";Z[W << 1] = T++;Z[W++ << 1 | 1] = ab; + }break;case 3:case 4: + var ac = ab.nodeValue;if (ac.length) { + if (!Y) { + ac = ac.replace(/[ \t\r\n]+/g, " "); + } else { + ac = ac.replace(/\r\n?/g, "\n"); + }X[W] = ac;Z[W << 1] = T;T += ac.length;Z[W++ << 1 | 1] = ab; + }break;} + }aa(V);return { sourceCode: X.join("").replace(/\n$/, ""), spans: Z }; + }function B(S, U, W, T) { + if (!U) { + return; + }var V = { sourceCode: U, basePos: S };W(V);T.push.apply(T, V.decorations); + }var v = /\S/;function o(S) { + var V = undefined;for (var U = S.firstChild; U; U = U.nextSibling) { + var T = U.nodeType;V = T === 1 ? V ? S : U : T === 3 ? v.test(U.nodeValue) ? S : V : V; + }return V === S ? undefined : V; + }function g(U, T) { + var S = {};var V;(function () { + var ad = U.concat(T);var ah = [];var ag = {};for (var ab = 0, Z = ad.length; ab < Z; ++ab) { + var Y = ad[ab];var ac = Y[3];if (ac) { + for (var ae = ac.length; --ae >= 0;) { + S[ac.charAt(ae)] = Y; + } + }var af = Y[1];var aa = "" + af;if (!ag.hasOwnProperty(aa)) { + ah.push(af);ag[aa] = null; + } + }ah.push(/[\0-\uffff]/);V = k(ah); + })();var X = T.length;var W = function W(ah) { + var Z = ah.sourceCode, + Y = ah.basePos;var ad = [Y, F];var af = 0;var an = Z.match(V) || [];var aj = {};for (var ae = 0, aq = an.length; ae < aq; ++ae) { + var ag = an[ae];var ap = aj[ag];var ai = void 0;var am;if (typeof ap === "string") { + am = false; + } else { + var aa = S[ag.charAt(0)];if (aa) { + ai = ag.match(aa[1]);ap = aa[0]; + } else { + for (var ao = 0; ao < X; ++ao) { + aa = T[ao];ai = ag.match(aa[1]);if (ai) { + ap = aa[0];break; + } + }if (!ai) { + ap = F; + } + }am = ap.length >= 5 && "lang-" === ap.substring(0, 5);if (am && !(ai && typeof ai[1] === "string")) { + am = false;ap = J; + }if (!am) { + aj[ag] = ap; + } + }var ab = af;af += ag.length;if (!am) { + ad.push(Y + ab, ap); + } else { + var al = ai[1];var ak = ag.indexOf(al);var ac = ak + al.length;if (ai[2]) { + ac = ag.length - ai[2].length;ak = ac - al.length; + }var ar = ap.substring(5);B(Y + ab, ag.substring(0, ak), W, ad);B(Y + ab + ak, al, q(ar, al), ad);B(Y + ab + ac, ag.substring(ac), W, ad); + } + }ah.decorations = ad; + };return W; + }function i(T) { + var W = [], + S = [];if (T.tripleQuotedStrings) { + W.push([C, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, null, "'\""]); + } else { + if (T.multiLineStrings) { + W.push([C, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, null, "'\"`"]); + } else { + W.push([C, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, "\"'"]); + } + }if (T.verbatimStrings) { + S.push([C, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]); + }var Y = T.hashComments;if (Y) { + if (T.cStyleComments) { + if (Y > 1) { + W.push([j, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, "#"]); + } else { + W.push([j, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, "#"]); + }S.push([C, /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, null]); + } else { + W.push([j, /^#[^\r\n]*/, null, "#"]); + } + }if (T.cStyleComments) { + S.push([j, /^\/\/[^\r\n]*/, null]);S.push([j, /^\/\*[\s\S]*?(?:\*\/|$)/, null]); + }if (T.regexLiterals) { + var X = "/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/";S.push(["lang-regex", new RegExp("^" + M + "(" + X + ")")]); + }var V = T.types;if (V) { + S.push([O, V]); + }var U = ("" + T.keywords).replace(/^ | $/g, "");if (U.length) { + S.push([z, new RegExp("^(?:" + U.replace(/[\s,]+/g, "|") + ")\\b"), null]); + }W.push([F, /^\s+/, null, " \r\n\t\xA0"]);S.push([G, /^@[a-z_$][a-z_$@0-9]*/i, null], [O, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null], [F, /^[a-z_$][a-z_$@0-9]*/i, null], [G, new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*", "i"), null, "0123456789"], [F, /^\\[\s\S]?/, null], [L, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);return g(W, S); + }var K = i({ keywords: A, hashComments: true, cStyleComments: true, multiLineStrings: true, regexLiterals: true });function Q(V, ag) { + var U = /(?:^|\s)nocode(?:\s|$)/;var ab = /\r\n?|\n/;var ac = V.ownerDocument;var S;if (V.currentStyle) { + S = V.currentStyle.whiteSpace; + } else { + if (window.getComputedStyle) { + S = ac.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); + } + }var Z = S && "pre" === S.substring(0, 3);var af = ac.createElement("LI");while (V.firstChild) { + af.appendChild(V.firstChild); + }var W = [af];function ae(al) { + switch (al.nodeType) {case 1: + if (U.test(al.className)) { + break; + }if ("BR" === al.nodeName) { + ad(al);if (al.parentNode) { + al.parentNode.removeChild(al); + } + } else { + for (var an = al.firstChild; an; an = an.nextSibling) { + ae(an); + } + }break;case 3:case 4: + if (Z) { + var am = al.nodeValue;var aj = am.match(ab);if (aj) { + var ai = am.substring(0, aj.index);al.nodeValue = ai;var ah = am.substring(aj.index + aj[0].length);if (ah) { + var ak = al.parentNode;ak.insertBefore(ac.createTextNode(ah), al.nextSibling); + }ad(al);if (!ai) { + al.parentNode.removeChild(al); + } + } + }break;} + }function ad(ak) { + while (!ak.nextSibling) { + ak = ak.parentNode;if (!ak) { + return; + } + }function ai(al, ar) { + var aq = ar ? al.cloneNode(false) : al;var ao = al.parentNode;if (ao) { + var ap = ai(ao, 1);var an = al.nextSibling;ap.appendChild(aq);for (var am = an; am; am = an) { + an = am.nextSibling;ap.appendChild(am); + } + }return aq; + }var ah = ai(ak.nextSibling, 0);for (var aj; (aj = ah.parentNode) && aj.nodeType === 1;) { + ah = aj; + }W.push(ah); + }for (var Y = 0; Y < W.length; ++Y) { + ae(W[Y]); + }if (ag === (ag | 0)) { + W[0].setAttribute("value", ag); + }var aa = ac.createElement("OL");aa.className = "linenums";var X = Math.max(0, ag - 1 | 0) || 0;for (var Y = 0, T = W.length; Y < T; ++Y) { + af = W[Y];af.className = "L" + (Y + X) % 10;if (!af.firstChild) { + af.appendChild(ac.createTextNode("\xA0")); + }aa.appendChild(af); + }V.appendChild(aa); + }function D(ac) { + var aj = /\bMSIE\b/.test(navigator.userAgent);var am = /\n/g;var al = ac.sourceCode;var an = al.length;var V = 0;var aa = ac.spans;var T = aa.length;var ah = 0;var X = ac.decorations;var Y = X.length;var Z = 0;X[Y] = an;var ar, aq;for (aq = ar = 0; aq < Y;) { + if (X[aq] !== X[aq + 2]) { + X[ar++] = X[aq++];X[ar++] = X[aq++]; + } else { + aq += 2; + } + }Y = ar;for (aq = ar = 0; aq < Y;) { + var at = X[aq];var ab = X[aq + 1];var W = aq + 2;while (W + 2 <= Y && X[W + 1] === ab) { + W += 2; + }X[ar++] = at;X[ar++] = ab;aq = W; + }Y = X.length = ar;var ae = null;while (ah < T) { + var af = aa[ah];var S = aa[ah + 2] || an;var ag = X[Z];var ap = X[Z + 2] || an;var W = Math.min(S, ap);var ak = aa[ah + 1];var U;if (ak.nodeType !== 1 && (U = al.substring(V, W))) { + if (aj) { + U = U.replace(am, "\r"); + }ak.nodeValue = U;var ai = ak.ownerDocument;var ao = ai.createElement("SPAN");ao.className = X[Z + 1];var ad = ak.parentNode;ad.replaceChild(ao, ak);ao.appendChild(ak);if (V < S) { + aa[ah + 1] = ak = ai.createTextNode(al.substring(W, S));ad.insertBefore(ak, ao.nextSibling); + } + }V = W;if (V >= S) { + ah += 2; + }if (V >= ap) { + Z += 2; + } + } + }var t = {};function c(U, V) { + for (var S = V.length; --S >= 0;) { + var T = V[S];if (!t.hasOwnProperty(T)) { + t[T] = U; + } else { + if (window.console) { + console.warn("cannot override language handler %s", T); + } + } + } + }function q(T, S) { + if (!(T && t.hasOwnProperty(T))) { + T = /^\s*]*(?:>|$)/], [j, /^<\!--[\s\S]*?(?:-\->|$)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], [L, /^(?:<[%?]|[%?]>)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i]]), ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"]);c(g([[F, /^[\s]+/, null, " \t\r\n"], [n, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, "\"'"]], [[m, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i], [P, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i], ["lang-uq.val", /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/], [L, /^[=<>\/]+/], ["lang-js", /^on\w+\s*=\s*\"([^\"]+)\"/i], ["lang-js", /^on\w+\s*=\s*\'([^\']+)\'/i], ["lang-js", /^on\w+\s*=\s*([^\"\'>\s]+)/i], ["lang-css", /^style\s*=\s*\"([^\"]+)\"/i], ["lang-css", /^style\s*=\s*\'([^\']+)\'/i], ["lang-css", /^style\s*=\s*([^\"\'>\s]+)/i]]), ["in.tag"]);c(g([], [[n, /^[\s\S]+/]]), ["uq.val"]);c(i({ keywords: l, hashComments: true, cStyleComments: true, types: e }), ["c", "cc", "cpp", "cxx", "cyc", "m"]);c(i({ keywords: "null,true,false" }), ["json"]);c(i({ keywords: R, hashComments: true, cStyleComments: true, verbatimStrings: true, types: e }), ["cs"]);c(i({ keywords: x, cStyleComments: true }), ["java"]);c(i({ keywords: H, hashComments: true, multiLineStrings: true }), ["bsh", "csh", "sh"]);c(i({ keywords: I, hashComments: true, multiLineStrings: true, tripleQuotedStrings: true }), ["cv", "py"]);c(i({ keywords: s, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["perl", "pl", "pm"]);c(i({ keywords: f, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["rb"]);c(i({ keywords: w, cStyleComments: true, regexLiterals: true }), ["js"]);c(i({ keywords: r, hashComments: 3, cStyleComments: true, multilineStrings: true, tripleQuotedStrings: true, regexLiterals: true }), ["coffee"]);c(g([], [[C, /^[\s\S]+/]]), ["regex"]);function d(V) { + var U = V.langExtension;try { + var S = a(V.sourceNode);var T = S.sourceCode;V.sourceCode = T;V.spans = S.spans;V.basePos = 0;q(U, T)(V);D(V); + } catch (W) { + if ("console" in window) { + console.log(W && W.stack ? W.stack : W); + } + } + }function y(W, V, U) { + var S = document.createElement("PRE");S.innerHTML = W;if (U) { + Q(S, U); + }var T = { langExtension: V, numberLines: U, sourceNode: S };d(T);return S.innerHTML; + }function b(ad) { + function Y(af) { + return document.getElementsByTagName(af); + }var ac = [Y("pre"), Y("code"), Y("xmp")];var T = [];for (var aa = 0; aa < ac.length; ++aa) { + for (var Z = 0, V = ac[aa].length; Z < V; ++Z) { + T.push(ac[aa][Z]); + } + }ac = null;var W = Date;if (!W.now) { + W = { now: function now() { + return +new Date(); + } }; + }var X = 0;var S;var ab = /\blang(?:uage)?-([\w.]+)(?!\S)/;var ae = /\bprettyprint\b/;function U() { + var ag = window.PR_SHOULD_USE_CONTINUATION ? W.now() + 250 : Infinity;for (; X < T.length && W.now() < ag; X++) { + var aj = T[X];var ai = aj.className;if (ai.indexOf("prettyprint") >= 0) { + var ah = ai.match(ab);var am;if (!ah && (am = o(aj)) && "CODE" === am.tagName) { + ah = am.className.match(ab); + }if (ah) { + ah = ah[1]; + }var al = false;for (var ak = aj.parentNode; ak; ak = ak.parentNode) { + if ((ak.tagName === "pre" || ak.tagName === "code" || ak.tagName === "xmp") && ak.className && ak.className.indexOf("prettyprint") >= 0) { + al = true;break; + } + }if (!al) { + var af = aj.className.match(/\blinenums\b(?::(\d+))?/);af = af ? af[1] && af[1].length ? +af[1] : true : false;if (af) { + Q(aj, af); + }S = { langExtension: ah, sourceNode: aj, numberLines: af };d(S); + } + } + }if (X < T.length) { + setTimeout(U, 250); + } else { + if (ad) { + ad(); + } + } + }U(); + }window.prettyPrintOne = y;window.prettyPrint = b;window.PR = { createSimpleLexer: g, registerLangHandler: c, sourceDecorator: i, PR_ATTRIB_NAME: P, PR_ATTRIB_VALUE: n, PR_COMMENT: j, PR_DECLARATION: E, PR_KEYWORD: z, PR_LITERAL: G, PR_NOCODE: N, PR_PLAIN: F, PR_PUNCTUATION: L, PR_SOURCE: J, PR_STRING: C, PR_TAG: m, PR_TYPE: O }; +})();PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_DECLARATION, /^]*(?:>|$)/], [PR.PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/], [PR.PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-handlebars", /^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i], [PR.PR_DECLARATION, /^{{[#^>/]?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{&?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{{>?\s*[\w.][^}]*}}}/], [PR.PR_COMMENT, /^{{![^}]*}}/]]), ["handlebars", "hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN, /^[ \t\r\n\f]+/, null, " \t\r\n\f"]], [[PR.PR_STRING, /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null], [PR.PR_STRING, /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null], ["lang-css-str", /^url\(([^\)\"\']*)\)/i], [PR.PR_KEYWORD, /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i, null], ["lang-css-kw", /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i], [PR.PR_COMMENT, /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], [PR.PR_COMMENT, /^(?:)/], [PR.PR_LITERAL, /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], [PR.PR_LITERAL, /^#(?:[0-9a-f]{3}){1,2}/i], [PR.PR_PLAIN, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i], [PR.PR_PUNCTUATION, /^[^\s\w\'\"]+/]]), ["css"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_KEYWORD, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]), ["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_STRING, /^[^\)\"\']+/]]), ["css-str"]); \ No newline at end of file diff --git a/dist/coverage/sorter.js b/dist/coverage/sorter.js new file mode 100644 index 0000000..9519297 --- /dev/null +++ b/dist/coverage/sorter.js @@ -0,0 +1,169 @@ +'use strict'; + +var addSorting = function () { + "use strict"; + + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function sorter(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function finalSorter(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function () { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function () { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(cols); + addSortIndicators(); + enableUI(); + }; +}(); + +window.addEventListener('load', addSorting); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 32c726d..80c5176 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,9 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { + value: true +}); + var _express = require('./server/config/express'); var _express2 = _interopRequireDefault(_express); @@ -8,6 +12,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var port = process.env.PORT || 3000; -_express2.default.listen(port, function () { +var server = _express2.default.listen(port, function () { console.log('API Server started and listening on port 3000'); -}); \ No newline at end of file +}); + +exports.default = server; \ No newline at end of file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js index 9fd7ab2..c13361b 100644 --- a/dist/server/controllers/roles.js +++ b/dist/server/controllers/roles.js @@ -62,16 +62,22 @@ function getRoles(req, res) { * @returns {object} - role found by id */ function findRole(req, res) { - return Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(function (error) { - return res.status(400).json(error); - }); + if (isNaN(req.params.id)) { + return res.status(401).json({ + message: 'invalid input syntax for integer: "' + req.params.id + '"' + }); + } else { + Role.findById(req.params.id).then(function (role) { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(function (error) { + return res.status(400).json(error); + }); + } } /** diff --git a/dist/server/controllers/searches.js b/dist/server/controllers/searches.js index 9a390c3..fd34c6c 100644 --- a/dist/server/controllers/searches.js +++ b/dist/server/controllers/searches.js @@ -1 +1,144 @@ -"use strict"; \ No newline at end of file +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _helper = require('../helpers/helper'); + +var _helper2 = _interopRequireDefault(_helper); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var Document = _models2.default.Document; +var User = _models2.default.User; +var metaData = _helper2.default.paginationMetaData; + +/** + * Search for user using a query string + * @param {string} req - search query of string + * @param {array} res - array of users + * @returns {array} - array users searched + */ +function searchUser(req, res) { + var searchQuery = req.query.q, + limit = req.query.limit, + offset = req.query.offset; + if (!searchQuery) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + return User.findAndCountAll({ + limit: limit, + offset: offset, + attributes: { exclude: ['password'] }, + where: { + userName: { + $like: '%' + searchQuery + '%' + } + } + }).then(function (_ref) { + var user = _ref.rows, + count = _ref.count; + + if (count === 0) { + return res.status(404).json({ message: 'User not found' }); + } + res.status(200).send({ + user: user, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); +} + +/** + * + * Search for documents by title + * @param {string} req - an object containing the query, offset and limit + * @param {array} res - an array containing searched document + * @returns {array} - searched document + */ +function searchDocuments(req, res) { + var limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ + message: 'Invalid search input' + }); + } + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + }, + include: [{ + model: User, + attributes: ['userName', 'roleId'] + }] + }).then(function (_ref2) { + var document = _ref2.rows, + count = _ref2.count; + + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } else if (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ + limit: limit, + offset: offset, + include: [{ + model: User, + attributes: ['userName', 'roleId'], + where: { + roleId: req.decoded.roleId + } + }], + where: { + access: { + $ne: 'private' + }, + title: { + $like: '%' + queryString + '%' + } + } + + }).then(function (_ref3) { + var document = _ref3.rows, + count = _ref3.count; + + if (count === 0) { + res.status(404).json({ message: 'Document not found' }); + } + res.status(200).send({ + document: document, + pagination: metaData(count, limit, offset) + }); + }).catch(function (error) { + return res.status(400).send(error); + }); + } +} + +exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 669a273..6561d7f 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -72,30 +72,26 @@ function createUser(req, res) { if (errors) { res.status(400).json({ errors: errors }); } else { - _bcrypt2.default.genSalt(10, function (err, salt) { - _bcrypt2.default.hash(req.body.password, salt, function (err, hash) { - User.findAll({ - where: { email: req.body.email } - }).then(function (err, user) { - if (!user) { - User.create({ - fullName: req.body.fullName, - userName: req.body.userName, - email: req.body.email, - password: hash, - roleId: req.body.roleId || 2 - }).then(function (userDetails) { - res.status(200).json({ - userDetails: userDetails, - success: 'ok', - message: 'You have successfully registered.' - }); - }).catch(function (error) { - res.status(400).json(error); - }); - } + User.findAll({ + where: { email: req.body.email } + }).then(function (err, user) { + if (!user) { + User.create({ + fullName: req.body.fullName, + userName: req.body.userName, + email: req.body.email, + password: _bcrypt2.default.hashSync(req.body.password, _bcrypt2.default.genSaltSync(10)), + roleId: req.body.roleId || 2 + }).then(function (userDetails) { + res.status(200).json({ + userDetails: userDetails, + success: true, + message: 'You have successfully registered.' + }); + }).catch(function (error) { + res.status(400).json(error); }); - }); + } }); } } @@ -125,29 +121,26 @@ function login(req, res) { success: false, message: 'Authentication failed. User not found.' }); } else if (existingUser) { - _bcrypt2.default.compare(req.body.password, existingUser.password, function (err, result) { - if (err) throw err; - if (result) { - var payLoad = { - email: existingUser.email, - id: existingUser.id, - fullName: existingUser.fullName, - roleId: existingUser.roleId - }; - var token = _jsonwebtoken2.default.sign(payLoad, jwtSecret, { - expiresIn: 60 * 60 * 24 - }); - res.status(201).json({ - success: true, - token: token - }); - } else { - res.status(401).json({ - success: false, - message: 'Authentication failed. Wrong password.' - }); - } - }); + if (_bcrypt2.default.compareSync(req.body.password, existingUser.password)) { + var payLoad = { + email: existingUser.email, + id: existingUser.id, + fullName: existingUser.fullName, + roleId: existingUser.roleId + }; + var token = _jsonwebtoken2.default.sign(payLoad, jwtSecret, { + expiresIn: 60 * 60 * 24 + }); + res.status(201).json({ + success: true, + token: token + }); + } else { + res.status(401).json({ + success: false, + message: 'Authentication failed. Wrong password.' + }); + } } }).catch(function (error) { return res.status(400).send(error); @@ -168,6 +161,11 @@ function findUser(req, res) { message: 'Unauthorized Access' }); } + if (isNaN(userQuery)) { + return res.status(401).json({ + message: 'invalid input syntax for integer: "' + req.params.id + '"' + }); + } return User.findAll({ where: { id: req.params.id diff --git a/dist/server/seeders/20170727152600-sample-roles.js b/dist/server/seeders/20170727152600-sample-roles.js new file mode 100644 index 0000000..790d10f --- /dev/null +++ b/dist/server/seeders/20170727152600-sample-roles.js @@ -0,0 +1,23 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface) { + return queryInterface.bulkInsert('Roles', [{ + title: 'admin', + createdAt: new Date(), + updatedAt: new Date() + }, { + title: 'facilitator', + createdAt: new Date(), + updatedAt: new Date() + }, { + title: 'fellow', + createdAt: new Date(), + updatedAt: new Date() + }], {}); + }, + + down: function down(queryInterface) { + return queryInterface.bulkDelete('Roles', null, {}); + } +}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153559-sample-users.js b/dist/server/seeders/20170727153559-sample-users.js new file mode 100644 index 0000000..6c8bde8 --- /dev/null +++ b/dist/server/seeders/20170727153559-sample-users.js @@ -0,0 +1,38 @@ +'use strict'; + +var bcrypt = require('bcrypt'); +require('dotenv').config(); + +module.exports = { + up: function up(queryInterface) { + return queryInterface.bulkInsert('Users', [{ + userName: 'bank', + fullName: 'Baas Bank', + email: 'baas@test.com', + password: bcrypt.hashSync(process.env.TEST_ADMIN_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, { + userName: 'john', + fullName: 'John Bosco', + email: 'john@test.com', + password: bcrypt.hashSync(process.env.TEST_FELLOW_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 2, + createdAt: new Date(), + updatedAt: new Date() + }, { + userName: 'blessing', + fullName: 'Blessing Philip', + email: 'blessing@test.com', + password: bcrypt.hashSync(process.env.TEST_FACILITATOR_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 3, + createdAt: new Date(), + updatedAt: new Date() + }], {}); + }, + + down: function down(queryInterface) { + return queryInterface.bulkDelete('Users', null, {}); + } +}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153641-sample-documents.js b/dist/server/seeders/20170727153641-sample-documents.js new file mode 100644 index 0000000..caf5e98 --- /dev/null +++ b/dist/server/seeders/20170727153641-sample-documents.js @@ -0,0 +1,32 @@ +'use strict'; + +module.exports = { + up: function up(queryInterface, Sequelize) { + return queryInterface.bulkInsert('Documents', [{ + title: 'John Doe', + content: 'eze goes to school', + access: 'public', + userId: 2, + createdAt: new Date(), + updatedAt: new Date() + }, { + title: 'John naddddd', + content: 'John watches american gods regularly', + access: 'private', + userId: 2, + createdAt: new Date(), + updatedAt: new Date() + }, { + title: 'James Hannn', + content: 'Han is a bad guy', + access: 'role', + userId: 2, + createdAt: new Date(), + updatedAt: new Date() + }], {}); + }, + + down: function down(queryInterface, Sequelize) { + return queryInterface.bulkDelete('Documents', null, {}); + } +}; \ No newline at end of file diff --git a/dist/server/test/document.spec.js b/dist/server/test/document.spec.js new file mode 100644 index 0000000..8791e41 --- /dev/null +++ b/dist/server/test/document.spec.js @@ -0,0 +1,291 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow; + + +describe('Documents', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + after(function (done) { + _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST Document', function () { + it('should add a new document if the user is authenticated', function (done) { + var document = { + title: 'boromir-team', + content: 'Andela is really awesome!!!', + access: 'public', + userId: 2 + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.property('id'); + expect(res.body.title).to.eql('boromir-team'); + expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + + it('Should fail if document already exist', function () { + var document = { + title: 'John team', + content: 'eze goes to school', + access: 'public' + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body.message).to.eql('Document already exists'); + }); + }); + it('should fail to add a new document if the user is not authenticated', function (done) { + var document = { + title: 'boromir-team', + content: 'Andela is really awesome !!!', + value: 'private', + userId: 2 + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + }); + + describe('/GET Documents', function () { + it('Should get all documents for the user that is authenticated', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['document', 'pagination']); + done(); + }); + }); + it('should fail to get all documents if the user is not authenticated', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).be.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get all documents with correct limit as a query', function (done) { + var limit = 1; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + limit).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + it('Should get all documents with correct offset as a query', function (done) { + var offset = 0; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + offset).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + }); + + describe('/GET/:id Document', function () { + it('Should fail to get document if it doesn`t exist', function (done) { + var documentId = 8; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + it('Should get all public regardless of id', function (done) { + var documentId = 4; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(4); + expect(res.body.title).to.equal('boromir-team'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + it('Should fail to get a private document if the requester does not own it', function (done) { + var documentId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a private document the where the requester is the owner', function (done) { + var documentId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.access).to.eql('private'); + expect(res.body.title).to.eql('John naddddd'); + expect(res.body.id).to.eql(2); + expect(res.body.userId).to.eql(2); + done(); + }); + }); + it('Should fail get a role document if the users are not on the same role', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a role document if the users are on the same role', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + done(); + }); + }); + it('Should get a role document if the user is an admin', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + }); + done(); + }); + }); + + describe('/PUT/:id, Document', function () { + it('Should update a document by id if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'wreck it ralph' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.title).to.eql('wreck it ralph'); + done(); + }); + }); + it('Should fail to update a document by\n id if the user does not have the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).send({ title: 'spiderman Homecoming' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to edit this document'); + done(); + }); + }); + it('Should not update a document by id if the user has admin access', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: adminToken }).send({ title: 'wreck it' }).end(function (err, res) { + expect(res.status).to.equal(401); + done(); + }); + }); + it('Should fail to update a document by id if the document does not exist', function (done) { + var id = 10; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'Deadpool' }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document Not Found'); + done(); + }); + }); + }); + + describe('DELETE/:id Document', function () { + it('Should delete a document if the user has admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should delete a document if the user is the owner', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete the document given the user is not the owner', function (done) { + var id = 1; + _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to delete this document'); + done(); + }); + }); + it('Should fail to delete if the document does not exist', function (done) { + var id = 234; + _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/dist/server/test/mockData.js b/dist/server/test/mockData.js new file mode 100644 index 0000000..3017a66 --- /dev/null +++ b/dist/server/test/mockData.js @@ -0,0 +1,54 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _dotenv = require('dotenv'); + +var _dotenv2 = _interopRequireDefault(_dotenv); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_dotenv2.default.config(); + +exports.default = { + admin: { + email: 'baas@test.com', + password: process.env.TEST_ADMIN_PASSWORD + }, + fellow: { + email: 'john@test.com', + password: process.env.TEST_FELLOW_PASSWORD + }, + faciliatator: { + email: 'blessing@test.com', + password: process.env.TEST_FACILITATOR_PASSWORD + }, + user2: { + email: 'baas@test.com', + password: 'test' + }, + user1: { + email: 'test@test123.com', + password: 'test' + }, + fakeBass: { + fullName: 'Baasbank Adams', + userName: 'tiaandela', + email: 'name@example.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, + fakeUserDetails: { + fullName: 'Daniel Cfh', + userName: 'cfh', + email: 'cfh@example.com', + password: 'pass123', + roleId: 2, + createdAt: 'date', + updatedAt: new Date() + } +}; \ No newline at end of file diff --git a/dist/server/test/role.spec.js b/dist/server/test/role.spec.js new file mode 100644 index 0000000..cecad5c --- /dev/null +++ b/dist/server/test/role.spec.js @@ -0,0 +1,245 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow; + + +describe('Roles', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + after(function (done) { + _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST Role', function () { + it('should add a new role if the user is an admin', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'boromir' }).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + expect(res.body.role).to.have.property('title').to.equal('boromir'); + }); + done(); + }); + it('should add a new role if the user is an admin', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'king' }).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + }); + done(); + }); + it('Should fail if a non-admin wants to add a new role', function (done) { + var role = { + title: 'boromir-team' + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/roles/').set({ authorization: userToken }).send(role).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should return an error if the title is not a string', function (done) { + _chai2.default.request(_index2.default).post('/api/v1/roles').set({ authorization: adminToken }).send({ title: 358583 }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Invalid input credentials'); + done(); + }); + }); + }); + + describe('/GET Role', function () { + it('Should get all the roles if the user is an admin', function (done) { + _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.length(5); + expect(res.body).to.be.a('array'); + expect(res.body[0].id).to.eql(1); + expect(res.body[0].title).to.eql('admin'); + expect(res.body[1].id).to.eql(2); + expect(res.body[1].title).to.eql('facilitator'); + done(); + }); + }); + it('Should fail to get the roles if the user is not admin', function (done) { + _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + }); + + describe('/GET/:id Role', function () { + it('Should get a role by id if the user is an admin', function (done) { + var id = 2; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.title).to.eql('facilitator'); + expect(res.body.id).to.equal(2); + done(); + }); + }); + it('Should fail to get a role by id if the user is not an admin', function (done) { + var id = 2; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get a role by id if the user enters an invalid input', function (done) { + var id = 'fddjsdcdjn'; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('invalid input syntax for integer: "' + id + '"'); + done(); + }); + }); + it('Should fail to get a role by id if the role does not exist', function (done) { + var id = 250; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body.message).to.eql('Role not found'); + done(); + }); + }); + it('Should fail to get a role by id if the id is out of range', function (done) { + var id = 500000000000000000000; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); + done(); + }); + }); + }); + describe('/PUT/:id Role', function () { + it('Should update a role by id if the user has admin access', function (done) { + var id = 2; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'boromir-team' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role updated successfully'); + expect(res.body).to.have.property('role'); + done(); + }); + }); + it('Should fail to update a role by id if the user has no admin access', function (done) { + var id = 2; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: userToken }).send({ title: 'kiba' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to update a\n role by id if the admin enters an invalid input', function (done) { + var id = 200; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'kiba' }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it('Should fail to update a role by\n id if the admin enters an id that is out range', function (done) { + var id = 2000000000000000; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'regular' }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); + done(); + }); + }); + }); + describe('/DELETE/:id Role', function () { + it('Should delete a role given the user has admin access', function (done) { + var id = 3; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + }); + done(); + }); + it('Should fail to delete a role given the user has no admin access', function (done) { + var id = 3; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to delete a role given the admin enters an invalid input', function (done) { + var id = 300; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it('Should fail to delete a role given\n the admin enters an input that is out of range', function (done) { + var id = 3000000000000000; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/dist/server/test/search.spec.js b/dist/server/test/search.spec.js new file mode 100644 index 0000000..8af060e --- /dev/null +++ b/dist/server/test/search.spec.js @@ -0,0 +1,106 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToke = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow; + + +describe('Users', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + after(function (done) { + _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/SEARCH/users/?q={name}', function () { + it('Should return an error if no querystring is provided', function () { + var query = ''; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('Inval search input'); + }); + }); + it('Should return a search list response of the required search input', function () { + var query = 'jame'; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body.fullName).to.eql('jame doe'); + expect(res.body.userName).to.eql('testdoe'); + }); + }); + }); + describe('/SEARCH/documents/?q=', function () { + it('Should return an error if no querystring is provided', function () { + var query = ''; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message').to.equal('Invalid search input'); + }); + }); + it('Should return a search list of the required search input', function () { + var query = 'John'; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.property('document'); + expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); + expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); + expect(res.body).to.have.property('pagination'); + expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + }); + }); + it('Should throw an error if the searched document is not found', function () { + var query = 'jk'; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.have.property('message').to.equal('Document not found'); + }); + }); + }); +}); \ No newline at end of file diff --git a/dist/server/test/user.spec.js b/dist/server/test/user.spec.js new file mode 100644 index 0000000..2b8403b --- /dev/null +++ b/dist/server/test/user.spec.js @@ -0,0 +1,314 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _models = require('../models'); + +var _models2 = _interopRequireDefault(_models); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fakeBass = _mockData2.default.fakeBass, + fellow = _mockData2.default.fellow, + user1 = _mockData2.default.user1, + user2 = _mockData2.default.user2; + + +describe('Users', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + after(function (done) { + _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST User login', function () { + it('Should fail if the user enters incorrect crendentials upon login', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user1).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message).to.eql('Authentication failed. User not found.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('Should fail if the user provide a wrong password', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user2).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message).to.eql('Authentication failed. Wrong password.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('should log in a user and return a token', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.have.keys(['success', 'token']); + expect(res.body.success).to.eql(true); + done(); + }); + }); + + describe('/POST User Signup', function () { + it('should create a new user', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/').send(fakeBass).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.keys(['message', 'success', 'userDetails']); + expect(res.body.success).to.eql(true); + expect(res.body.message).to.eql('You have successfully registered.'); + done(); + }); + }); + }); + + describe('#GET Users', function () { + it('Should get all users if the user is an admin ', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['user', 'pagination']); + done(); + }); + }); + it('Should fail to get all users if the user has no admin access ', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get all users if no token was provided', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + it('Should get all users with correct limit as a query', function (done) { + var limit = 1; + _chai2.default.request(_index2.default).get('/api/v1/users?limit=' + limit).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.user[0].fullName).to.equal('Baas Bank'); + expect(res.body.user[0].userName).to.equal('bank'); + done(); + }); + }); + }); + describe('#GET User by Id', function () { + it('Should get a user if the user is an admin', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).to.eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should get the user if the requested user is the current user', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should fail to get a user if an invalid input is entered', function (done) { + var id = 'fddjsdcdjn'; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.property('message').to.eql('invalid input syntax for integer: "' + id + '"'); + done(); + }); + }); + it('should fail to get the user if the requester is not the owner', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('api/users/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message']); + expect(res.body.message).to.eql('Unauthorized access'); + }); + done(); + }); + it('Should fail to get a user if the user does not exist', function (done) { + var id = 250; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.have.property('message'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + it('Should fail to get a user if the id is out of range', function (done) { + var id = 500000000000000000; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message').to.equal('value "' + id + '" is out of range for type integer'); + done(); + }); + }); + }); + describe('#PUT Update user by Id', function () { + it('Should update a user`s full name if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ fullName: 'jake doe' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.fullName).to.eql('jake doe'); + done(); + }); + }); + it('Should update a user`s email if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.email).to.eql('jakedoe@andela.com'); + done(); + }); + }); + it('Should update a user`s username if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ userName: 'jakedoe12' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.userName).to.eql('jakedoe12'); + done(); + }); + }); + it('Should fail to update a user\'s\n details if the user does not have the same user id', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to access this user'); + done(); + }); + }); + it('Should fail to update a user\'s\n details if the user enters an invalid user id', function (done) { + var id = 2302; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to access this user'); + done(); + }); + }); + }); + describe('#DELETE /:id Users', function () { + it('Should delete a user given the user has admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete a user if the user has no admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized to access this field'); + done(); + }); + }); + it('Should give a User not found if user don\'t exist', function (done) { + var id = 23; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + }); + describe('/GET/users/:id/documents Documents', function () { + it('Should fail to get documents if the user does not exist', function (done) { + var userId = 9; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + it('Should fail to get documents if there is no token present', function (done) { + var userId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get documents for the user with its unique userId', function (done) { + var userId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.document[1].userId).to.eql(2); + expect(res.body.document[1].title).to.eql('boromir-team'); + expect(res.body.document[1].content).to.eql('Andela is really awesome!!!'); + done(); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/index.js b/index.js index e81e308..7d0286a 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,8 @@ import app from './server/config/express'; const port = process.env.PORT || 3000; -app.listen(port, () => { +const server = app.listen(port, () => { console.log('API Server started and listening on port 3000'); }); + +export default server; diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 0000000..dbd7248 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,49 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/bin/node', +1 verbose cli '/usr/local/bin/npm', +1 verbose cli 'run', +1 verbose cli 'server-test' ] +2 info using npm@3.10.10 +3 info using node@v6.10.3 +4 verbose run-script [ 'preserver-test', 'server-test', 'postserver-test' ] +5 info lifecycle document-manager@1.0.0~preserver-test: document-manager@1.0.0 +6 silly lifecycle document-manager@1.0.0~preserver-test: no script for preserver-test, continuing +7 info lifecycle document-manager@1.0.0~server-test: document-manager@1.0.0 +8 verbose lifecycle document-manager@1.0.0~server-test: unsafe-perm in lifecycle true +9 verbose lifecycle document-manager@1.0.0~server-test: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/andeladeveloper/Documents/projects/document-manager/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin +10 verbose lifecycle document-manager@1.0.0~server-test: CWD: /Users/andeladeveloper/Documents/projects/document-manager +11 silly lifecycle document-manager@1.0.0~server-test: Args: [ '-c', +11 silly lifecycle 'npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000' ] +12 silly lifecycle document-manager@1.0.0~server-test: Returned: code: 6 signal: null +13 info lifecycle document-manager@1.0.0~server-test: Failed to exec server-test script +14 verbose stack Error: document-manager@1.0.0 server-test: `npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000` +14 verbose stack Exit status 6 +14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at EventEmitter.emit (events.js:191:7) +14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14) +14 verbose stack at emitTwo (events.js:106:13) +14 verbose stack at ChildProcess.emit (events.js:191:7) +14 verbose stack at maybeClose (internal/child_process.js:886:16) +14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) +15 verbose pkgid document-manager@1.0.0 +16 verbose cwd /Users/andeladeveloper/Documents/projects/document-manager +17 error Darwin 16.6.0 +18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server-test" +19 error node v6.10.3 +20 error npm v3.10.10 +21 error code ELIFECYCLE +22 error document-manager@1.0.0 server-test: `npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000` +22 error Exit status 6 +23 error Failed at the document-manager@1.0.0 server-test script 'npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000'. +23 error Make sure you have the latest version of node.js and npm installed. +23 error If you do, this is most likely a problem with the document-manager package, +23 error not with npm itself. +23 error Tell the author that this fails on your system: +23 error npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000 +23 error You can get information on how to open an issue for this project with: +23 error npm bugs document-manager +23 error Or if that isn't available, you can get their info via: +23 error npm owner ls document-manager +23 error There is likely additional logging output above. +24 verbose exit [ 1, true ] diff --git a/package.json b/package.json index 109bcaa..4e15acd 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,10 @@ "scripts": { "start": "node node_modules/gulp/bin/gulp", "test": "node node_modules/gulp/bin/gulp test", + "test:db:migrate": "NODE_ENV=test sequelize db:migrate:undo:all && NODE_ENV=test sequelize db:migrate", + "test:db:seed": "NODE_ENV=test sequelize db:seed:all", + "start:test:db": "npm run test:db:migrate && npm run test:db:seed", + "server-test": "npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000", "postinstall": "node node_modules/gulp/bin/gulp production" }, "repository": { @@ -21,7 +25,9 @@ "homepage": "https://github.com/iakhator/document-manager#readme", "dependencies": { "babel": "^6.23.0", + "babel-core": "^6.25.0", "babel-cli": "^6.24.1", + "babel-plugin-istanbul": "^4.1.4", "babel-preset-es2015": "^6.24.1", "bcrypt": "^1.0.2", "body-parser": "^1.17.2", @@ -31,11 +37,12 @@ "eslint-plugin-import": "^2.7.0", "express": "^4.15.3", "express-validator": "^3.2.1", + "faker": "^4.1.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", - "gulp-nodemon": "^2.2.1", "gulp-mocha": "^4.3.1", + "gulp-nodemon": "^2.2.1", "jsonwebtoken": "^7.4.1", "mocha": "^3.4.2", "morgan": "^1.8.2", @@ -52,11 +59,15 @@ "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", "eslint-plugin-import": "^2.7.0", + "faker": "^4.1.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-load-plugins": "^1.5.0", "gulp-mocha": "^4.3.1", "gulp-nodemon": "^2.2.1", - "mocha": "^3.4.2" + "mocha": "^3.4.2", + "node-mocks-http": "^1.6.4", + "nyc": "^11.0.3", + "supertest": "^3.0.0" } } diff --git a/server/controllers/roles.js b/server/controllers/roles.js index c2e4cb7..50a27af 100644 --- a/server/controllers/roles.js +++ b/server/controllers/roles.js @@ -54,16 +54,22 @@ function getRoles(req, res) { * @returns {object} - role found by id */ function findRole(req, res) { - return Role - .findById(req.params.id) - .then((role) => { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(error => res.status(400).json(error)); + if (isNaN(req.params.id)) { + return res.status(401).json({ + message: `invalid input syntax for integer: "${req.params.id}"` + }); + } else { + Role + .findById(req.params.id) + .then((role) => { + if (!role) { + return res.status(404).json({ + message: 'Role not found' + }); + } + res.status(200).json(role); + }).catch(error => res.status(400).json(error)); + } } /** diff --git a/server/controllers/users.js b/server/controllers/users.js index 9bb38be..ec56859 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -54,30 +54,26 @@ function createUser(req, res) { if (errors) { res.status(400).json({ errors }); } else { - bcrypt.genSalt(10, (err, salt) => { - bcrypt.hash(req.body.password, salt, (err, hash) => { - User.findAll({ - where: { email: req.body.email } - }).then((err, user) => { - if (!user) { - User.create({ - fullName: req.body.fullName, - userName: req.body.userName, - email: req.body.email, - password: hash, - roleId: req.body.roleId || 2 - }).then((userDetails) => { - res.status(200).json({ - userDetails, - success: 'ok', - message: 'You have successfully registered.' - }); - }).catch((error) => { - res.status(400).json(error); - }); - } + User.findAll({ + where: { email: req.body.email } + }).then((err, user) => { + if (!user) { + User.create({ + fullName: req.body.fullName, + userName: req.body.userName, + email: req.body.email, + password: bcrypt.hashSync(req.body.password, bcrypt.genSaltSync(10)), + roleId: req.body.roleId || 2 + }).then((userDetails) => { + res.status(200).json({ + userDetails, + success: true, + message: 'You have successfully registered.' + }); + }).catch((error) => { + res.status(400).json(error); }); - }); + } }); } } @@ -108,32 +104,28 @@ function login(req, res) { success: false, message: 'Authentication failed. User not found.' }); } else if (existingUser) { - bcrypt - .compare(req.body.password, existingUser.password, (err, result) => { - if (err) throw err; - if (result) { - const payLoad = ( - { - email: existingUser.email, - id: existingUser.id, - fullName: existingUser.fullName, - roleId: existingUser.roleId, - } - ); - const token = jwt.sign(payLoad, jwtSecret, { - expiresIn: 60 * 60 * 24 - }); - res.status(201).json({ - success: true, - token, - }); - } else { - res.status(401).json({ - success: false, - message: 'Authentication failed. Wrong password.' - }); - } - }); + if (bcrypt.compareSync(req.body.password, existingUser.password)) { + const payLoad = ( + { + email: existingUser.email, + id: existingUser.id, + fullName: existingUser.fullName, + roleId: existingUser.roleId, + } + ); + const token = jwt.sign(payLoad, jwtSecret, { + expiresIn: 60 * 60 * 24 + }); + res.status(201).json({ + success: true, + token, + }); + } else { + res.status(401).json({ + success: false, + message: 'Authentication failed. Wrong password.' + }); + } } }).catch(error => res.status(400).send(error)); } @@ -152,6 +144,11 @@ function findUser(req, res) { message: 'Unauthorized Access' }); } + if (isNaN(userQuery)) { + return res.status(401).json({ + message: `invalid input syntax for integer: "${req.params.id}"` + }); + } return User .findAll({ where: { diff --git a/server/models/user.js b/server/models/user.js index 437c1f3..db5c6f1 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,4 +1,3 @@ - module.exports = (sequelize, DataTypes) => { const User = sequelize.define('User', { fullName: { diff --git a/server/seeders/20170727152600-sample-roles.js b/server/seeders/20170727152600-sample-roles.js new file mode 100644 index 0000000..68f04ea --- /dev/null +++ b/server/seeders/20170727152600-sample-roles.js @@ -0,0 +1,18 @@ +module.exports = { + up: queryInterface => + queryInterface.bulkInsert('Roles', [{ + title: 'admin', + createdAt: new Date(), + updatedAt: new Date(), + }, { + title: 'facilitator', + createdAt: new Date(), + updatedAt: new Date(), + }, { + title: 'fellow', + createdAt: new Date(), + updatedAt: new Date(), + }], {}), + + down: queryInterface => queryInterface.bulkDelete('Roles', null, {}) +}; diff --git a/server/seeders/20170727153559-sample-users.js b/server/seeders/20170727153559-sample-users.js new file mode 100644 index 0000000..dc6ef04 --- /dev/null +++ b/server/seeders/20170727153559-sample-users.js @@ -0,0 +1,34 @@ +const bcrypt = require('bcrypt'); +require('dotenv').config(); + +module.exports = { + up: queryInterface => + queryInterface.bulkInsert('Users', [{ + userName: 'bank', + fullName: 'Baas Bank', + email: 'baas@test.com', + password: bcrypt.hashSync(process.env.TEST_ADMIN_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 1, + createdAt: new Date(), + updatedAt: new Date(), + }, { + userName: 'john', + fullName: 'John Bosco', + email: 'john@test.com', + password: bcrypt.hashSync(process.env.TEST_FELLOW_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 2, + createdAt: new Date(), + updatedAt: new Date(), + }, { + userName: 'blessing', + fullName: 'Blessing Philip', + email: 'blessing@test.com', + password: bcrypt.hashSync(process.env.TEST_FACILITATOR_PASSWORD, bcrypt.genSaltSync(10)), + roleId: 3, + createdAt: new Date(), + updatedAt: new Date(), + } + ], {}), + + down: queryInterface => queryInterface.bulkDelete('Users', null, {}) +}; diff --git a/server/seeders/20170727153641-sample-documents.js b/server/seeders/20170727153641-sample-documents.js new file mode 100644 index 0000000..38a5e71 --- /dev/null +++ b/server/seeders/20170727153641-sample-documents.js @@ -0,0 +1,28 @@ +module.exports = { + up: (queryInterface, Sequelize) => queryInterface.bulkInsert('Documents', [{ + title: 'John Doe', + content: 'eze goes to school', + access: 'public', + userId: 2, + createdAt: new Date(), + updatedAt: new Date(), + }, + { + title: 'John naddddd', + content: 'John watches american gods regularly', + access: 'private', + userId: 2, + createdAt: new Date(), + updatedAt: new Date(), + }, { + title: 'James Hannn', + content: 'Han is a bad guy', + access: 'role', + userId: 2, + createdAt: new Date(), + updatedAt: new Date(), + } + ], {}), + + down: (queryInterface, Sequelize) => queryInterface.bulkDelete('Documents', null, {}) +}; diff --git a/server/test/document.spec.js b/server/test/document.spec.js new file mode 100644 index 0000000..cc2593c --- /dev/null +++ b/server/test/document.spec.js @@ -0,0 +1,362 @@ +import chai from 'chai'; +import request from 'supertest'; +import http from 'chai-http'; +import server from '../../index'; +import models from '../models'; +import data from './mockData'; + +const expect = chai.expect; +chai.use(http); +let userToken, adminToken, sampleUserToken; +const { admin, fellow } = data; + +describe('Documents', () => { + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(admin) + .end((err, res) => { + adminToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(fellow) + .end((err, res) => { + userToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send({ email: 'blessing@test.com', password: 'pass123' }) + .end((err, res) => { + sampleUserToken = res.body.token; + done(); + }); + }); + after((done) => { + models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST Document', () => { + it('should add a new document if the user is authenticated', (done) => { + const document = { + title: 'boromir-team', + content: 'Andela is really awesome!!!', + access: 'public', + userId: 2, + }; + request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.property('id'); + expect(res.body.title).to.eql('boromir-team'); + expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + + it('Should fail if document already exist', () => { + const document = { + title: 'John team', + content: 'eze goes to school', + access: 'public', + }; + request(server) + .post('/api/v1/documents') + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(403); + expect(res.body.message).to.eql('Document already exists'); + }); + }); + it('should fail to add a new document if the user is not authenticated', + (done) => { + const document = { + title: 'boromir-team', + content: 'Andela is really awesome !!!', + value: 'private', + userId: 2, + }; + request(server) + .post('/api/v1/documents') + .send(document) + .end((err, res) => { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + }); + + describe('/GET Documents', () => { + it('Should get all documents for the user that is authenticated', + (done) => { + request(server) + .get('/api/v1/documents') + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['document', 'pagination']); + done(); + }); + }); + it('should fail to get all documents if the user is not authenticated', + (done) => { + request(server) + .get('/api/v1/documents/') + .end((err, res) => { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).be.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get all documents with correct limit as a query', (done) => { + const limit = 1; + request(server) + .get(`/api/v1/documents?limit=${limit}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + it('Should get all documents with correct offset as a query', (done) => { + const offset = 0; + request(server) + .get(`/api/v1/documents?limit=${offset}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + }); + + describe('/GET/:id Document', () => { + it('Should fail to get document if it doesn`t exist', (done) => { + const documentId = 8; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + it('Should get all public regardless of id', (done) => { + const documentId = 4; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(4); + expect(res.body.title).to.equal('boromir-team'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + it('Should fail to get a private document if the requester does not own it', + (done) => { + const documentId = 2; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: sampleUserToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a private document the where the requester is the owner', + (done) => { + const documentId = 2; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.access).to.eql('private'); + expect(res.body.title).to.eql('John naddddd'); + expect(res.body.id).to.eql(2); + expect(res.body.userId).to.eql(2); + done(); + }); + }); + it('Should fail get a role document if the users are not on the same role', + (done) => { + const documentId = 3; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: sampleUserToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a role document if the users are on the same role', + (done) => { + const documentId = 3; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + done(); + }); + }); + it('Should get a role document if the user is an admin', (done) => { + const documentId = 3; + request(server) + .get(`/api/v1/documents/${documentId}/`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + }); + done(); + }); + }); + + describe('/PUT/:id, Document', () => { + it('Should update a document by id if the user has the same id', + (done) => { + const id = 2; + request(server) + .put(`/api/v1/documents/${id}`) + .set({ authorization: userToken }) + .send({ title: 'wreck it ralph' }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.title).to.eql('wreck it ralph'); + done(); + }); + }); + it(`Should fail to update a document by + id if the user does not have the same id`, + (done) => { + const id = 2; + request(server) + .put(`/api/v1/documents/${id}`) + .set({ authorization: sampleUserToken }) + .send({ title: 'spiderman Homecoming' }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to edit this document'); + done(); + }); + }); + it('Should not update a document by id if the user has admin access', + (done) => { + const id = 2; + request(server) + .put(`/api/v1/documents/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'wreck it' }) + .end((err, res) => { + expect(res.status).to.equal(401); + done(); + }); + }); + it('Should fail to update a document by id if the document does not exist', + (done) => { + const id = 10; + request(server) + .put(`/api/v1/documents/${id}`) + .set({ authorization: userToken }) + .send({ title: 'Deadpool' }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document Not Found'); + done(); + }); + }); + }); + + describe('DELETE/:id Document', () => { + it('Should delete a document if the user has admin access', (done) => { + const id = 3; + request(server) + .delete(`/api/v1/documents/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should delete a document if the user is the owner', (done) => { + const id = 2; + request(server) + .delete(`/api/v1/documents/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete the document given the user is not the owner', + (done) => { + const id = 1; + chai.request(server) + .delete(`/api/v1/documents/${id}`) + .set({ authorization: sampleUserToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to delete this document'); + done(); + }); + }); + it('Should fail to delete if the document does not exist', (done) => { + const id = 234; + chai.request(server) + .delete(`/api/v1/documents/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + }); +}); diff --git a/server/test/index.spec.js b/server/test/index.spec.js deleted file mode 100644 index 6550627..0000000 --- a/server/test/index.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -process.env.NODE_ENV = 'test'; -const chai = require('chai'); -const chaiHttp = require('chai-http'); -const server = require('../../index'); - -let expect = chai.expect(); - -chai.use(chaiHttp); diff --git a/server/test/mockData.js b/server/test/mockData.js new file mode 100644 index 0000000..9187d80 --- /dev/null +++ b/server/test/mockData.js @@ -0,0 +1,44 @@ +import dotenv from 'dotenv'; + +dotenv.config(); + +export default { + admin: { + email: 'baas@test.com', + password: process.env.TEST_ADMIN_PASSWORD + }, + fellow: { + email: 'john@test.com', + password: process.env.TEST_FELLOW_PASSWORD + }, + faciliatator: { + email: 'blessing@test.com', + password: process.env.TEST_FACILITATOR_PASSWORD + }, + user2: { + email: 'baas@test.com', + password: 'test' + }, + user1: { + email: 'test@test123.com', + password: 'test' + }, + fakeBass: { + fullName: 'Baasbank Adams', + userName: 'tiaandela', + email: 'name@example.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, + fakeUserDetails: { + fullName: 'Daniel Cfh', + userName: 'cfh', + email: 'cfh@example.com', + password: 'pass123', + roleId: 2, + createdAt: 'date', + updatedAt: new Date() + }, +}; diff --git a/server/test/role.spec.js b/server/test/role.spec.js new file mode 100644 index 0000000..f74a6d2 --- /dev/null +++ b/server/test/role.spec.js @@ -0,0 +1,309 @@ +import chai from 'chai'; +import request from 'supertest'; +import http from 'chai-http'; +import server from '../../index'; +import models from '../models'; +import data from './mockData'; + +const expect = chai.expect; +chai.use(http); +let userToken, adminToken, sampleUserToken; +const { admin, fellow } = data; + +describe('Roles', () => { + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(admin) + .end((err, res) => { + adminToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(fellow) + .end((err, res) => { + userToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send({ email: 'blessing@test.com', password: 'pass123' }) + .end((err, res) => { + sampleUserToken = res.body.token; + done(); + }); + }); + after((done) => { + models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST Role', () => { + it('should add a new role if the user is an admin', (done) => { + request(server) + .post('/api/v1/roles') + .send({ title: 'boromir' }) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + expect(res.body.role).to.have.property('title').to.equal('boromir'); + }); + done(); + }); + it('should add a new role if the user is an admin', (done) => { + request(server) + .post('/api/v1/roles') + .send({ title: 'king' }) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + }); + done(); + }); + it('Should fail if a non-admin wants to add a new role', (done) => { + const role = { + title: 'boromir-team' + }; + request(server) + .post('/api/v1/roles/') + .set({ authorization: userToken }) + .send(role) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should return an error if the title is not a string', (done) => { + chai.request(server) + .post('/api/v1/roles') + .set({ authorization: adminToken }) + .send({ title: 358583 }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Invalid input credentials'); + done(); + }); + }); + }); + + describe('/GET Role', () => { + it('Should get all the roles if the user is an admin', (done) => { + chai.request(server) + .get('/api/v1/roles') + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.have.length(5); + expect(res.body).to.be.a('array'); + expect(res.body[0].id).to.eql(1); + expect(res.body[0].title).to.eql('admin'); + expect(res.body[1].id).to.eql(2); + expect(res.body[1].title).to.eql('facilitator'); + done(); + }); + }); + it('Should fail to get the roles if the user is not admin', (done) => { + chai.request(server) + .get('/api/v1/roles') + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body.message) + .to.eql('You are not authorized'); + done(); + }); + }); + }); + + describe('/GET/:id Role', () => { + it('Should get a role by id if the user is an admin', (done) => { + const id = 2; + chai.request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.title).to.eql('facilitator'); + expect(res.body.id).to.equal(2); + done(); + }); + }); + it('Should fail to get a role by id if the user is not an admin', + (done) => { + const id = 2; + chai.request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get a role by id if the user enters an invalid input', + (done) => { + const id = 'fddjsdcdjn'; + chai.request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body.message) + .to.eql(`invalid input syntax for integer: "${id}"`); + done(); + }); + }); + it('Should fail to get a role by id if the role does not exist', (done) => { + const id = 250; + chai.request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body.message).to.eql('Role not found'); + done(); + }); + }); + it('Should fail to get a role by id if the id is out of range', (done) => { + const id = 500000000000000000000; + chai.request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body.message) + .to.eql(`value "${id}" is out of range for type integer`); + done(); + }); + }); + }); + describe('/PUT/:id Role', () => { + it('Should update a role by id if the user has admin access', (done) => { + const id = 2; + chai.request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'boromir-team' }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role updated successfully'); + expect(res.body).to.have.property('role'); + done(); + }); + }); + it('Should fail to update a role by id if the user has no admin access', + (done) => { + const id = 2; + chai.request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: userToken }) + .send({ title: 'kiba' }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it(`Should fail to update a + role by id if the admin enters an invalid input`, + (done) => { + const id = 200; + chai.request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'kiba' }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it(`Should fail to update a role by + id if the admin enters an id that is out range`, + (done) => { + const id = 2000000000000000; + chai.request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'regular' }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql(`value "${id}" is out of range for type integer`); + done(); + }); + }); + }); + describe('/DELETE/:id Role', () => { + it('Should delete a role given the user has admin access', (done) => { + const id = 3; + chai.request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + }); + done(); + }); + it('Should fail to delete a role given the user has no admin access', + (done) => { + const id = 3; + chai.request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to delete a role given the admin enters an invalid input', + (done) => { + const id = 300; + chai.request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it(`Should fail to delete a role given + the admin enters an input that is out of range`, (done) => { + const id = 3000000000000000; + chai.request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql(`value "${id}" is out of range for type integer`); + done(); + }); + }); + }); +}); diff --git a/server/test/search.spec.js b/server/test/search.spec.js new file mode 100644 index 0000000..e65520a --- /dev/null +++ b/server/test/search.spec.js @@ -0,0 +1,107 @@ +import chai from 'chai'; +import request from 'supertest'; +import http from 'chai-http'; +import server from '../../index'; +import models from '../models'; +import data from './mockData'; + +const expect = chai.expect; +chai.use(http); +let userToken, adminToken, sampleUserToke; +const { admin, fellow } = data; + +describe('Users', () => { + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(admin) + .end((err, res) => { + adminToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(fellow) + .end((err, res) => { + userToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send({ email: 'blessing@test.com', password: 'pass123' }) + .end((err, res) => { + sampleUserToken = res.body.token; + done(); + }); + }); + after((done) => { + models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + + describe('/SEARCH/users/?q={name}', () => { + it('Should return an error if no querystring is provided', () => { + const query = ''; + request(server) + .get(`/api/v1/search/users/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('Inval search input'); + }); + }); + it('Should return a search list response of the required search input', + () => { + const query = 'jame'; + request(server) + .get(`/api/v1/search/users/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body.fullName).to.eql('jame doe'); + expect(res.body.userName).to.eql('testdoe'); + }); + }); + }); + describe('/SEARCH/documents/?q=', () => { + it('Should return an error if no querystring is provided', () => { + const query = ''; + request(server) + .get(`/api/v1/search/document/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message').to.equal('Invalid search input') + }); + }); + it('Should return a search list of the required search input', () => { + const query = 'John'; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.have.property('document'); + expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); + expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); + expect(res.body).to.have.property('pagination'); + expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + }); + }); + it('Should throw an error if the searched document is not found', () => { + const query = 'jk'; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.have.property('message').to.equal('Document not found'); + }); + }); + }); +}); diff --git a/server/test/user.spec.js b/server/test/user.spec.js new file mode 100644 index 0000000..1b6f2e3 --- /dev/null +++ b/server/test/user.spec.js @@ -0,0 +1,394 @@ +import chai from 'chai'; +import request from 'supertest'; +import http from 'chai-http'; +import server from '../../index'; +import models from '../models'; +import data from './mockData'; + +const expect = chai.expect; +chai.use(http); +let userToken, adminToken, sampleUserToken; +const { admin, fakeBass, fellow, user1, user2 } = data; + +describe('Users', () => { + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(admin) + .end((err, res) => { + adminToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send(fellow) + .end((err, res) => { + userToken = res.body.token; + done(); + }); + }); + before((done) => { + request(server) + .post('/api/v1/users/login') + .send({ email: 'blessing@test.com', password: 'pass123' }) + .end((err, res) => { + sampleUserToken = res.body.token; + done(); + }); + }); + after((done) => { + models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); + done(); + }); + + describe('/POST User login', () => { + it('Should fail if the user enters incorrect crendentials upon login', + (done) => { + request(server) + .post('/api/v1/users/login') + .send(user1) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message) + .to.eql('Authentication failed. User not found.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('Should fail if the user provide a wrong password', (done) => { + request(server) + .post('/api/v1/users/login') + .send(user2) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message) + .to.eql('Authentication failed. Wrong password.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('should log in a user and return a token', (done) => { + request(server) + .post('/api/v1/users/login').send(admin).end((err, res) => { + expect(res.status).to.equal(201); + expect(res.body).to.have.keys(['success', 'token']); + expect(res.body.success).to.eql(true); + done(); + }); + }); + + describe('/POST User Signup', () => { + it('should create a new user', (done) => { + request(server) + .post('/api/v1/users/').send(fakeBass).end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body) + .to.have.keys(['message', 'success', 'userDetails']); + expect(res.body.success).to.eql(true); + expect(res.body.message) + .to.eql('You have successfully registered.'); + done(); + }); + }); + }); + + describe('#GET Users', () => { + it('Should get all users if the user is an admin ', (done) => { + request(server) + .get('/api/v1/users') + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['user', 'pagination']); + done(); + }); + }); + it('Should fail to get all users if the user has no admin access ', + (done) => { + request(server) + .get('/api/v1/users') + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get all users if no token was provided', (done) => { + request(server) + .get('/api/v1/users') + .end((err, res) => { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + it('Should get all users with correct limit as a query', (done) => { + const limit = 1; + chai.request(server) + .get(`/api/v1/users?limit=${limit}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.user[0].fullName).to.equal('Baas Bank'); + expect(res.body.user[0].userName).to.equal('bank'); + done(); + }); + }); + }); + describe('#GET User by Id', () => { + it('Should get a user if the user is an admin', (done) => { + const id = 2; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).to.eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should get the user if the requested user is the current user', + (done) => { + const id = 2; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should fail to get a user if an invalid input is entered', + (done) => { + const id = 'fddjsdcdjn'; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.have.property('message') + .to.eql(`invalid input syntax for integer: "${id}"`); + done(); + }); + }); + it('should fail to get the user if the requester is not the owner', + (done) => { + const id = 2; + request(server) + .get(`api/users/${id}`) + .set({ authorization: sampleUserToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message']); + expect(res.body.message).to.eql('Unauthorized access'); + }); + done(); + }); + it('Should fail to get a user if the user does not exist', + (done) => { + const id = 250; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.have.property('message'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + it('Should fail to get a user if the id is out of range', + (done) => { + const id = 500000000000000000; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message') + .to.equal(`value "${id}" is out of range for type integer`); + done(); + }); + }); + }); + describe('#PUT Update user by Id', () => { + it('Should update a user`s full name if the user has the same id', + (done) => { + const id = 2; + request(server) + .put(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .send({ fullName: 'jake doe' }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.fullName).to.eql('jake doe'); + done(); + }); + }); + it('Should update a user`s email if the user has the same id', (done) => { + const id = 2; + request(server) + .put(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .send({ email: 'jakedoe@andela.com' }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.email).to.eql('jakedoe@andela.com'); + done(); + }); + }); + it('Should update a user`s username if the user has the same id', + (done) => { + const id = 2; + request(server) + .put(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .send({ userName: 'jakedoe12' }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.userName).to.eql('jakedoe12'); + done(); + }); + }); + it(`Should fail to update a user's + details if the user does not have the same user id`, + (done) => { + const id = 3; + request(server) + .put(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .send({ email: 'jakedoe@andela.com' }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to access this user'); + done(); + }); + }); + it(`Should fail to update a user's + details if the user enters an invalid user id`, + (done) => { + const id = 2302; + request(server) + .put(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .send({ email: 'jakedoe@andela.com' }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message) + .to.eql('You are not authorized to access this user'); + done(); + }); + }); + }); + describe('#DELETE /:id Users', () => { + it('Should delete a user given the user has admin access', (done) => { + const id = 3; + request(server) + .delete(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete a user if the user has no admin access', + (done) => { + const id = 3; + request(server) + .delete(`/api/v1/users/${id}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(401); + expect(res.body.message) + .to.eql('You are not authorized to access this field'); + done(); + }); + }); + it('Should give a User not found if user don\'t exist', (done) => { + const id = 23; + request(server) + .delete(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + }); + describe('/GET/users/:id/documents Documents', () => { + it('Should fail to get documents if the user does not exist', (done) => { + const userId = 9; + request(server) + .get(`/api/v1/users/${userId}/documents`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + it('Should fail to get documents if there is no token present', + (done) => { + const userId = 2; + request(server) + .get(`/api/v1/users/${userId}/documents`) + .end((err, res) => { + expect(res.status).to.equal(403); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get documents for the user with its unique userId', (done) => { + const userId = 2; + request(server) + .get(`/api/v1/users/${userId}/documents`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.document[1].userId).to.eql(2); + expect(res.body.document[1].title).to.eql('boromir-team'); + expect(res.body.document[1].content) + .to.eql('Andela is really awesome!!!'); + done(); + }); + }); + }); + }); +}); From c0185931b158c053c12831eb3bb674c4d34abea2 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 30 Jul 2017 09:50:03 +0100 Subject: [PATCH 36/98] feature(testing routes): routes - add document routes for getting a user document - add route for deleting user document [Finishes #149632847] --- .gitignore | 1 + npm-debug.log | 49 ------------------------------------------------- 2 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 npm-debug.log diff --git a/.gitignore b/.gitignore index 6e267fc..dc9a743 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ .DS_Store .env +npm-debug-log diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index dbd7248..0000000 --- a/npm-debug.log +++ /dev/null @@ -1,49 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/bin/node', -1 verbose cli '/usr/local/bin/npm', -1 verbose cli 'run', -1 verbose cli 'server-test' ] -2 info using npm@3.10.10 -3 info using node@v6.10.3 -4 verbose run-script [ 'preserver-test', 'server-test', 'postserver-test' ] -5 info lifecycle document-manager@1.0.0~preserver-test: document-manager@1.0.0 -6 silly lifecycle document-manager@1.0.0~preserver-test: no script for preserver-test, continuing -7 info lifecycle document-manager@1.0.0~server-test: document-manager@1.0.0 -8 verbose lifecycle document-manager@1.0.0~server-test: unsafe-perm in lifecycle true -9 verbose lifecycle document-manager@1.0.0~server-test: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/andeladeveloper/Documents/projects/document-manager/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin -10 verbose lifecycle document-manager@1.0.0~server-test: CWD: /Users/andeladeveloper/Documents/projects/document-manager -11 silly lifecycle document-manager@1.0.0~server-test: Args: [ '-c', -11 silly lifecycle 'npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000' ] -12 silly lifecycle document-manager@1.0.0~server-test: Returned: code: 6 signal: null -13 info lifecycle document-manager@1.0.0~server-test: Failed to exec server-test script -14 verbose stack Error: document-manager@1.0.0 server-test: `npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000` -14 verbose stack Exit status 6 -14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at EventEmitter.emit (events.js:191:7) -14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14) -14 verbose stack at emitTwo (events.js:106:13) -14 verbose stack at ChildProcess.emit (events.js:191:7) -14 verbose stack at maybeClose (internal/child_process.js:886:16) -14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) -15 verbose pkgid document-manager@1.0.0 -16 verbose cwd /Users/andeladeveloper/Documents/projects/document-manager -17 error Darwin 16.6.0 -18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server-test" -19 error node v6.10.3 -20 error npm v3.10.10 -21 error code ELIFECYCLE -22 error document-manager@1.0.0 server-test: `npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000` -22 error Exit status 6 -23 error Failed at the document-manager@1.0.0 server-test script 'npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000'. -23 error Make sure you have the latest version of node.js and npm installed. -23 error If you do, this is most likely a problem with the document-manager package, -23 error not with npm itself. -23 error Tell the author that this fails on your system: -23 error npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000 -23 error You can get information on how to open an issue for this project with: -23 error npm bugs document-manager -23 error Or if that isn't available, you can get their info via: -23 error npm owner ls document-manager -23 error There is likely additional logging output above. -24 verbose exit [ 1, true ] From 2f4cc1652c7ed9d684f9335bbfed04bcacf224d6 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 31 Jul 2017 06:27:23 +0100 Subject: [PATCH 37/98] feature(testing routes): routes - fix failing tests [Finishes #149632847] --- .gitignore | 2 +- .../855b6e7b77bab94604408e7b7434c58a.json | 1 + ... => af900f3c2b7376a2ee4661b3a5b4960c.json} | 0 .../d9387f41d819cd714da6161ea327df8e.json | 1 - coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 14 +- .../document-manager/server/config/index.html | 2 +- .../server/controllers/documents.js.html | 2 +- .../server/controllers/index.html | 28 +- .../server/controllers/roles.js.html | 32 +- .../server/controllers/search.js.html | 2 +- .../server/controllers/users.js.html | 2 +- .../server/helpers/helper.js.html | 2 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 14 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 2 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 2 +- .../server/routes/users.js.html | 2 +- .../test/controllers/document.spec.js.html | 1136 +++++++++++++++ .../server/test/controllers/index.html | 145 ++ .../server/test/controllers/mockData.js.html | 197 +++ .../server/test/controllers/role.spec.js.html | 977 +++++++++++++ .../test/controllers/search.spec.js.html | 377 +++++ .../server/test/controllers/user.spec.js.html | 1232 +++++++++++++++++ .../server/test/document.spec.js.html | 28 +- .../document-manager/server/test/index.html | 70 +- .../server/test/middlewares/auth.spec.js.html | 158 +-- .../server/test/middlewares/index.html | 32 +- .../server/test/mockData.js.html | 2 +- .../server/test/role.spec.js.html | 52 +- .../server/test/search.spec.js.html | 117 +- .../server/test/user.spec.js.html | 26 +- coverage/gulpfile.babel.js.html | 182 +++ coverage/index.html | 44 +- dist/gulpfile.babel.js | 12 +- dist/server/test/document.spec.js | 291 ---- dist/server/test/index.spec.js | 10 - dist/server/test/mockData.js | 54 - dist/server/test/role.spec.js | 245 ---- dist/server/test/search.spec.js | 106 -- dist/server/test/user.spec.js | 314 ----- gulpfile.babel.js | 9 +- package.json | 2 + .../test/{ => controllers}/document.spec.js | 7 +- server/test/{ => controllers}/mockData.js | 0 server/test/{ => controllers}/role.spec.js | 7 +- server/test/{ => controllers}/search.spec.js | 17 +- server/test/{ => controllers}/user.spec.js | 7 +- 59 files changed, 4577 insertions(+), 1413 deletions(-) create mode 100644 .nyc_output/855b6e7b77bab94604408e7b7434c58a.json rename .nyc_output/{761fb25525ac9854b017da3143f5384b.json => af900f3c2b7376a2ee4661b3a5b4960c.json} (100%) delete mode 100644 .nyc_output/d9387f41d819cd714da6161ea327df8e.json create mode 100644 coverage/document-manager/server/test/controllers/document.spec.js.html create mode 100644 coverage/document-manager/server/test/controllers/index.html create mode 100644 coverage/document-manager/server/test/controllers/mockData.js.html create mode 100644 coverage/document-manager/server/test/controllers/role.spec.js.html create mode 100644 coverage/document-manager/server/test/controllers/search.spec.js.html create mode 100644 coverage/document-manager/server/test/controllers/user.spec.js.html create mode 100644 coverage/gulpfile.babel.js.html delete mode 100644 dist/server/test/document.spec.js delete mode 100644 dist/server/test/index.spec.js delete mode 100644 dist/server/test/mockData.js delete mode 100644 dist/server/test/role.spec.js delete mode 100644 dist/server/test/search.spec.js delete mode 100644 dist/server/test/user.spec.js rename server/test/{ => controllers}/document.spec.js (98%) rename server/test/{ => controllers}/mockData.js (100%) rename server/test/{ => controllers}/role.spec.js (98%) rename server/test/{ => controllers}/search.spec.js (91%) rename server/test/{ => controllers}/user.spec.js (98%) diff --git a/.gitignore b/.gitignore index dc9a743..3a70c66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules/ .DS_Store .env -npm-debug-log +npm-debug.log diff --git a/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json b/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json new file mode 100644 index 0000000..3083241 --- /dev/null +++ b/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json @@ -0,0 +1 @@ +{"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/document.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/document.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":13},"end":{"line":31,"column":38}},"18":{"start":{"line":34,"column":0},"end":{"line":283,"column":3}},"19":{"start":{"line":35,"column":2},"end":{"line":40,"column":5}},"20":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"21":{"start":{"line":37,"column":6},"end":{"line":37,"column":34}},"22":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}},"23":{"start":{"line":41,"column":2},"end":{"line":46,"column":5}},"24":{"start":{"line":42,"column":4},"end":{"line":45,"column":7}},"25":{"start":{"line":43,"column":6},"end":{"line":43,"column":33}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":13}},"27":{"start":{"line":47,"column":2},"end":{"line":52,"column":5}},"28":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"29":{"start":{"line":49,"column":6},"end":{"line":49,"column":39}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":13}},"31":{"start":{"line":54,"column":2},"end":{"line":98,"column":5}},"32":{"start":{"line":55,"column":4},"end":{"line":71,"column":7}},"33":{"start":{"line":56,"column":21},"end":{"line":61,"column":7}},"34":{"start":{"line":62,"column":6},"end":{"line":70,"column":9}},"35":{"start":{"line":63,"column":8},"end":{"line":63,"column":41}},"36":{"start":{"line":64,"column":8},"end":{"line":64,"column":43}},"37":{"start":{"line":65,"column":8},"end":{"line":65,"column":48}},"38":{"start":{"line":66,"column":8},"end":{"line":66,"column":54}},"39":{"start":{"line":67,"column":8},"end":{"line":67,"column":71}},"40":{"start":{"line":68,"column":8},"end":{"line":68,"column":51}},"41":{"start":{"line":69,"column":8},"end":{"line":69,"column":15}},"42":{"start":{"line":73,"column":4},"end":{"line":83,"column":7}},"43":{"start":{"line":74,"column":21},"end":{"line":78,"column":7}},"44":{"start":{"line":79,"column":6},"end":{"line":82,"column":9}},"45":{"start":{"line":80,"column":8},"end":{"line":80,"column":41}},"46":{"start":{"line":81,"column":8},"end":{"line":81,"column":67}},"47":{"start":{"line":84,"column":4},"end":{"line":97,"column":7}},"48":{"start":{"line":85,"column":21},"end":{"line":90,"column":7}},"49":{"start":{"line":91,"column":6},"end":{"line":96,"column":9}},"50":{"start":{"line":92,"column":8},"end":{"line":92,"column":41}},"51":{"start":{"line":93,"column":8},"end":{"line":93,"column":43}},"52":{"start":{"line":94,"column":8},"end":{"line":94,"column":62}},"53":{"start":{"line":95,"column":8},"end":{"line":95,"column":15}},"54":{"start":{"line":100,"column":2},"end":{"line":134,"column":5}},"55":{"start":{"line":101,"column":4},"end":{"line":108,"column":7}},"56":{"start":{"line":102,"column":6},"end":{"line":107,"column":9}},"57":{"start":{"line":103,"column":8},"end":{"line":103,"column":41}},"58":{"start":{"line":104,"column":8},"end":{"line":104,"column":43}},"59":{"start":{"line":105,"column":8},"end":{"line":105,"column":66}},"60":{"start":{"line":106,"column":8},"end":{"line":106,"column":15}},"61":{"start":{"line":109,"column":4},"end":{"line":117,"column":7}},"62":{"start":{"line":110,"column":6},"end":{"line":116,"column":9}},"63":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"64":{"start":{"line":112,"column":8},"end":{"line":112,"column":43}},"65":{"start":{"line":113,"column":8},"end":{"line":113,"column":62}},"66":{"start":{"line":114,"column":8},"end":{"line":114,"column":47}},"67":{"start":{"line":115,"column":8},"end":{"line":115,"column":15}},"68":{"start":{"line":118,"column":4},"end":{"line":125,"column":7}},"69":{"start":{"line":119,"column":18},"end":{"line":119,"column":19}},"70":{"start":{"line":120,"column":6},"end":{"line":124,"column":9}},"71":{"start":{"line":121,"column":8},"end":{"line":121,"column":41}},"72":{"start":{"line":122,"column":8},"end":{"line":122,"column":43}},"73":{"start":{"line":123,"column":8},"end":{"line":123,"column":15}},"74":{"start":{"line":126,"column":4},"end":{"line":133,"column":7}},"75":{"start":{"line":127,"column":19},"end":{"line":127,"column":20}},"76":{"start":{"line":128,"column":6},"end":{"line":132,"column":9}},"77":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"78":{"start":{"line":130,"column":8},"end":{"line":130,"column":43}},"79":{"start":{"line":131,"column":8},"end":{"line":131,"column":15}},"80":{"start":{"line":136,"column":2},"end":{"line":209,"column":5}},"81":{"start":{"line":137,"column":4},"end":{"line":145,"column":7}},"82":{"start":{"line":138,"column":23},"end":{"line":138,"column":24}},"83":{"start":{"line":139,"column":6},"end":{"line":144,"column":9}},"84":{"start":{"line":140,"column":8},"end":{"line":140,"column":41}},"85":{"start":{"line":141,"column":8},"end":{"line":141,"column":43}},"86":{"start":{"line":142,"column":8},"end":{"line":142,"column":62}},"87":{"start":{"line":143,"column":8},"end":{"line":143,"column":15}},"88":{"start":{"line":146,"column":4},"end":{"line":156,"column":7}},"89":{"start":{"line":147,"column":23},"end":{"line":147,"column":24}},"90":{"start":{"line":148,"column":6},"end":{"line":155,"column":9}},"91":{"start":{"line":149,"column":8},"end":{"line":149,"column":41}},"92":{"start":{"line":150,"column":8},"end":{"line":150,"column":43}},"93":{"start":{"line":151,"column":8},"end":{"line":151,"column":38}},"94":{"start":{"line":152,"column":8},"end":{"line":152,"column":56}},"95":{"start":{"line":153,"column":8},"end":{"line":153,"column":51}},"96":{"start":{"line":154,"column":8},"end":{"line":154,"column":15}},"97":{"start":{"line":157,"column":4},"end":{"line":165,"column":7}},"98":{"start":{"line":158,"column":23},"end":{"line":158,"column":24}},"99":{"start":{"line":159,"column":6},"end":{"line":164,"column":9}},"100":{"start":{"line":160,"column":8},"end":{"line":160,"column":41}},"101":{"start":{"line":161,"column":8},"end":{"line":161,"column":43}},"102":{"start":{"line":162,"column":8},"end":{"line":162,"column":88}},"103":{"start":{"line":163,"column":8},"end":{"line":163,"column":15}},"104":{"start":{"line":166,"column":4},"end":{"line":177,"column":7}},"105":{"start":{"line":167,"column":23},"end":{"line":167,"column":24}},"106":{"start":{"line":168,"column":6},"end":{"line":176,"column":9}},"107":{"start":{"line":169,"column":8},"end":{"line":169,"column":41}},"108":{"start":{"line":170,"column":8},"end":{"line":170,"column":43}},"109":{"start":{"line":171,"column":8},"end":{"line":171,"column":50}},"110":{"start":{"line":172,"column":8},"end":{"line":172,"column":54}},"111":{"start":{"line":173,"column":8},"end":{"line":173,"column":38}},"112":{"start":{"line":174,"column":8},"end":{"line":174,"column":42}},"113":{"start":{"line":175,"column":8},"end":{"line":175,"column":15}},"114":{"start":{"line":178,"column":4},"end":{"line":186,"column":7}},"115":{"start":{"line":179,"column":23},"end":{"line":179,"column":24}},"116":{"start":{"line":180,"column":6},"end":{"line":185,"column":9}},"117":{"start":{"line":181,"column":8},"end":{"line":181,"column":41}},"118":{"start":{"line":182,"column":8},"end":{"line":182,"column":43}},"119":{"start":{"line":183,"column":8},"end":{"line":183,"column":88}},"120":{"start":{"line":184,"column":8},"end":{"line":184,"column":15}},"121":{"start":{"line":187,"column":4},"end":{"line":197,"column":7}},"122":{"start":{"line":188,"column":23},"end":{"line":188,"column":24}},"123":{"start":{"line":189,"column":6},"end":{"line":196,"column":9}},"124":{"start":{"line":190,"column":8},"end":{"line":190,"column":41}},"125":{"start":{"line":191,"column":8},"end":{"line":191,"column":43}},"126":{"start":{"line":192,"column":8},"end":{"line":192,"column":38}},"127":{"start":{"line":193,"column":8},"end":{"line":193,"column":53}},"128":{"start":{"line":194,"column":8},"end":{"line":194,"column":47}},"129":{"start":{"line":195,"column":8},"end":{"line":195,"column":15}},"130":{"start":{"line":198,"column":4},"end":{"line":208,"column":7}},"131":{"start":{"line":199,"column":23},"end":{"line":199,"column":24}},"132":{"start":{"line":200,"column":6},"end":{"line":206,"column":9}},"133":{"start":{"line":201,"column":8},"end":{"line":201,"column":41}},"134":{"start":{"line":202,"column":8},"end":{"line":202,"column":43}},"135":{"start":{"line":203,"column":8},"end":{"line":203,"column":38}},"136":{"start":{"line":204,"column":8},"end":{"line":204,"column":53}},"137":{"start":{"line":205,"column":8},"end":{"line":205,"column":47}},"138":{"start":{"line":207,"column":6},"end":{"line":207,"column":13}},"139":{"start":{"line":211,"column":2},"end":{"line":247,"column":5}},"140":{"start":{"line":212,"column":4},"end":{"line":221,"column":7}},"141":{"start":{"line":213,"column":15},"end":{"line":213,"column":16}},"142":{"start":{"line":214,"column":6},"end":{"line":220,"column":9}},"143":{"start":{"line":215,"column":8},"end":{"line":215,"column":41}},"144":{"start":{"line":216,"column":8},"end":{"line":216,"column":43}},"145":{"start":{"line":217,"column":8},"end":{"line":217,"column":38}},"146":{"start":{"line":218,"column":8},"end":{"line":218,"column":56}},"147":{"start":{"line":219,"column":8},"end":{"line":219,"column":15}},"148":{"start":{"line":222,"column":4},"end":{"line":230,"column":7}},"149":{"start":{"line":223,"column":15},"end":{"line":223,"column":16}},"150":{"start":{"line":224,"column":6},"end":{"line":229,"column":9}},"151":{"start":{"line":225,"column":8},"end":{"line":225,"column":41}},"152":{"start":{"line":226,"column":8},"end":{"line":226,"column":43}},"153":{"start":{"line":227,"column":8},"end":{"line":227,"column":88}},"154":{"start":{"line":228,"column":8},"end":{"line":228,"column":15}},"155":{"start":{"line":231,"column":4},"end":{"line":237,"column":7}},"156":{"start":{"line":232,"column":15},"end":{"line":232,"column":16}},"157":{"start":{"line":233,"column":6},"end":{"line":236,"column":9}},"158":{"start":{"line":234,"column":8},"end":{"line":234,"column":41}},"159":{"start":{"line":235,"column":8},"end":{"line":235,"column":15}},"160":{"start":{"line":238,"column":4},"end":{"line":246,"column":7}},"161":{"start":{"line":239,"column":15},"end":{"line":239,"column":17}},"162":{"start":{"line":240,"column":6},"end":{"line":245,"column":9}},"163":{"start":{"line":241,"column":8},"end":{"line":241,"column":41}},"164":{"start":{"line":242,"column":8},"end":{"line":242,"column":43}},"165":{"start":{"line":243,"column":8},"end":{"line":243,"column":62}},"166":{"start":{"line":244,"column":8},"end":{"line":244,"column":15}},"167":{"start":{"line":249,"column":2},"end":{"line":282,"column":5}},"168":{"start":{"line":250,"column":4},"end":{"line":256,"column":7}},"169":{"start":{"line":251,"column":15},"end":{"line":251,"column":16}},"170":{"start":{"line":252,"column":6},"end":{"line":255,"column":9}},"171":{"start":{"line":253,"column":8},"end":{"line":253,"column":41}},"172":{"start":{"line":254,"column":8},"end":{"line":254,"column":15}},"173":{"start":{"line":257,"column":4},"end":{"line":263,"column":7}},"174":{"start":{"line":258,"column":15},"end":{"line":258,"column":16}},"175":{"start":{"line":259,"column":6},"end":{"line":262,"column":9}},"176":{"start":{"line":260,"column":8},"end":{"line":260,"column":41}},"177":{"start":{"line":261,"column":8},"end":{"line":261,"column":15}},"178":{"start":{"line":264,"column":4},"end":{"line":272,"column":7}},"179":{"start":{"line":265,"column":15},"end":{"line":265,"column":16}},"180":{"start":{"line":266,"column":6},"end":{"line":271,"column":9}},"181":{"start":{"line":267,"column":8},"end":{"line":267,"column":41}},"182":{"start":{"line":268,"column":8},"end":{"line":268,"column":43}},"183":{"start":{"line":269,"column":8},"end":{"line":269,"column":90}},"184":{"start":{"line":270,"column":8},"end":{"line":270,"column":15}},"185":{"start":{"line":273,"column":4},"end":{"line":281,"column":7}},"186":{"start":{"line":274,"column":15},"end":{"line":274,"column":18}},"187":{"start":{"line":275,"column":6},"end":{"line":280,"column":9}},"188":{"start":{"line":276,"column":8},"end":{"line":276,"column":41}},"189":{"start":{"line":277,"column":8},"end":{"line":277,"column":43}},"190":{"start":{"line":278,"column":8},"end":{"line":278,"column":62}},"191":{"start":{"line":279,"column":8},"end":{"line":279,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":34,"column":22},"end":{"line":34,"column":23}},"loc":{"start":{"line":34,"column":34},"end":{"line":283,"column":1}},"line":34},"2":{"name":"(anonymous_2)","decl":{"start":{"line":35,"column":9},"end":{"line":35,"column":10}},"loc":{"start":{"line":35,"column":25},"end":{"line":40,"column":3}},"line":35},"3":{"name":"(anonymous_3)","decl":{"start":{"line":36,"column":90},"end":{"line":36,"column":91}},"loc":{"start":{"line":36,"column":110},"end":{"line":39,"column":5}},"line":36},"4":{"name":"(anonymous_4)","decl":{"start":{"line":41,"column":9},"end":{"line":41,"column":10}},"loc":{"start":{"line":41,"column":25},"end":{"line":46,"column":3}},"line":41},"5":{"name":"(anonymous_5)","decl":{"start":{"line":42,"column":91},"end":{"line":42,"column":92}},"loc":{"start":{"line":42,"column":111},"end":{"line":45,"column":5}},"line":42},"6":{"name":"(anonymous_6)","decl":{"start":{"line":47,"column":9},"end":{"line":47,"column":10}},"loc":{"start":{"line":47,"column":25},"end":{"line":52,"column":3}},"line":47},"7":{"name":"(anonymous_7)","decl":{"start":{"line":48,"column":136},"end":{"line":48,"column":137}},"loc":{"start":{"line":48,"column":156},"end":{"line":51,"column":5}},"line":48},"8":{"name":"(anonymous_8)","decl":{"start":{"line":54,"column":29},"end":{"line":54,"column":30}},"loc":{"start":{"line":54,"column":41},"end":{"line":98,"column":3}},"line":54},"9":{"name":"(anonymous_9)","decl":{"start":{"line":55,"column":65},"end":{"line":55,"column":66}},"loc":{"start":{"line":55,"column":81},"end":{"line":71,"column":5}},"line":55},"10":{"name":"(anonymous_10)","decl":{"start":{"line":62,"column":127},"end":{"line":62,"column":128}},"loc":{"start":{"line":62,"column":147},"end":{"line":70,"column":7}},"line":62},"11":{"name":"(anonymous_11)","decl":{"start":{"line":73,"column":48},"end":{"line":73,"column":49}},"loc":{"start":{"line":73,"column":60},"end":{"line":83,"column":5}},"line":73},"12":{"name":"(anonymous_12)","decl":{"start":{"line":79,"column":112},"end":{"line":79,"column":113}},"loc":{"start":{"line":79,"column":132},"end":{"line":82,"column":7}},"line":79},"13":{"name":"(anonymous_13)","decl":{"start":{"line":84,"column":77},"end":{"line":84,"column":78}},"loc":{"start":{"line":84,"column":93},"end":{"line":97,"column":5}},"line":84},"14":{"name":"(anonymous_14)","decl":{"start":{"line":91,"column":93},"end":{"line":91,"column":94}},"loc":{"start":{"line":91,"column":113},"end":{"line":96,"column":7}},"line":91},"15":{"name":"(anonymous_15)","decl":{"start":{"line":100,"column":29},"end":{"line":100,"column":30}},"loc":{"start":{"line":100,"column":41},"end":{"line":134,"column":3}},"line":100},"16":{"name":"(anonymous_16)","decl":{"start":{"line":101,"column":70},"end":{"line":101,"column":71}},"loc":{"start":{"line":101,"column":86},"end":{"line":108,"column":5}},"line":101},"17":{"name":"(anonymous_17)","decl":{"start":{"line":102,"column":111},"end":{"line":102,"column":112}},"loc":{"start":{"line":102,"column":131},"end":{"line":107,"column":7}},"line":102},"18":{"name":"(anonymous_18)","decl":{"start":{"line":109,"column":76},"end":{"line":109,"column":77}},"loc":{"start":{"line":109,"column":92},"end":{"line":117,"column":5}},"line":109},"19":{"name":"(anonymous_19)","decl":{"start":{"line":110,"column":78},"end":{"line":110,"column":79}},"loc":{"start":{"line":110,"column":98},"end":{"line":116,"column":7}},"line":110},"20":{"name":"(anonymous_20)","decl":{"start":{"line":118,"column":65},"end":{"line":118,"column":66}},"loc":{"start":{"line":118,"column":81},"end":{"line":125,"column":5}},"line":118},"21":{"name":"(anonymous_21)","decl":{"start":{"line":120,"column":126},"end":{"line":120,"column":127}},"loc":{"start":{"line":120,"column":146},"end":{"line":124,"column":7}},"line":120},"22":{"name":"(anonymous_22)","decl":{"start":{"line":126,"column":66},"end":{"line":126,"column":67}},"loc":{"start":{"line":126,"column":82},"end":{"line":133,"column":5}},"line":126},"23":{"name":"(anonymous_23)","decl":{"start":{"line":128,"column":127},"end":{"line":128,"column":128}},"loc":{"start":{"line":128,"column":147},"end":{"line":132,"column":7}},"line":128},"24":{"name":"(anonymous_24)","decl":{"start":{"line":136,"column":32},"end":{"line":136,"column":33}},"loc":{"start":{"line":136,"column":44},"end":{"line":209,"column":3}},"line":136},"25":{"name":"(anonymous_25)","decl":{"start":{"line":137,"column":58},"end":{"line":137,"column":59}},"loc":{"start":{"line":137,"column":74},"end":{"line":145,"column":5}},"line":137},"26":{"name":"(anonymous_26)","decl":{"start":{"line":139,"column":131},"end":{"line":139,"column":132}},"loc":{"start":{"line":139,"column":151},"end":{"line":144,"column":7}},"line":139},"27":{"name":"(anonymous_27)","decl":{"start":{"line":146,"column":49},"end":{"line":146,"column":50}},"loc":{"start":{"line":146,"column":65},"end":{"line":156,"column":5}},"line":146},"28":{"name":"(anonymous_28)","decl":{"start":{"line":148,"column":131},"end":{"line":148,"column":132}},"loc":{"start":{"line":148,"column":151},"end":{"line":155,"column":7}},"line":148},"29":{"name":"(anonymous_29)","decl":{"start":{"line":157,"column":81},"end":{"line":157,"column":82}},"loc":{"start":{"line":157,"column":97},"end":{"line":165,"column":5}},"line":157},"30":{"name":"(anonymous_30)","decl":{"start":{"line":159,"column":137},"end":{"line":159,"column":138}},"loc":{"start":{"line":159,"column":157},"end":{"line":164,"column":7}},"line":159},"31":{"name":"(anonymous_31)","decl":{"start":{"line":166,"column":77},"end":{"line":166,"column":78}},"loc":{"start":{"line":166,"column":93},"end":{"line":177,"column":5}},"line":166},"32":{"name":"(anonymous_32)","decl":{"start":{"line":168,"column":131},"end":{"line":168,"column":132}},"loc":{"start":{"line":168,"column":151},"end":{"line":176,"column":7}},"line":168},"33":{"name":"(anonymous_33)","decl":{"start":{"line":178,"column":80},"end":{"line":178,"column":81}},"loc":{"start":{"line":178,"column":96},"end":{"line":186,"column":5}},"line":178},"34":{"name":"(anonymous_34)","decl":{"start":{"line":180,"column":137},"end":{"line":180,"column":138}},"loc":{"start":{"line":180,"column":157},"end":{"line":185,"column":7}},"line":180},"35":{"name":"(anonymous_35)","decl":{"start":{"line":187,"column":71},"end":{"line":187,"column":72}},"loc":{"start":{"line":187,"column":87},"end":{"line":197,"column":5}},"line":187},"36":{"name":"(anonymous_36)","decl":{"start":{"line":189,"column":131},"end":{"line":189,"column":132}},"loc":{"start":{"line":189,"column":151},"end":{"line":196,"column":7}},"line":189},"37":{"name":"(anonymous_37)","decl":{"start":{"line":198,"column":61},"end":{"line":198,"column":62}},"loc":{"start":{"line":198,"column":77},"end":{"line":208,"column":5}},"line":198},"38":{"name":"(anonymous_38)","decl":{"start":{"line":200,"column":132},"end":{"line":200,"column":133}},"loc":{"start":{"line":200,"column":152},"end":{"line":206,"column":7}},"line":200},"39":{"name":"(anonymous_39)","decl":{"start":{"line":211,"column":33},"end":{"line":211,"column":34}},"loc":{"start":{"line":211,"column":45},"end":{"line":247,"column":3}},"line":211},"40":{"name":"(anonymous_40)","decl":{"start":{"line":212,"column":69},"end":{"line":212,"column":70}},"loc":{"start":{"line":212,"column":85},"end":{"line":221,"column":5}},"line":212},"41":{"name":"(anonymous_41)","decl":{"start":{"line":214,"column":151},"end":{"line":214,"column":152}},"loc":{"start":{"line":214,"column":171},"end":{"line":220,"column":7}},"line":214},"42":{"name":"(anonymous_42)","decl":{"start":{"line":222,"column":94},"end":{"line":222,"column":95}},"loc":{"start":{"line":222,"column":110},"end":{"line":230,"column":5}},"line":222},"43":{"name":"(anonymous_43)","decl":{"start":{"line":224,"column":163},"end":{"line":224,"column":164}},"loc":{"start":{"line":224,"column":183},"end":{"line":229,"column":7}},"line":224},"44":{"name":"(anonymous_44)","decl":{"start":{"line":231,"column":74},"end":{"line":231,"column":75}},"loc":{"start":{"line":231,"column":90},"end":{"line":237,"column":5}},"line":231},"45":{"name":"(anonymous_45)","decl":{"start":{"line":233,"column":146},"end":{"line":233,"column":147}},"loc":{"start":{"line":233,"column":166},"end":{"line":236,"column":7}},"line":233},"46":{"name":"(anonymous_46)","decl":{"start":{"line":238,"column":80},"end":{"line":238,"column":81}},"loc":{"start":{"line":238,"column":96},"end":{"line":246,"column":5}},"line":238},"47":{"name":"(anonymous_47)","decl":{"start":{"line":240,"column":145},"end":{"line":240,"column":146}},"loc":{"start":{"line":240,"column":165},"end":{"line":245,"column":7}},"line":240},"48":{"name":"(anonymous_48)","decl":{"start":{"line":249,"column":34},"end":{"line":249,"column":35}},"loc":{"start":{"line":249,"column":46},"end":{"line":282,"column":3}},"line":249},"49":{"name":"(anonymous_49)","decl":{"start":{"line":250,"column":64},"end":{"line":250,"column":65}},"loc":{"start":{"line":250,"column":80},"end":{"line":256,"column":5}},"line":250},"50":{"name":"(anonymous_50)","decl":{"start":{"line":252,"column":121},"end":{"line":252,"column":122}},"loc":{"start":{"line":252,"column":141},"end":{"line":255,"column":7}},"line":252},"51":{"name":"(anonymous_51)","decl":{"start":{"line":257,"column":60},"end":{"line":257,"column":61}},"loc":{"start":{"line":257,"column":76},"end":{"line":263,"column":5}},"line":257},"52":{"name":"(anonymous_52)","decl":{"start":{"line":259,"column":120},"end":{"line":259,"column":121}},"loc":{"start":{"line":259,"column":140},"end":{"line":262,"column":7}},"line":259},"53":{"name":"(anonymous_53)","decl":{"start":{"line":264,"column":77},"end":{"line":264,"column":78}},"loc":{"start":{"line":264,"column":93},"end":{"line":272,"column":5}},"line":264},"54":{"name":"(anonymous_54)","decl":{"start":{"line":266,"column":124},"end":{"line":266,"column":125}},"loc":{"start":{"line":266,"column":144},"end":{"line":271,"column":7}},"line":266},"55":{"name":"(anonymous_55)","decl":{"start":{"line":273,"column":63},"end":{"line":273,"column":64}},"loc":{"start":{"line":273,"column":79},"end":{"line":281,"column":5}},"line":273},"56":{"name":"(anonymous_56)","decl":{"start":{"line":275,"column":118},"end":{"line":275,"column":119}},"loc":{"start":{"line":275,"column":138},"end":{"line":280,"column":7}},"line":275}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":0,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":0,"134":0,"135":0,"136":0,"137":0,"138":1,"139":1,"140":1,"141":1,"142":1,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":0,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"10c2204a94869348a88d4e5f4280dce0e208e693","contentHash":"49dba68cdca6874553107612f5b94da3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":49}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"5":{"start":{"line":15,"column":13},"end":{"line":17,"column":2}},"6":{"start":{"line":16,"column":2},"end":{"line":16,"column":63}},"7":{"start":{"line":19,"column":0},"end":{"line":19,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":44},"end":{"line":15,"column":45}},"loc":{"start":{"line":15,"column":56},"end":{"line":17,"column":1}},"line":15}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"type":"binary-expr","locations":[{"start":{"line":13,"column":11},"end":{"line":13,"column":27}},{"start":{"line":13,"column":31},"end":{"line":13,"column":35}}],"line":13}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1},"f":{"0":1,"1":1},"b":{"0":[1,0],"1":[1,1],"2":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"2c3f4d308d6c389ee08f6e68cdad1a35bf84c346","contentHash":"b011e4774c730a6764287d46023c385e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"4":{"start":{"line":13,"column":19},"end":{"line":13,"column":54}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":31}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":24},"end":{"line":19,"column":52}},"8":{"start":{"line":21,"column":25},"end":{"line":21,"column":66}},"9":{"start":{"line":23,"column":14},"end":{"line":23,"column":34}},"10":{"start":{"line":25,"column":15},"end":{"line":25,"column":46}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":10},"end":{"line":29,"column":34}},"13":{"start":{"line":31,"column":0},"end":{"line":31,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":37}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":62}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":43}},"17":{"start":{"line":37,"column":0},"end":{"line":46,"column":3}},"18":{"start":{"line":38,"column":13},"end":{"line":38,"column":21}},"19":{"start":{"line":39,"column":13},"end":{"line":39,"column":18}},"20":{"start":{"line":40,"column":2},"end":{"line":44,"column":4}},"21":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"22":{"start":{"line":41,"column":14},"end":{"line":41,"column":21}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":25}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":16}},"25":{"start":{"line":45,"column":2},"end":{"line":45,"column":9}},"26":{"start":{"line":49,"column":0},"end":{"line":49,"column":37}},"27":{"start":{"line":51,"column":0},"end":{"line":51,"column":22}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":8},"end":{"line":37,"column":9}},"loc":{"start":{"line":37,"column":34},"end":{"line":46,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":13},"end":{"line":40,"column":14}},"loc":{"start":{"line":40,"column":29},"end":{"line":44,"column":3}},"line":40}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27},"2":{"loc":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"type":"if","locations":[{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},{"start":{"line":41,"column":4},"end":{"line":41,"column":21}}],"line":41}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":81,"19":81,"20":81,"21":110,"22":4,"23":106,"24":106,"25":81,"26":1,"27":1},"f":{"0":5,"1":81,"2":110},"b":{"0":[1,4],"1":[5,5],"2":[4,106]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"631ffa56d34b584cfaaf514a9d3aab5ddb9550d2","contentHash":"68477734160cec3adc5d527b8a040a9b_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":31}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":33}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":17},"end":{"line":19,"column":39}},"8":{"start":{"line":21,"column":18},"end":{"line":21,"column":52}},"9":{"start":{"line":23,"column":13},"end":{"line":23,"column":31}},"10":{"start":{"line":25,"column":14},"end":{"line":25,"column":44}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":13},"end":{"line":29,"column":39}},"13":{"start":{"line":32,"column":0},"end":{"line":32,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":40}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":46}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":38}},"17":{"start":{"line":37,"column":0},"end":{"line":37,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1},"f":{"0":5},"b":{"0":[4,1],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"242d65573f043ccce04223bd6f51cdda15503f5f","contentHash":"3a58cb6f4391326b95f0cf67e2d870a0_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":34}},"10":{"start":{"line":30,"column":0},"end":{"line":32,"column":29}},"11":{"start":{"line":34,"column":0},"end":{"line":42,"column":64}},"12":{"start":{"line":44,"column":0},"end":{"line":46,"column":67}},"13":{"start":{"line":48,"column":0},"end":{"line":48,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a4c38addb0d124dbae4b2d5ea8e6e3d38cf94991","contentHash":"b6e317aa7a985adf5a98d45b1aa5fd24_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":20},"end":{"line":11,"column":43}},"4":{"start":{"line":13,"column":21},"end":{"line":13,"column":58}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"8":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"9":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"10":{"start":{"line":25,"column":0},"end":{"line":25,"column":27}},"11":{"start":{"line":27,"column":16},"end":{"line":27,"column":38}},"12":{"start":{"line":28,"column":15},"end":{"line":28,"column":40}},"13":{"start":{"line":29,"column":11},"end":{"line":29,"column":32}},"14":{"start":{"line":30,"column":15},"end":{"line":30,"column":50}},"15":{"start":{"line":39,"column":14},"end":{"line":39,"column":29}},"16":{"start":{"line":40,"column":15},"end":{"line":40,"column":31}},"17":{"start":{"line":41,"column":2},"end":{"line":54,"column":5}},"18":{"start":{"line":45,"column":15},"end":{"line":45,"column":24}},"19":{"start":{"line":46,"column":16},"end":{"line":46,"column":26}},"20":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"21":{"start":{"line":53,"column":4},"end":{"line":53,"column":39}},"22":{"start":{"line":64,"column":2},"end":{"line":64,"column":59}},"23":{"start":{"line":65,"column":2},"end":{"line":65,"column":59}},"24":{"start":{"line":66,"column":2},"end":{"line":66,"column":53}},"25":{"start":{"line":67,"column":2},"end":{"line":67,"column":59}},"26":{"start":{"line":68,"column":2},"end":{"line":68,"column":59}},"27":{"start":{"line":69,"column":2},"end":{"line":69,"column":85}},"28":{"start":{"line":70,"column":15},"end":{"line":70,"column":37}},"29":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"30":{"start":{"line":73,"column":4},"end":{"line":73,"column":45}},"31":{"start":{"line":75,"column":4},"end":{"line":95,"column":7}},"32":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"33":{"start":{"line":79,"column":8},"end":{"line":93,"column":11}},"34":{"start":{"line":86,"column":10},"end":{"line":90,"column":13}},"35":{"start":{"line":92,"column":10},"end":{"line":92,"column":38}},"36":{"start":{"line":106,"column":2},"end":{"line":106,"column":53}},"37":{"start":{"line":107,"column":2},"end":{"line":107,"column":59}},"38":{"start":{"line":108,"column":2},"end":{"line":108,"column":59}},"39":{"start":{"line":110,"column":15},"end":{"line":110,"column":37}},"40":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"41":{"start":{"line":113,"column":4},"end":{"line":113,"column":45}},"42":{"start":{"line":115,"column":4},"end":{"line":147,"column":7}},"43":{"start":{"line":118,"column":25},"end":{"line":118,"column":32}},"44":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"45":{"start":{"line":120,"column":8},"end":{"line":122,"column":63}},"46":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"47":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":125,"column":24},"end":{"line":130,"column":11}},"49":{"start":{"line":131,"column":22},"end":{"line":133,"column":12}},"50":{"start":{"line":134,"column":10},"end":{"line":137,"column":13}},"51":{"start":{"line":139,"column":10},"end":{"line":142,"column":13}},"52":{"start":{"line":146,"column":6},"end":{"line":146,"column":41}},"53":{"start":{"line":158,"column":18},"end":{"line":158,"column":39}},"54":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"55":{"start":{"line":160,"column":4},"end":{"line":162,"column":7}},"56":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"57":{"start":{"line":165,"column":4},"end":{"line":167,"column":7}},"58":{"start":{"line":169,"column":2},"end":{"line":181,"column":5}},"59":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"60":{"start":{"line":176,"column":6},"end":{"line":176,"column":58}},"61":{"start":{"line":178,"column":4},"end":{"line":178,"column":31}},"62":{"start":{"line":180,"column":4},"end":{"line":180,"column":39}},"63":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"64":{"start":{"line":192,"column":4},"end":{"line":194,"column":7}},"65":{"start":{"line":196,"column":15},"end":{"line":196,"column":36}},"66":{"start":{"line":197,"column":2},"end":{"line":225,"column":5}},"67":{"start":{"line":198,"column":4},"end":{"line":224,"column":7}},"68":{"start":{"line":199,"column":6},"end":{"line":223,"column":9}},"69":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"70":{"start":{"line":201,"column":10},"end":{"line":201,"column":69}},"71":{"start":{"line":203,"column":8},"end":{"line":220,"column":11}},"72":{"start":{"line":210,"column":10},"end":{"line":217,"column":13}},"73":{"start":{"line":219,"column":10},"end":{"line":219,"column":45}},"74":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"75":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"76":{"start":{"line":236,"column":4},"end":{"line":238,"column":7}},"77":{"start":{"line":240,"column":2},"end":{"line":252,"column":5}},"78":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"79":{"start":{"line":242,"column":6},"end":{"line":242,"column":65}},"80":{"start":{"line":244,"column":4},"end":{"line":249,"column":7}},"81":{"start":{"line":245,"column":6},"end":{"line":246,"column":57}},"82":{"start":{"line":248,"column":6},"end":{"line":248,"column":41}},"83":{"start":{"line":251,"column":4},"end":{"line":251,"column":39}},"84":{"start":{"line":263,"column":14},"end":{"line":263,"column":29}},"85":{"start":{"line":264,"column":15},"end":{"line":264,"column":31}},"86":{"start":{"line":265,"column":2},"end":{"line":290,"column":5}},"87":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"88":{"start":{"line":267,"column":6},"end":{"line":269,"column":9}},"89":{"start":{"line":271,"column":4},"end":{"line":287,"column":7}},"90":{"start":{"line":278,"column":21},"end":{"line":278,"column":31}},"91":{"start":{"line":279,"column":18},"end":{"line":279,"column":29}},"92":{"start":{"line":281,"column":6},"end":{"line":284,"column":9}},"93":{"start":{"line":286,"column":6},"end":{"line":286,"column":41}},"94":{"start":{"line":289,"column":4},"end":{"line":289,"column":39}},"95":{"start":{"line":293,"column":0},"end":{"line":301,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"getUsers","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":17}},"loc":{"start":{"line":38,"column":28},"end":{"line":55,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":44,"column":10},"end":{"line":44,"column":11}},"loc":{"start":{"line":44,"column":26},"end":{"line":52,"column":3}},"line":44},"3":{"name":"(anonymous_3)","decl":{"start":{"line":52,"column":11},"end":{"line":52,"column":12}},"loc":{"start":{"line":52,"column":28},"end":{"line":54,"column":3}},"line":52},"4":{"name":"createUser","decl":{"start":{"line":63,"column":9},"end":{"line":63,"column":19}},"loc":{"start":{"line":63,"column":30},"end":{"line":97,"column":1}},"line":63},"5":{"name":"(anonymous_5)","decl":{"start":{"line":77,"column":12},"end":{"line":77,"column":13}},"loc":{"start":{"line":77,"column":33},"end":{"line":95,"column":5}},"line":77},"6":{"name":"(anonymous_6)","decl":{"start":{"line":85,"column":16},"end":{"line":85,"column":17}},"loc":{"start":{"line":85,"column":39},"end":{"line":91,"column":9}},"line":85},"7":{"name":"(anonymous_7)","decl":{"start":{"line":91,"column":17},"end":{"line":91,"column":18}},"loc":{"start":{"line":91,"column":34},"end":{"line":93,"column":9}},"line":91},"8":{"name":"login","decl":{"start":{"line":105,"column":9},"end":{"line":105,"column":14}},"loc":{"start":{"line":105,"column":25},"end":{"line":149,"column":1}},"line":105},"9":{"name":"(anonymous_9)","decl":{"start":{"line":117,"column":12},"end":{"line":117,"column":13}},"loc":{"start":{"line":117,"column":28},"end":{"line":145,"column":5}},"line":117},"10":{"name":"(anonymous_10)","decl":{"start":{"line":145,"column":13},"end":{"line":145,"column":14}},"loc":{"start":{"line":145,"column":30},"end":{"line":147,"column":5}},"line":145},"11":{"name":"findUser","decl":{"start":{"line":157,"column":9},"end":{"line":157,"column":17}},"loc":{"start":{"line":157,"column":28},"end":{"line":182,"column":1}},"line":157},"12":{"name":"(anonymous_12)","decl":{"start":{"line":174,"column":10},"end":{"line":174,"column":11}},"loc":{"start":{"line":174,"column":26},"end":{"line":179,"column":3}},"line":174},"13":{"name":"(anonymous_13)","decl":{"start":{"line":179,"column":11},"end":{"line":179,"column":12}},"loc":{"start":{"line":179,"column":28},"end":{"line":181,"column":3}},"line":179},"14":{"name":"updateUser","decl":{"start":{"line":190,"column":9},"end":{"line":190,"column":19}},"loc":{"start":{"line":190,"column":30},"end":{"line":226,"column":1}},"line":190},"15":{"name":"(anonymous_15)","decl":{"start":{"line":197,"column":31},"end":{"line":197,"column":32}},"loc":{"start":{"line":197,"column":52},"end":{"line":225,"column":3}},"line":197},"16":{"name":"(anonymous_16)","decl":{"start":{"line":198,"column":51},"end":{"line":198,"column":52}},"loc":{"start":{"line":198,"column":72},"end":{"line":224,"column":5}},"line":198},"17":{"name":"(anonymous_17)","decl":{"start":{"line":199,"column":33},"end":{"line":199,"column":34}},"loc":{"start":{"line":199,"column":49},"end":{"line":221,"column":7}},"line":199},"18":{"name":"(anonymous_18)","decl":{"start":{"line":209,"column":16},"end":{"line":209,"column":17}},"loc":{"start":{"line":209,"column":39},"end":{"line":218,"column":9}},"line":209},"19":{"name":"(anonymous_19)","decl":{"start":{"line":218,"column":17},"end":{"line":218,"column":18}},"loc":{"start":{"line":218,"column":34},"end":{"line":220,"column":9}},"line":218},"20":{"name":"(anonymous_20)","decl":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"loc":{"start":{"line":221,"column":32},"end":{"line":223,"column":7}},"line":221},"21":{"name":"deleteUser","decl":{"start":{"line":234,"column":9},"end":{"line":234,"column":19}},"loc":{"start":{"line":234,"column":30},"end":{"line":253,"column":1}},"line":234},"22":{"name":"(anonymous_22)","decl":{"start":{"line":240,"column":43},"end":{"line":240,"column":44}},"loc":{"start":{"line":240,"column":59},"end":{"line":250,"column":3}},"line":240},"23":{"name":"(anonymous_23)","decl":{"start":{"line":244,"column":31},"end":{"line":244,"column":32}},"loc":{"start":{"line":244,"column":43},"end":{"line":247,"column":5}},"line":244},"24":{"name":"(anonymous_24)","decl":{"start":{"line":247,"column":13},"end":{"line":247,"column":14}},"loc":{"start":{"line":247,"column":30},"end":{"line":249,"column":5}},"line":247},"25":{"name":"(anonymous_25)","decl":{"start":{"line":250,"column":11},"end":{"line":250,"column":12}},"loc":{"start":{"line":250,"column":28},"end":{"line":252,"column":3}},"line":250},"26":{"name":"getUserDocuments","decl":{"start":{"line":262,"column":9},"end":{"line":262,"column":25}},"loc":{"start":{"line":262,"column":36},"end":{"line":291,"column":1}},"line":262},"27":{"name":"(anonymous_27)","decl":{"start":{"line":265,"column":36},"end":{"line":265,"column":37}},"loc":{"start":{"line":265,"column":52},"end":{"line":288,"column":3}},"line":265},"28":{"name":"(anonymous_28)","decl":{"start":{"line":277,"column":12},"end":{"line":277,"column":13}},"loc":{"start":{"line":277,"column":29},"end":{"line":285,"column":5}},"line":277},"29":{"name":"(anonymous_29)","decl":{"start":{"line":285,"column":13},"end":{"line":285,"column":14}},"loc":{"start":{"line":285,"column":30},"end":{"line":287,"column":5}},"line":285},"30":{"name":"(anonymous_30)","decl":{"start":{"line":288,"column":11},"end":{"line":288,"column":12}},"loc":{"start":{"line":288,"column":28},"end":{"line":290,"column":3}},"line":288}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23},"2":{"loc":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},{"start":{"line":72,"column":2},"end":{"line":96,"column":3}}],"line":72},"3":{"loc":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"type":"if","locations":[{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},{"start":{"line":78,"column":6},"end":{"line":94,"column":7}}],"line":78},"4":{"loc":{"start":{"line":84,"column":18},"end":{"line":84,"column":38}},"type":"binary-expr","locations":[{"start":{"line":84,"column":18},"end":{"line":84,"column":33}},{"start":{"line":84,"column":37},"end":{"line":84,"column":38}}],"line":84},"5":{"loc":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"type":"if","locations":[{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},{"start":{"line":112,"column":2},"end":{"line":148,"column":3}}],"line":112},"6":{"loc":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},{"start":{"line":119,"column":6},"end":{"line":144,"column":7}}],"line":119},"7":{"loc":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},{"start":{"line":123,"column":13},"end":{"line":144,"column":7}}],"line":123},"8":{"loc":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"type":"if","locations":[{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},{"start":{"line":124,"column":8},"end":{"line":143,"column":9}}],"line":124},"9":{"loc":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"type":"if","locations":[{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},{"start":{"line":159,"column":2},"end":{"line":163,"column":3}}],"line":159},"10":{"loc":{"start":{"line":159,"column":6},"end":{"line":159,"column":62}},"type":"binary-expr","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":34}},{"start":{"line":159,"column":38},"end":{"line":159,"column":62}}],"line":159},"11":{"loc":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},{"start":{"line":164,"column":2},"end":{"line":168,"column":3}}],"line":164},"12":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"13":{"loc":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"type":"if","locations":[{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},{"start":{"line":191,"column":2},"end":{"line":195,"column":3}}],"line":191},"14":{"loc":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"type":"if","locations":[{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},{"start":{"line":200,"column":8},"end":{"line":202,"column":9}}],"line":200},"15":{"loc":{"start":{"line":204,"column":20},"end":{"line":204,"column":54}},"type":"binary-expr","locations":[{"start":{"line":204,"column":20},"end":{"line":204,"column":37}},{"start":{"line":204,"column":41},"end":{"line":204,"column":54}}],"line":204},"16":{"loc":{"start":{"line":205,"column":20},"end":{"line":205,"column":54}},"type":"binary-expr","locations":[{"start":{"line":205,"column":20},"end":{"line":205,"column":37}},{"start":{"line":205,"column":41},"end":{"line":205,"column":54}}],"line":205},"17":{"loc":{"start":{"line":206,"column":17},"end":{"line":206,"column":45}},"type":"binary-expr","locations":[{"start":{"line":206,"column":17},"end":{"line":206,"column":31}},{"start":{"line":206,"column":35},"end":{"line":206,"column":45}}],"line":206},"18":{"loc":{"start":{"line":207,"column":20},"end":{"line":207,"column":41}},"type":"binary-expr","locations":[{"start":{"line":207,"column":20},"end":{"line":207,"column":24}},{"start":{"line":207,"column":28},"end":{"line":207,"column":41}}],"line":207},"19":{"loc":{"start":{"line":208,"column":18},"end":{"line":208,"column":48}},"type":"binary-expr","locations":[{"start":{"line":208,"column":18},"end":{"line":208,"column":33}},{"start":{"line":208,"column":37},"end":{"line":208,"column":48}}],"line":208},"20":{"loc":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"type":"if","locations":[{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},{"start":{"line":235,"column":2},"end":{"line":239,"column":3}}],"line":235},"21":{"loc":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},{"start":{"line":241,"column":4},"end":{"line":243,"column":5}}],"line":241},"22":{"loc":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"type":"if","locations":[{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},{"start":{"line":266,"column":4},"end":{"line":270,"column":5}}],"line":266}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":4,"10":1,"11":1,"12":1,"13":1,"14":1,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":0,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":0,"31":1,"32":1,"33":1,"34":1,"35":0,"36":15,"37":15,"38":15,"39":15,"40":15,"41":0,"42":15,"43":15,"44":15,"45":1,"46":14,"47":14,"48":13,"49":13,"50":13,"51":1,"52":0,"53":5,"54":5,"55":0,"56":5,"57":1,"58":4,"59":3,"60":1,"61":3,"62":1,"63":5,"64":2,"65":3,"66":3,"67":3,"68":3,"69":3,"70":0,"71":3,"72":3,"73":0,"74":0,"75":3,"76":1,"77":2,"78":2,"79":1,"80":1,"81":1,"82":0,"83":0,"84":2,"85":2,"86":2,"87":2,"88":1,"89":1,"90":1,"91":1,"92":1,"93":0,"94":0,"95":1},"f":{"0":4,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":15,"9":15,"10":0,"11":5,"12":3,"13":1,"14":5,"15":3,"16":3,"17":3,"18":3,"19":0,"20":0,"21":3,"22":2,"23":1,"24":0,"25":0,"26":2,"27":2,"28":1,"29":0,"30":0},"b":{"0":[0,4],"1":[4,4],"2":[0,1],"3":[1,0],"4":[1,0],"5":[0,15],"6":[1,14],"7":[14,0],"8":[13,1],"9":[0,5],"10":[5,4],"11":[1,4],"12":[1,2],"13":[2,3],"14":[0,3],"15":[3,2],"16":[3,2],"17":[3,2],"18":[3,3],"19":[3,3],"20":[1,2],"21":[1,1],"22":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a873f3a1e83910dd4a7534a9fab6445e85d48e8a","contentHash":"8f158652d1e645800e331a339c32bd94_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":10,"column":1}},"1":{"start":{"line":4,"column":2},"end":{"line":9,"column":4}},"2":{"start":{"line":12,"column":0},"end":{"line":12,"column":55}}},"fnMap":{"0":{"name":"paginationMetaData","decl":{"start":{"line":3,"column":34},"end":{"line":3,"column":52}},"loc":{"start":{"line":3,"column":75},"end":{"line":10,"column":1}},"line":3}},"branchMap":{},"s":{"0":1,"1":6,"2":1},"f":{"0":6},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"4465f4d163a5ad4fee78e39a1eef0f59ca60bcc2","contentHash":"65216cd25fbea3beb9fe0dfec073fc7e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js","statementMap":{"0":{"start":{"line":3,"column":9},"end":{"line":3,"column":22}},"1":{"start":{"line":4,"column":11},"end":{"line":4,"column":26}},"2":{"start":{"line":5,"column":16},"end":{"line":5,"column":36}},"3":{"start":{"line":7,"column":15},"end":{"line":7,"column":45}},"4":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"5":{"start":{"line":9,"column":13},"end":{"line":9,"column":48}},"6":{"start":{"line":11,"column":9},"end":{"line":11,"column":11}},"7":{"start":{"line":13,"column":16},"end":{"line":13,"column":22}},"8":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"9":{"start":{"line":15,"column":2},"end":{"line":15,"column":66}},"10":{"start":{"line":17,"column":2},"end":{"line":17,"column":87}},"11":{"start":{"line":20,"column":0},"end":{"line":25,"column":3}},"12":{"start":{"line":21,"column":2},"end":{"line":21,"column":82}},"13":{"start":{"line":23,"column":14},"end":{"line":23,"column":58}},"14":{"start":{"line":24,"column":2},"end":{"line":24,"column":25}},"15":{"start":{"line":27,"column":0},"end":{"line":31,"column":3}},"16":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"17":{"start":{"line":29,"column":4},"end":{"line":29,"column":32}},"18":{"start":{"line":33,"column":0},"end":{"line":33,"column":25}},"19":{"start":{"line":34,"column":0},"end":{"line":34,"column":25}},"20":{"start":{"line":36,"column":0},"end":{"line":36,"column":20}},"21":{"start":{"line":38,"column":0},"end":{"line":38,"column":25}},"22":{"start":{"line":39,"column":0},"end":{"line":39,"column":25}},"23":{"start":{"line":41,"column":0},"end":{"line":41,"column":20}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":33},"end":{"line":20,"column":34}},"loc":{"start":{"line":20,"column":49},"end":{"line":22,"column":1}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":22,"column":11},"end":{"line":22,"column":12}},"loc":{"start":{"line":22,"column":27},"end":{"line":25,"column":1}},"line":22},"2":{"name":"(anonymous_2)","decl":{"start":{"line":27,"column":24},"end":{"line":27,"column":25}},"loc":{"start":{"line":27,"column":45},"end":{"line":31,"column":1}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"type":"binary-expr","locations":[{"start":{"line":8,"column":10},"end":{"line":8,"column":30}},{"start":{"line":8,"column":34},"end":{"line":8,"column":47}}],"line":8},"1":{"loc":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"type":"if","locations":[{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},{"start":{"line":14,"column":0},"end":{"line":18,"column":1}}],"line":14},"2":{"loc":{"start":{"line":21,"column":9},"end":{"line":21,"column":81}},"type":"binary-expr","locations":[{"start":{"line":21,"column":9},"end":{"line":21,"column":32}},{"start":{"line":21,"column":36},"end":{"line":21,"column":53}},{"start":{"line":21,"column":57},"end":{"line":21,"column":81}}],"line":21},"3":{"loc":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"type":"if","locations":[{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},{"start":{"line":28,"column":2},"end":{"line":30,"column":3}}],"line":28}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":1,"11":1,"12":4,"13":3,"14":3,"15":1,"16":3,"17":3,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1},"f":{"0":4,"1":3,"2":3},"b":{"0":[1,0],"1":[0,1],"2":[4,4,3],"3":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"873e872266ec01d9da7d7ec0d8cff9eeebab65b3","contentHash":"147d2f5ce718f5d34ee69e59b4b18b17_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":27,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a1ab92e502a6f44216fbf97c5e3b416d2cdd1c15","contentHash":"bfdbdb10808231c6b80faf6c05504184_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":30,"column":2}},"1":{"start":{"line":4,"column":17},"end":{"line":22,"column":4}},"2":{"start":{"line":23,"column":2},"end":{"line":28,"column":4}},"3":{"start":{"line":25,"column":4},"end":{"line":27,"column":7}},"4":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":30,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":23,"column":23},"end":{"line":23,"column":24}},"loc":{"start":{"line":23,"column":41},"end":{"line":28,"column":3}},"line":23}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"40f538af399cb910f51ef1c6e4b9fa7626ac8040","contentHash":"ebe8d40228054cd49ad96bbdc1301e25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":18,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":10,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":13,"column":4},"end":{"line":15,"column":7}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":18,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":11,"column":19},"end":{"line":11,"column":20}},"loc":{"start":{"line":11,"column":37},"end":{"line":16,"column":3}},"line":11}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1aba90d94e80bdb0379ea9ddd4c53cf22a593f71","contentHash":"b22cffd605cf93f69a3f2719a0d065e3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":42,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":28,"column":4}},"2":{"start":{"line":29,"column":2},"end":{"line":40,"column":4}},"3":{"start":{"line":31,"column":4},"end":{"line":35,"column":7}},"4":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"5":{"start":{"line":41,"column":2},"end":{"line":41,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":42,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":19},"end":{"line":29,"column":20}},"loc":{"start":{"line":29,"column":37},"end":{"line":40,"column":3}},"line":29}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1296338becccf35da8d16bf6f6a410038393a663","contentHash":"e3e5a8798513104b93e617b86fce0484_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":20},"end":{"line":7,"column":43}},"2":{"start":{"line":9,"column":21},"end":{"line":9,"column":58}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":16},"end":{"line":13,"column":38}},"5":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"6":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"7":{"start":{"line":18,"column":4},"end":{"line":25,"column":7}},"8":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"9":{"start":{"line":20,"column":8},"end":{"line":20,"column":79}},"10":{"start":{"line":22,"column":8},"end":{"line":22,"column":30}},"11":{"start":{"line":23,"column":8},"end":{"line":23,"column":15}},"12":{"start":{"line":27,"column":4},"end":{"line":30,"column":7}},"13":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"14":{"start":{"line":36,"column":4},"end":{"line":36,"column":11}},"15":{"start":{"line":38,"column":4},"end":{"line":40,"column":7}},"16":{"start":{"line":44,"column":0},"end":{"line":44,"column":73}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"verifyToken","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":20}},"loc":{"start":{"line":15,"column":37},"end":{"line":32,"column":1}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":18,"column":52},"end":{"line":18,"column":53}},"loc":{"start":{"line":18,"column":76},"end":{"line":25,"column":5}},"line":18},"3":{"name":"adminAccess","decl":{"start":{"line":34,"column":9},"end":{"line":34,"column":20}},"loc":{"start":{"line":34,"column":37},"end":{"line":42,"column":1}},"line":34}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"type":"binary-expr","locations":[{"start":{"line":16,"column":14},"end":{"line":16,"column":39}},{"start":{"line":16,"column":43},"end":{"line":16,"column":72}}],"line":16},"3":{"loc":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},{"start":{"line":17,"column":2},"end":{"line":31,"column":3}}],"line":17},"4":{"loc":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"type":"if","locations":[{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},{"start":{"line":19,"column":6},"end":{"line":24,"column":7}}],"line":19},"5":{"loc":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},{"start":{"line":35,"column":2},"end":{"line":41,"column":3}}],"line":35}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":64,"6":64,"7":60,"8":60,"9":0,"10":60,"11":60,"12":4,"13":25,"14":15,"15":10,"16":1},"f":{"0":1,"1":64,"2":60,"3":25},"b":{"0":[0,1],"1":[1,1],"2":[64,4],"3":[60,4],"4":[0,60],"5":[15,10]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ecc14d1e97432b8e57f39e5c505683a335fe6c8b","contentHash":"319c6e9c3dd86dee4e26cb1f933899cc_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":46}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":25,"column":90}},"10":{"start":{"line":27,"column":0},"end":{"line":29,"column":95}},"11":{"start":{"line":31,"column":0},"end":{"line":31,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"68b3619793c37e6d78583f4e6d35dc746e22808b","contentHash":"1708591ee5a07428c3cfae7deaa863aa_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":20},"end":{"line":28,"column":31}},"10":{"start":{"line":29,"column":14},"end":{"line":29,"column":29}},"11":{"start":{"line":30,"column":15},"end":{"line":30,"column":31}},"12":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"13":{"start":{"line":32,"column":4},"end":{"line":34,"column":7}},"14":{"start":{"line":36,"column":2},"end":{"line":58,"column":5}},"15":{"start":{"line":46,"column":15},"end":{"line":46,"column":24}},"16":{"start":{"line":47,"column":16},"end":{"line":47,"column":26}},"17":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"18":{"start":{"line":50,"column":6},"end":{"line":50,"column":65}},"19":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"20":{"start":{"line":57,"column":4},"end":{"line":57,"column":39}},"21":{"start":{"line":69,"column":14},"end":{"line":69,"column":29}},"22":{"start":{"line":70,"column":15},"end":{"line":70,"column":31}},"23":{"start":{"line":71,"column":20},"end":{"line":71,"column":31}},"24":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"25":{"start":{"line":73,"column":4},"end":{"line":75,"column":7}},"26":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"27":{"start":{"line":78,"column":4},"end":{"line":106,"column":7}},"28":{"start":{"line":94,"column":21},"end":{"line":94,"column":31}},"29":{"start":{"line":95,"column":18},"end":{"line":95,"column":29}},"30":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"31":{"start":{"line":98,"column":8},"end":{"line":98,"column":64}},"32":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"33":{"start":{"line":105,"column":6},"end":{"line":105,"column":41}},"34":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"35":{"start":{"line":108,"column":4},"end":{"line":140,"column":7}},"36":{"start":{"line":128,"column":21},"end":{"line":128,"column":31}},"37":{"start":{"line":129,"column":18},"end":{"line":129,"column":29}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"39":{"start":{"line":132,"column":8},"end":{"line":132,"column":64}},"40":{"start":{"line":134,"column":6},"end":{"line":137,"column":9}},"41":{"start":{"line":139,"column":6},"end":{"line":139,"column":41}},"42":{"start":{"line":144,"column":0},"end":{"line":144,"column":79}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"searchUser","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":19}},"loc":{"start":{"line":27,"column":30},"end":{"line":59,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":45,"column":10},"end":{"line":45,"column":11}},"loc":{"start":{"line":45,"column":26},"end":{"line":56,"column":3}},"line":45},"3":{"name":"(anonymous_3)","decl":{"start":{"line":56,"column":11},"end":{"line":56,"column":12}},"loc":{"start":{"line":56,"column":28},"end":{"line":58,"column":3}},"line":56},"4":{"name":"searchDocuments","decl":{"start":{"line":68,"column":9},"end":{"line":68,"column":24}},"loc":{"start":{"line":68,"column":35},"end":{"line":142,"column":1}},"line":68},"5":{"name":"(anonymous_5)","decl":{"start":{"line":93,"column":12},"end":{"line":93,"column":13}},"loc":{"start":{"line":93,"column":29},"end":{"line":104,"column":5}},"line":93},"6":{"name":"(anonymous_6)","decl":{"start":{"line":104,"column":13},"end":{"line":104,"column":14}},"loc":{"start":{"line":104,"column":30},"end":{"line":106,"column":5}},"line":104},"7":{"name":"(anonymous_7)","decl":{"start":{"line":127,"column":12},"end":{"line":127,"column":13}},"loc":{"start":{"line":127,"column":29},"end":{"line":138,"column":5}},"line":127},"8":{"name":"(anonymous_8)","decl":{"start":{"line":138,"column":13},"end":{"line":138,"column":14}},"loc":{"start":{"line":138,"column":30},"end":{"line":140,"column":5}},"line":138}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"type":"if","locations":[{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},{"start":{"line":31,"column":2},"end":{"line":35,"column":3}}],"line":31},"3":{"loc":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"type":"if","locations":[{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},{"start":{"line":49,"column":4},"end":{"line":51,"column":5}}],"line":49},"4":{"loc":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},{"start":{"line":72,"column":2},"end":{"line":76,"column":3}}],"line":72},"5":{"loc":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},{"start":{"line":77,"column":2},"end":{"line":141,"column":3}}],"line":77},"6":{"loc":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"type":"if","locations":[{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},{"start":{"line":97,"column":6},"end":{"line":99,"column":7}}],"line":97},"7":{"loc":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},{"start":{"line":107,"column":9},"end":{"line":141,"column":3}}],"line":107},"8":{"loc":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"type":"if","locations":[{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},{"start":{"line":131,"column":6},"end":{"line":133,"column":7}}],"line":131}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,2],"1":[2,2],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"6efc7327907302db1883f00d2862afff115a5da3","contentHash":"50e871939ef4ea62c58b58df2dfa2014_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":17},"end":{"line":11,"column":52}},"4":{"start":{"line":13,"column":18},"end":{"line":13,"column":52}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":70}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":72}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63cb1e0c24d02fe76a86b13384c3b6510a628d08","contentHash":"befe059d51eace8d5b2b154e0976915f_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":2},"end":{"line":28,"column":53}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":57}},"11":{"start":{"line":30,"column":2},"end":{"line":30,"column":59}},"12":{"start":{"line":32,"column":15},"end":{"line":32,"column":37}},"13":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"14":{"start":{"line":35,"column":4},"end":{"line":35,"column":45}},"15":{"start":{"line":37,"column":4},"end":{"line":59,"column":7}},"16":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"17":{"start":{"line":43,"column":8},"end":{"line":52,"column":11}},"18":{"start":{"line":49,"column":10},"end":{"line":49,"column":56}},"19":{"start":{"line":51,"column":10},"end":{"line":51,"column":45}},"20":{"start":{"line":54,"column":6},"end":{"line":56,"column":9}},"21":{"start":{"line":58,"column":6},"end":{"line":58,"column":41}},"22":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"23":{"start":{"line":71,"column":4},"end":{"line":71,"column":27}},"24":{"start":{"line":73,"column":14},"end":{"line":73,"column":35}},"25":{"start":{"line":74,"column":2},"end":{"line":97,"column":5}},"26":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"27":{"start":{"line":76,"column":6},"end":{"line":78,"column":9}},"28":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"29":{"start":{"line":81,"column":6},"end":{"line":83,"column":9}},"30":{"start":{"line":85,"column":4},"end":{"line":94,"column":7}},"31":{"start":{"line":91,"column":6},"end":{"line":91,"column":44}},"32":{"start":{"line":93,"column":6},"end":{"line":93,"column":41}},"33":{"start":{"line":96,"column":4},"end":{"line":96,"column":39}},"34":{"start":{"line":107,"column":14},"end":{"line":107,"column":29}},"35":{"start":{"line":108,"column":15},"end":{"line":108,"column":31}},"36":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"37":{"start":{"line":110,"column":4},"end":{"line":132,"column":7}},"38":{"start":{"line":123,"column":21},"end":{"line":123,"column":30}},"39":{"start":{"line":124,"column":18},"end":{"line":124,"column":28}},"40":{"start":{"line":126,"column":6},"end":{"line":129,"column":9}},"41":{"start":{"line":131,"column":6},"end":{"line":131,"column":41}},"42":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"43":{"start":{"line":134,"column":4},"end":{"line":160,"column":7}},"44":{"start":{"line":151,"column":21},"end":{"line":151,"column":31}},"45":{"start":{"line":152,"column":18},"end":{"line":152,"column":29}},"46":{"start":{"line":154,"column":6},"end":{"line":157,"column":9}},"47":{"start":{"line":159,"column":6},"end":{"line":159,"column":41}},"48":{"start":{"line":171,"column":2},"end":{"line":203,"column":5}},"49":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"50":{"start":{"line":173,"column":6},"end":{"line":173,"column":62}},"51":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"52":{"start":{"line":176,"column":6},"end":{"line":176,"column":22}},"53":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"54":{"start":{"line":179,"column":6},"end":{"line":179,"column":44}},"55":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"56":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"57":{"start":{"line":183,"column":8},"end":{"line":185,"column":11}},"58":{"start":{"line":187,"column":6},"end":{"line":187,"column":44}},"59":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"60":{"start":{"line":190,"column":6},"end":{"line":199,"column":9}},"61":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"62":{"start":{"line":192,"column":10},"end":{"line":194,"column":13}},"63":{"start":{"line":196,"column":8},"end":{"line":196,"column":46}},"64":{"start":{"line":198,"column":8},"end":{"line":198,"column":43}},"65":{"start":{"line":202,"column":4},"end":{"line":202,"column":39}},"66":{"start":{"line":214,"column":2},"end":{"line":230,"column":5}},"67":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"68":{"start":{"line":216,"column":6},"end":{"line":216,"column":62}},"69":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"70":{"start":{"line":219,"column":6},"end":{"line":221,"column":9}},"71":{"start":{"line":223,"column":4},"end":{"line":227,"column":7}},"72":{"start":{"line":224,"column":6},"end":{"line":224,"column":80}},"73":{"start":{"line":226,"column":6},"end":{"line":226,"column":41}},"74":{"start":{"line":229,"column":4},"end":{"line":229,"column":39}},"75":{"start":{"line":233,"column":0},"end":{"line":238,"column":35}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"createDocument","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":23}},"loc":{"start":{"line":27,"column":34},"end":{"line":61,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":41,"column":12},"end":{"line":41,"column":13}},"loc":{"start":{"line":41,"column":32},"end":{"line":57,"column":5}},"line":41},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":16},"end":{"line":48,"column":17}},"loc":{"start":{"line":48,"column":44},"end":{"line":50,"column":9}},"line":48},"4":{"name":"(anonymous_4)","decl":{"start":{"line":50,"column":17},"end":{"line":50,"column":18}},"loc":{"start":{"line":50,"column":34},"end":{"line":52,"column":9}},"line":50},"5":{"name":"(anonymous_5)","decl":{"start":{"line":57,"column":13},"end":{"line":57,"column":14}},"loc":{"start":{"line":57,"column":30},"end":{"line":59,"column":5}},"line":57},"6":{"name":"updateDocument","decl":{"start":{"line":69,"column":9},"end":{"line":69,"column":23}},"loc":{"start":{"line":69,"column":34},"end":{"line":98,"column":1}},"line":69},"7":{"name":"(anonymous_7)","decl":{"start":{"line":74,"column":39},"end":{"line":74,"column":40}},"loc":{"start":{"line":74,"column":59},"end":{"line":95,"column":3}},"line":74},"8":{"name":"(anonymous_8)","decl":{"start":{"line":90,"column":12},"end":{"line":90,"column":13}},"loc":{"start":{"line":90,"column":24},"end":{"line":92,"column":5}},"line":90},"9":{"name":"(anonymous_9)","decl":{"start":{"line":92,"column":13},"end":{"line":92,"column":14}},"loc":{"start":{"line":92,"column":30},"end":{"line":94,"column":5}},"line":92},"10":{"name":"(anonymous_10)","decl":{"start":{"line":95,"column":11},"end":{"line":95,"column":12}},"loc":{"start":{"line":95,"column":28},"end":{"line":97,"column":3}},"line":95},"11":{"name":"getAllDocument","decl":{"start":{"line":106,"column":9},"end":{"line":106,"column":23}},"loc":{"start":{"line":106,"column":34},"end":{"line":162,"column":1}},"line":106},"12":{"name":"(anonymous_12)","decl":{"start":{"line":122,"column":12},"end":{"line":122,"column":13}},"loc":{"start":{"line":122,"column":28},"end":{"line":130,"column":5}},"line":122},"13":{"name":"(anonymous_13)","decl":{"start":{"line":130,"column":13},"end":{"line":130,"column":14}},"loc":{"start":{"line":130,"column":30},"end":{"line":132,"column":5}},"line":130},"14":{"name":"(anonymous_14)","decl":{"start":{"line":150,"column":12},"end":{"line":150,"column":13}},"loc":{"start":{"line":150,"column":29},"end":{"line":158,"column":5}},"line":150},"15":{"name":"(anonymous_15)","decl":{"start":{"line":158,"column":13},"end":{"line":158,"column":14}},"loc":{"start":{"line":158,"column":30},"end":{"line":160,"column":5}},"line":158},"16":{"name":"findDocument","decl":{"start":{"line":170,"column":9},"end":{"line":170,"column":21}},"loc":{"start":{"line":170,"column":32},"end":{"line":204,"column":1}},"line":170},"17":{"name":"(anonymous_17)","decl":{"start":{"line":171,"column":47},"end":{"line":171,"column":48}},"loc":{"start":{"line":171,"column":67},"end":{"line":201,"column":3}},"line":171},"18":{"name":"(anonymous_18)","decl":{"start":{"line":190,"column":66},"end":{"line":190,"column":67}},"loc":{"start":{"line":190,"column":91},"end":{"line":197,"column":7}},"line":190},"19":{"name":"(anonymous_19)","decl":{"start":{"line":197,"column":15},"end":{"line":197,"column":16}},"loc":{"start":{"line":197,"column":32},"end":{"line":199,"column":7}},"line":197},"20":{"name":"(anonymous_20)","decl":{"start":{"line":201,"column":11},"end":{"line":201,"column":12}},"loc":{"start":{"line":201,"column":28},"end":{"line":203,"column":3}},"line":201},"21":{"name":"deleteDocument","decl":{"start":{"line":213,"column":9},"end":{"line":213,"column":23}},"loc":{"start":{"line":213,"column":34},"end":{"line":231,"column":1}},"line":213},"22":{"name":"(anonymous_22)","decl":{"start":{"line":214,"column":47},"end":{"line":214,"column":48}},"loc":{"start":{"line":214,"column":67},"end":{"line":228,"column":3}},"line":214},"23":{"name":"(anonymous_23)","decl":{"start":{"line":223,"column":35},"end":{"line":223,"column":36}},"loc":{"start":{"line":223,"column":47},"end":{"line":225,"column":5}},"line":223},"24":{"name":"(anonymous_24)","decl":{"start":{"line":225,"column":13},"end":{"line":225,"column":14}},"loc":{"start":{"line":225,"column":30},"end":{"line":227,"column":5}},"line":225},"25":{"name":"(anonymous_25)","decl":{"start":{"line":228,"column":11},"end":{"line":228,"column":12}},"loc":{"start":{"line":228,"column":28},"end":{"line":230,"column":3}},"line":228}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},{"start":{"line":34,"column":2},"end":{"line":60,"column":3}}],"line":34},"3":{"loc":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"type":"if","locations":[{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},{"start":{"line":42,"column":6},"end":{"line":53,"column":7}}],"line":42},"4":{"loc":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"type":"if","locations":[{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},{"start":{"line":70,"column":2},"end":{"line":72,"column":3}}],"line":70},"5":{"loc":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},{"start":{"line":75,"column":4},"end":{"line":79,"column":5}}],"line":75},"6":{"loc":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"type":"if","locations":[{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},{"start":{"line":80,"column":4},"end":{"line":84,"column":5}}],"line":80},"7":{"loc":{"start":{"line":86,"column":13},"end":{"line":86,"column":45}},"type":"binary-expr","locations":[{"start":{"line":86,"column":13},"end":{"line":86,"column":27}},{"start":{"line":86,"column":31},"end":{"line":86,"column":45}}],"line":86},"8":{"loc":{"start":{"line":87,"column":15},"end":{"line":87,"column":51}},"type":"binary-expr","locations":[{"start":{"line":87,"column":15},"end":{"line":87,"column":31}},{"start":{"line":87,"column":35},"end":{"line":87,"column":51}}],"line":87},"9":{"loc":{"start":{"line":88,"column":14},"end":{"line":88,"column":47}},"type":"binary-expr","locations":[{"start":{"line":88,"column":14},"end":{"line":88,"column":28}},{"start":{"line":88,"column":32},"end":{"line":88,"column":47}}],"line":88},"10":{"loc":{"start":{"line":89,"column":14},"end":{"line":89,"column":48}},"type":"binary-expr","locations":[{"start":{"line":89,"column":14},"end":{"line":89,"column":29}},{"start":{"line":89,"column":33},"end":{"line":89,"column":48}}],"line":89},"11":{"loc":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},{"start":{"line":109,"column":2},"end":{"line":161,"column":3}}],"line":109},"12":{"loc":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},{"start":{"line":133,"column":9},"end":{"line":161,"column":3}}],"line":133},"13":{"loc":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},{"start":{"line":172,"column":4},"end":{"line":174,"column":5}}],"line":172},"14":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"15":{"loc":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"type":"if","locations":[{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},{"start":{"line":178,"column":4},"end":{"line":180,"column":5}}],"line":178},"16":{"loc":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"type":"if","locations":[{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},{"start":{"line":181,"column":4},"end":{"line":188,"column":5}}],"line":181},"17":{"loc":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"type":"if","locations":[{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},{"start":{"line":182,"column":6},"end":{"line":186,"column":7}}],"line":182},"18":{"loc":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"type":"if","locations":[{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},{"start":{"line":189,"column":4},"end":{"line":200,"column":5}}],"line":189},"19":{"loc":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"type":"if","locations":[{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},{"start":{"line":191,"column":8},"end":{"line":195,"column":9}}],"line":191},"20":{"loc":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"type":"if","locations":[{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},{"start":{"line":215,"column":4},"end":{"line":217,"column":5}}],"line":215},"21":{"loc":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"type":"if","locations":[{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},{"start":{"line":218,"column":4},"end":{"line":222,"column":5}}],"line":218},"22":{"loc":{"start":{"line":218,"column":8},"end":{"line":218,"column":86}},"type":"binary-expr","locations":[{"start":{"line":218,"column":8},"end":{"line":218,"column":32}},{"start":{"line":218,"column":36},"end":{"line":218,"column":86}}],"line":218}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":2,"10":2,"11":2,"12":2,"13":2,"14":1,"15":1,"16":1,"17":1,"18":1,"19":0,"20":0,"21":0,"22":4,"23":0,"24":4,"25":4,"26":4,"27":1,"28":3,"29":2,"30":1,"31":1,"32":0,"33":0,"34":3,"35":3,"36":3,"37":0,"38":0,"39":0,"40":0,"41":0,"42":3,"43":3,"44":3,"45":3,"46":3,"47":0,"48":7,"49":7,"50":1,"51":7,"52":1,"53":6,"54":1,"55":4,"56":2,"57":1,"58":1,"59":2,"60":2,"61":2,"62":1,"63":1,"64":0,"65":1,"66":4,"67":4,"68":1,"69":4,"70":1,"71":2,"72":2,"73":0,"74":1,"75":1},"f":{"0":2,"1":2,"2":1,"3":1,"4":0,"5":0,"6":4,"7":4,"8":1,"9":0,"10":0,"11":3,"12":0,"13":0,"14":3,"15":0,"16":7,"17":7,"18":2,"19":0,"20":1,"21":4,"22":4,"23":2,"24":0,"25":1},"b":{"0":[0,2],"1":[2,2],"2":[1,1],"3":[1,0],"4":[0,4],"5":[1,3],"6":[2,1],"7":[1,0],"8":[1,1],"9":[1,1],"10":[1,1],"11":[0,3],"12":[3,0],"13":[1,6],"14":[1,6],"15":[1,4],"16":[2,2],"17":[1,1],"18":[2,0],"19":[1,1],"20":[1,3],"21":[1,2],"22":[4,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0a4bf26938869e9b89bab568412c349bc1ff0083","contentHash":"deda95ed23abba3b13e7ef198467fe3e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":90}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":92}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63a3e651f707e94ed97ec659690592a0c340c6bd","contentHash":"85e8e83b7f1e99d944d489a44ed72bce_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":6,"column":13},"end":{"line":6,"column":33}},"2":{"start":{"line":8,"column":11},"end":{"line":8,"column":22}},"3":{"start":{"line":17,"column":2},"end":{"line":17,"column":53}},"4":{"start":{"line":19,"column":15},"end":{"line":19,"column":37}},"5":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"6":{"start":{"line":21,"column":4},"end":{"line":21,"column":45}},"7":{"start":{"line":23,"column":4},"end":{"line":40,"column":7}},"8":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"9":{"start":{"line":27,"column":8},"end":{"line":36,"column":11}},"10":{"start":{"line":30,"column":10},"end":{"line":33,"column":13}},"11":{"start":{"line":35,"column":10},"end":{"line":35,"column":33}},"12":{"start":{"line":39,"column":6},"end":{"line":39,"column":29}},"13":{"start":{"line":51,"column":2},"end":{"line":55,"column":5}},"14":{"start":{"line":52,"column":4},"end":{"line":52,"column":38}},"15":{"start":{"line":54,"column":4},"end":{"line":54,"column":27}},"16":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"17":{"start":{"line":66,"column":4},"end":{"line":68,"column":7}},"18":{"start":{"line":70,"column":4},"end":{"line":79,"column":7}},"19":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"20":{"start":{"line":72,"column":8},"end":{"line":74,"column":11}},"21":{"start":{"line":76,"column":6},"end":{"line":76,"column":33}},"22":{"start":{"line":78,"column":6},"end":{"line":78,"column":41}},"23":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"24":{"start":{"line":91,"column":4},"end":{"line":91,"column":90}},"25":{"start":{"line":93,"column":2},"end":{"line":111,"column":5}},"26":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"27":{"start":{"line":95,"column":6},"end":{"line":97,"column":9}},"28":{"start":{"line":99,"column":4},"end":{"line":108,"column":7}},"29":{"start":{"line":102,"column":6},"end":{"line":105,"column":9}},"30":{"start":{"line":107,"column":6},"end":{"line":107,"column":41}},"31":{"start":{"line":110,"column":4},"end":{"line":110,"column":39}},"32":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"33":{"start":{"line":122,"column":4},"end":{"line":122,"column":90}},"34":{"start":{"line":124,"column":2},"end":{"line":139,"column":5}},"35":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"36":{"start":{"line":126,"column":6},"end":{"line":128,"column":9}},"37":{"start":{"line":130,"column":4},"end":{"line":136,"column":7}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":9}},"39":{"start":{"line":135,"column":6},"end":{"line":135,"column":41}},"40":{"start":{"line":138,"column":4},"end":{"line":138,"column":27}},"41":{"start":{"line":142,"column":0},"end":{"line":142,"column":133}}},"fnMap":{"0":{"name":"createRole","decl":{"start":{"line":16,"column":9},"end":{"line":16,"column":19}},"loc":{"start":{"line":16,"column":30},"end":{"line":42,"column":1}},"line":16},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":12},"end":{"line":25,"column":13}},"loc":{"start":{"line":25,"column":41},"end":{"line":38,"column":5}},"line":25},"2":{"name":"(anonymous_2)","decl":{"start":{"line":29,"column":16},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":32},"end":{"line":34,"column":9}},"line":29},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":17},"end":{"line":34,"column":18}},"loc":{"start":{"line":34,"column":34},"end":{"line":36,"column":9}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":38,"column":13},"end":{"line":38,"column":14}},"loc":{"start":{"line":38,"column":30},"end":{"line":40,"column":5}},"line":38},"5":{"name":"getRoles","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":17}},"loc":{"start":{"line":50,"column":28},"end":{"line":56,"column":1}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":29},"end":{"line":51,"column":30}},"loc":{"start":{"line":51,"column":45},"end":{"line":53,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":53,"column":11},"end":{"line":53,"column":12}},"loc":{"start":{"line":53,"column":28},"end":{"line":55,"column":3}},"line":53},"8":{"name":"findRole","decl":{"start":{"line":64,"column":9},"end":{"line":64,"column":17}},"loc":{"start":{"line":64,"column":28},"end":{"line":81,"column":1}},"line":64},"9":{"name":"(anonymous_9)","decl":{"start":{"line":70,"column":38},"end":{"line":70,"column":39}},"loc":{"start":{"line":70,"column":54},"end":{"line":77,"column":5}},"line":70},"10":{"name":"(anonymous_10)","decl":{"start":{"line":77,"column":13},"end":{"line":77,"column":14}},"loc":{"start":{"line":77,"column":30},"end":{"line":79,"column":5}},"line":77},"11":{"name":"updateRole","decl":{"start":{"line":89,"column":9},"end":{"line":89,"column":19}},"loc":{"start":{"line":89,"column":30},"end":{"line":112,"column":1}},"line":89},"12":{"name":"(anonymous_12)","decl":{"start":{"line":93,"column":43},"end":{"line":93,"column":44}},"loc":{"start":{"line":93,"column":59},"end":{"line":109,"column":3}},"line":93},"13":{"name":"(anonymous_13)","decl":{"start":{"line":101,"column":12},"end":{"line":101,"column":13}},"loc":{"start":{"line":101,"column":24},"end":{"line":106,"column":5}},"line":101},"14":{"name":"(anonymous_14)","decl":{"start":{"line":106,"column":13},"end":{"line":106,"column":14}},"loc":{"start":{"line":106,"column":30},"end":{"line":108,"column":5}},"line":106},"15":{"name":"(anonymous_15)","decl":{"start":{"line":109,"column":11},"end":{"line":109,"column":12}},"loc":{"start":{"line":109,"column":28},"end":{"line":111,"column":3}},"line":109},"16":{"name":"deleteRole","decl":{"start":{"line":120,"column":9},"end":{"line":120,"column":19}},"loc":{"start":{"line":120,"column":30},"end":{"line":140,"column":1}},"line":120},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":43},"end":{"line":124,"column":44}},"loc":{"start":{"line":124,"column":59},"end":{"line":137,"column":3}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":130,"column":31},"end":{"line":130,"column":32}},"loc":{"start":{"line":130,"column":43},"end":{"line":134,"column":5}},"line":130},"19":{"name":"(anonymous_19)","decl":{"start":{"line":134,"column":13},"end":{"line":134,"column":14}},"loc":{"start":{"line":134,"column":30},"end":{"line":136,"column":5}},"line":134},"20":{"name":"(anonymous_20)","decl":{"start":{"line":137,"column":11},"end":{"line":137,"column":12}},"loc":{"start":{"line":137,"column":28},"end":{"line":139,"column":3}},"line":137}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},{"start":{"line":20,"column":2},"end":{"line":41,"column":3}}],"line":20},"1":{"loc":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"type":"if","locations":[{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},{"start":{"line":26,"column":6},"end":{"line":37,"column":7}}],"line":26},"2":{"loc":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"type":"if","locations":[{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},{"start":{"line":65,"column":2},"end":{"line":80,"column":3}}],"line":65},"3":{"loc":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"type":"if","locations":[{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},{"start":{"line":71,"column":6},"end":{"line":75,"column":7}}],"line":71},"4":{"loc":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"type":"if","locations":[{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},{"start":{"line":90,"column":2},"end":{"line":92,"column":3}}],"line":90},"5":{"loc":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},{"start":{"line":94,"column":4},"end":{"line":98,"column":5}}],"line":94},"6":{"loc":{"start":{"line":100,"column":13},"end":{"line":100,"column":41}},"type":"binary-expr","locations":[{"start":{"line":100,"column":13},"end":{"line":100,"column":27}},{"start":{"line":100,"column":31},"end":{"line":100,"column":41}}],"line":100},"7":{"loc":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"type":"if","locations":[{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},{"start":{"line":121,"column":2},"end":{"line":123,"column":3}}],"line":121},"8":{"loc":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"type":"if","locations":[{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},{"start":{"line":125,"column":4},"end":{"line":129,"column":5}}],"line":125}},"s":{"0":1,"1":1,"2":1,"3":2,"4":2,"5":2,"6":0,"7":2,"8":2,"9":2,"10":2,"11":0,"12":0,"13":1,"14":1,"15":0,"16":4,"17":1,"18":3,"19":2,"20":1,"21":1,"22":1,"23":3,"24":0,"25":3,"26":2,"27":1,"28":1,"29":1,"30":0,"31":1,"32":3,"33":0,"34":3,"35":2,"36":1,"37":2,"38":0,"39":1,"40":2,"41":1},"f":{"0":2,"1":2,"2":2,"3":0,"4":0,"5":1,"6":1,"7":0,"8":4,"9":2,"10":1,"11":3,"12":2,"13":1,"14":0,"15":1,"16":3,"17":2,"18":0,"19":1,"20":2},"b":{"0":[0,2],"1":[2,0],"2":[1,3],"3":[1,1],"4":[0,3],"5":[1,1],"6":[1,0],"7":[0,3],"8":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"30145fbb54f2bf78417895e538ec3aa77aa3022b","contentHash":"d0043f60ddb6921c54c62da8d1dd2774_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/mockData.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/mockData.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":26}},"5":{"start":{"line":15,"column":0},"end":{"line":54,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1},"b":{"0":[0,1],"1":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d98249d31e680d6d366965e47d10adb45667b660","contentHash":"4139d04232af869ee8cdf30b358efd68_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/role.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/role.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":13},"end":{"line":31,"column":38}},"18":{"start":{"line":34,"column":0},"end":{"line":237,"column":3}},"19":{"start":{"line":35,"column":2},"end":{"line":40,"column":5}},"20":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"21":{"start":{"line":37,"column":6},"end":{"line":37,"column":34}},"22":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}},"23":{"start":{"line":41,"column":2},"end":{"line":46,"column":5}},"24":{"start":{"line":42,"column":4},"end":{"line":45,"column":7}},"25":{"start":{"line":43,"column":6},"end":{"line":43,"column":33}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":13}},"27":{"start":{"line":47,"column":2},"end":{"line":52,"column":5}},"28":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"29":{"start":{"line":49,"column":6},"end":{"line":49,"column":39}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":13}},"31":{"start":{"line":54,"column":2},"end":{"line":93,"column":5}},"32":{"start":{"line":55,"column":4},"end":{"line":64,"column":7}},"33":{"start":{"line":56,"column":6},"end":{"line":62,"column":9}},"34":{"start":{"line":57,"column":8},"end":{"line":57,"column":41}},"35":{"start":{"line":58,"column":8},"end":{"line":58,"column":43}},"36":{"start":{"line":59,"column":8},"end":{"line":59,"column":69}},"37":{"start":{"line":60,"column":8},"end":{"line":60,"column":50}},"38":{"start":{"line":61,"column":8},"end":{"line":61,"column":76}},"39":{"start":{"line":63,"column":6},"end":{"line":63,"column":13}},"40":{"start":{"line":65,"column":4},"end":{"line":73,"column":7}},"41":{"start":{"line":66,"column":6},"end":{"line":71,"column":9}},"42":{"start":{"line":67,"column":8},"end":{"line":67,"column":41}},"43":{"start":{"line":68,"column":8},"end":{"line":68,"column":43}},"44":{"start":{"line":69,"column":8},"end":{"line":69,"column":69}},"45":{"start":{"line":70,"column":8},"end":{"line":70,"column":50}},"46":{"start":{"line":72,"column":6},"end":{"line":72,"column":13}},"47":{"start":{"line":74,"column":4},"end":{"line":84,"column":7}},"48":{"start":{"line":75,"column":17},"end":{"line":77,"column":7}},"49":{"start":{"line":78,"column":6},"end":{"line":83,"column":9}},"50":{"start":{"line":79,"column":8},"end":{"line":79,"column":41}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":43}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":66}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":15}},"54":{"start":{"line":85,"column":4},"end":{"line":92,"column":7}},"55":{"start":{"line":86,"column":6},"end":{"line":91,"column":9}},"56":{"start":{"line":87,"column":8},"end":{"line":87,"column":41}},"57":{"start":{"line":88,"column":8},"end":{"line":88,"column":43}},"58":{"start":{"line":89,"column":8},"end":{"line":89,"column":69}},"59":{"start":{"line":90,"column":8},"end":{"line":90,"column":15}},"60":{"start":{"line":95,"column":2},"end":{"line":115,"column":5}},"61":{"start":{"line":96,"column":4},"end":{"line":107,"column":7}},"62":{"start":{"line":97,"column":6},"end":{"line":106,"column":9}},"63":{"start":{"line":98,"column":8},"end":{"line":98,"column":41}},"64":{"start":{"line":99,"column":8},"end":{"line":99,"column":43}},"65":{"start":{"line":100,"column":8},"end":{"line":100,"column":42}},"66":{"start":{"line":101,"column":8},"end":{"line":101,"column":41}},"67":{"start":{"line":102,"column":8},"end":{"line":102,"column":50}},"68":{"start":{"line":103,"column":8},"end":{"line":103,"column":41}},"69":{"start":{"line":104,"column":8},"end":{"line":104,"column":56}},"70":{"start":{"line":105,"column":8},"end":{"line":105,"column":15}},"71":{"start":{"line":108,"column":4},"end":{"line":114,"column":7}},"72":{"start":{"line":109,"column":6},"end":{"line":113,"column":9}},"73":{"start":{"line":110,"column":8},"end":{"line":110,"column":41}},"74":{"start":{"line":111,"column":8},"end":{"line":111,"column":66}},"75":{"start":{"line":112,"column":8},"end":{"line":112,"column":15}},"76":{"start":{"line":117,"column":2},"end":{"line":160,"column":5}},"77":{"start":{"line":118,"column":4},"end":{"line":127,"column":7}},"78":{"start":{"line":119,"column":15},"end":{"line":119,"column":16}},"79":{"start":{"line":120,"column":6},"end":{"line":126,"column":9}},"80":{"start":{"line":121,"column":8},"end":{"line":121,"column":41}},"81":{"start":{"line":122,"column":8},"end":{"line":122,"column":40}},"82":{"start":{"line":123,"column":8},"end":{"line":123,"column":53}},"83":{"start":{"line":124,"column":8},"end":{"line":124,"column":40}},"84":{"start":{"line":125,"column":8},"end":{"line":125,"column":15}},"85":{"start":{"line":128,"column":4},"end":{"line":135,"column":7}},"86":{"start":{"line":129,"column":15},"end":{"line":129,"column":16}},"87":{"start":{"line":130,"column":6},"end":{"line":134,"column":9}},"88":{"start":{"line":131,"column":8},"end":{"line":131,"column":41}},"89":{"start":{"line":132,"column":8},"end":{"line":132,"column":66}},"90":{"start":{"line":133,"column":8},"end":{"line":133,"column":15}},"91":{"start":{"line":136,"column":4},"end":{"line":143,"column":7}},"92":{"start":{"line":137,"column":15},"end":{"line":137,"column":27}},"93":{"start":{"line":138,"column":6},"end":{"line":142,"column":9}},"94":{"start":{"line":139,"column":8},"end":{"line":139,"column":41}},"95":{"start":{"line":140,"column":8},"end":{"line":140,"column":90}},"96":{"start":{"line":141,"column":8},"end":{"line":141,"column":15}},"97":{"start":{"line":144,"column":4},"end":{"line":151,"column":7}},"98":{"start":{"line":145,"column":15},"end":{"line":145,"column":18}},"99":{"start":{"line":146,"column":6},"end":{"line":150,"column":9}},"100":{"start":{"line":147,"column":8},"end":{"line":147,"column":41}},"101":{"start":{"line":148,"column":8},"end":{"line":148,"column":58}},"102":{"start":{"line":149,"column":8},"end":{"line":149,"column":15}},"103":{"start":{"line":152,"column":4},"end":{"line":159,"column":7}},"104":{"start":{"line":153,"column":15},"end":{"line":153,"column":36}},"105":{"start":{"line":154,"column":6},"end":{"line":158,"column":9}},"106":{"start":{"line":155,"column":8},"end":{"line":155,"column":41}},"107":{"start":{"line":156,"column":8},"end":{"line":156,"column":95}},"108":{"start":{"line":157,"column":8},"end":{"line":157,"column":15}},"109":{"start":{"line":161,"column":2},"end":{"line":199,"column":5}},"110":{"start":{"line":162,"column":4},"end":{"line":171,"column":7}},"111":{"start":{"line":163,"column":15},"end":{"line":163,"column":16}},"112":{"start":{"line":164,"column":6},"end":{"line":170,"column":9}},"113":{"start":{"line":165,"column":8},"end":{"line":165,"column":41}},"114":{"start":{"line":166,"column":8},"end":{"line":166,"column":43}},"115":{"start":{"line":167,"column":8},"end":{"line":167,"column":69}},"116":{"start":{"line":168,"column":8},"end":{"line":168,"column":50}},"117":{"start":{"line":169,"column":8},"end":{"line":169,"column":15}},"118":{"start":{"line":172,"column":4},"end":{"line":180,"column":7}},"119":{"start":{"line":173,"column":15},"end":{"line":173,"column":16}},"120":{"start":{"line":174,"column":6},"end":{"line":179,"column":9}},"121":{"start":{"line":175,"column":8},"end":{"line":175,"column":41}},"122":{"start":{"line":176,"column":8},"end":{"line":176,"column":43}},"123":{"start":{"line":177,"column":8},"end":{"line":177,"column":66}},"124":{"start":{"line":178,"column":8},"end":{"line":178,"column":15}},"125":{"start":{"line":181,"column":4},"end":{"line":189,"column":7}},"126":{"start":{"line":182,"column":15},"end":{"line":182,"column":18}},"127":{"start":{"line":183,"column":6},"end":{"line":188,"column":9}},"128":{"start":{"line":184,"column":8},"end":{"line":184,"column":41}},"129":{"start":{"line":185,"column":8},"end":{"line":185,"column":43}},"130":{"start":{"line":186,"column":8},"end":{"line":186,"column":60}},"131":{"start":{"line":187,"column":8},"end":{"line":187,"column":15}},"132":{"start":{"line":190,"column":4},"end":{"line":198,"column":7}},"133":{"start":{"line":191,"column":15},"end":{"line":191,"column":31}},"134":{"start":{"line":192,"column":6},"end":{"line":197,"column":9}},"135":{"start":{"line":193,"column":8},"end":{"line":193,"column":41}},"136":{"start":{"line":194,"column":8},"end":{"line":194,"column":43}},"137":{"start":{"line":195,"column":8},"end":{"line":195,"column":95}},"138":{"start":{"line":196,"column":8},"end":{"line":196,"column":15}},"139":{"start":{"line":200,"column":2},"end":{"line":236,"column":5}},"140":{"start":{"line":201,"column":4},"end":{"line":208,"column":7}},"141":{"start":{"line":202,"column":15},"end":{"line":202,"column":16}},"142":{"start":{"line":203,"column":6},"end":{"line":206,"column":9}},"143":{"start":{"line":204,"column":8},"end":{"line":204,"column":41}},"144":{"start":{"line":205,"column":8},"end":{"line":205,"column":43}},"145":{"start":{"line":207,"column":6},"end":{"line":207,"column":13}},"146":{"start":{"line":209,"column":4},"end":{"line":217,"column":7}},"147":{"start":{"line":210,"column":15},"end":{"line":210,"column":16}},"148":{"start":{"line":211,"column":6},"end":{"line":216,"column":9}},"149":{"start":{"line":212,"column":8},"end":{"line":212,"column":41}},"150":{"start":{"line":213,"column":8},"end":{"line":213,"column":43}},"151":{"start":{"line":214,"column":8},"end":{"line":214,"column":66}},"152":{"start":{"line":215,"column":8},"end":{"line":215,"column":15}},"153":{"start":{"line":218,"column":4},"end":{"line":226,"column":7}},"154":{"start":{"line":219,"column":15},"end":{"line":219,"column":18}},"155":{"start":{"line":220,"column":6},"end":{"line":225,"column":9}},"156":{"start":{"line":221,"column":8},"end":{"line":221,"column":41}},"157":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"158":{"start":{"line":223,"column":8},"end":{"line":223,"column":60}},"159":{"start":{"line":224,"column":8},"end":{"line":224,"column":15}},"160":{"start":{"line":227,"column":4},"end":{"line":235,"column":7}},"161":{"start":{"line":228,"column":15},"end":{"line":228,"column":31}},"162":{"start":{"line":229,"column":6},"end":{"line":234,"column":9}},"163":{"start":{"line":230,"column":8},"end":{"line":230,"column":41}},"164":{"start":{"line":231,"column":8},"end":{"line":231,"column":43}},"165":{"start":{"line":232,"column":8},"end":{"line":232,"column":95}},"166":{"start":{"line":233,"column":8},"end":{"line":233,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":34,"column":18},"end":{"line":34,"column":19}},"loc":{"start":{"line":34,"column":30},"end":{"line":237,"column":1}},"line":34},"2":{"name":"(anonymous_2)","decl":{"start":{"line":35,"column":9},"end":{"line":35,"column":10}},"loc":{"start":{"line":35,"column":25},"end":{"line":40,"column":3}},"line":35},"3":{"name":"(anonymous_3)","decl":{"start":{"line":36,"column":90},"end":{"line":36,"column":91}},"loc":{"start":{"line":36,"column":110},"end":{"line":39,"column":5}},"line":36},"4":{"name":"(anonymous_4)","decl":{"start":{"line":41,"column":9},"end":{"line":41,"column":10}},"loc":{"start":{"line":41,"column":25},"end":{"line":46,"column":3}},"line":41},"5":{"name":"(anonymous_5)","decl":{"start":{"line":42,"column":91},"end":{"line":42,"column":92}},"loc":{"start":{"line":42,"column":111},"end":{"line":45,"column":5}},"line":42},"6":{"name":"(anonymous_6)","decl":{"start":{"line":47,"column":9},"end":{"line":47,"column":10}},"loc":{"start":{"line":47,"column":25},"end":{"line":52,"column":3}},"line":47},"7":{"name":"(anonymous_7)","decl":{"start":{"line":48,"column":136},"end":{"line":48,"column":137}},"loc":{"start":{"line":48,"column":156},"end":{"line":51,"column":5}},"line":48},"8":{"name":"(anonymous_8)","decl":{"start":{"line":54,"column":25},"end":{"line":54,"column":26}},"loc":{"start":{"line":54,"column":37},"end":{"line":93,"column":3}},"line":54},"9":{"name":"(anonymous_9)","decl":{"start":{"line":55,"column":56},"end":{"line":55,"column":57}},"loc":{"start":{"line":55,"column":72},"end":{"line":64,"column":5}},"line":55},"10":{"name":"(anonymous_10)","decl":{"start":{"line":56,"column":136},"end":{"line":56,"column":137}},"loc":{"start":{"line":56,"column":156},"end":{"line":62,"column":7}},"line":56},"11":{"name":"(anonymous_11)","decl":{"start":{"line":65,"column":56},"end":{"line":65,"column":57}},"loc":{"start":{"line":65,"column":72},"end":{"line":73,"column":5}},"line":65},"12":{"name":"(anonymous_12)","decl":{"start":{"line":66,"column":133},"end":{"line":66,"column":134}},"loc":{"start":{"line":66,"column":153},"end":{"line":71,"column":7}},"line":66},"13":{"name":"(anonymous_13)","decl":{"start":{"line":74,"column":61},"end":{"line":74,"column":62}},"loc":{"start":{"line":74,"column":77},"end":{"line":84,"column":5}},"line":74},"14":{"name":"(anonymous_14)","decl":{"start":{"line":78,"column":120},"end":{"line":78,"column":121}},"loc":{"start":{"line":78,"column":140},"end":{"line":83,"column":7}},"line":78},"15":{"name":"(anonymous_15)","decl":{"start":{"line":85,"column":62},"end":{"line":85,"column":63}},"loc":{"start":{"line":85,"column":78},"end":{"line":92,"column":5}},"line":85},"16":{"name":"(anonymous_16)","decl":{"start":{"line":86,"column":131},"end":{"line":86,"column":132}},"loc":{"start":{"line":86,"column":151},"end":{"line":91,"column":7}},"line":86},"17":{"name":"(anonymous_17)","decl":{"start":{"line":95,"column":24},"end":{"line":95,"column":25}},"loc":{"start":{"line":95,"column":36},"end":{"line":115,"column":3}},"line":95},"18":{"name":"(anonymous_18)","decl":{"start":{"line":96,"column":59},"end":{"line":96,"column":60}},"loc":{"start":{"line":96,"column":75},"end":{"line":107,"column":5}},"line":96},"19":{"name":"(anonymous_19)","decl":{"start":{"line":97,"column":106},"end":{"line":97,"column":107}},"loc":{"start":{"line":97,"column":126},"end":{"line":106,"column":7}},"line":97},"20":{"name":"(anonymous_20)","decl":{"start":{"line":108,"column":64},"end":{"line":108,"column":65}},"loc":{"start":{"line":108,"column":80},"end":{"line":114,"column":5}},"line":108},"21":{"name":"(anonymous_21)","decl":{"start":{"line":109,"column":105},"end":{"line":109,"column":106}},"loc":{"start":{"line":109,"column":125},"end":{"line":113,"column":7}},"line":109},"22":{"name":"(anonymous_22)","decl":{"start":{"line":117,"column":28},"end":{"line":117,"column":29}},"loc":{"start":{"line":117,"column":40},"end":{"line":160,"column":3}},"line":117},"23":{"name":"(anonymous_23)","decl":{"start":{"line":118,"column":58},"end":{"line":118,"column":59}},"loc":{"start":{"line":118,"column":74},"end":{"line":127,"column":5}},"line":118},"24":{"name":"(anonymous_24)","decl":{"start":{"line":120,"column":112},"end":{"line":120,"column":113}},"loc":{"start":{"line":120,"column":132},"end":{"line":126,"column":7}},"line":120},"25":{"name":"(anonymous_25)","decl":{"start":{"line":128,"column":70},"end":{"line":128,"column":71}},"loc":{"start":{"line":128,"column":86},"end":{"line":135,"column":5}},"line":128},"26":{"name":"(anonymous_26)","decl":{"start":{"line":130,"column":111},"end":{"line":130,"column":112}},"loc":{"start":{"line":130,"column":131},"end":{"line":134,"column":7}},"line":130},"27":{"name":"(anonymous_27)","decl":{"start":{"line":136,"column":78},"end":{"line":136,"column":79}},"loc":{"start":{"line":136,"column":94},"end":{"line":143,"column":5}},"line":136},"28":{"name":"(anonymous_28)","decl":{"start":{"line":138,"column":112},"end":{"line":138,"column":113}},"loc":{"start":{"line":138,"column":132},"end":{"line":142,"column":7}},"line":138},"29":{"name":"(anonymous_29)","decl":{"start":{"line":144,"column":69},"end":{"line":144,"column":70}},"loc":{"start":{"line":144,"column":85},"end":{"line":151,"column":5}},"line":144},"30":{"name":"(anonymous_30)","decl":{"start":{"line":146,"column":112},"end":{"line":146,"column":113}},"loc":{"start":{"line":146,"column":132},"end":{"line":150,"column":7}},"line":146},"31":{"name":"(anonymous_31)","decl":{"start":{"line":152,"column":68},"end":{"line":152,"column":69}},"loc":{"start":{"line":152,"column":84},"end":{"line":159,"column":5}},"line":152},"32":{"name":"(anonymous_32)","decl":{"start":{"line":154,"column":112},"end":{"line":154,"column":113}},"loc":{"start":{"line":154,"column":132},"end":{"line":158,"column":7}},"line":154},"33":{"name":"(anonymous_33)","decl":{"start":{"line":161,"column":28},"end":{"line":161,"column":29}},"loc":{"start":{"line":161,"column":40},"end":{"line":199,"column":3}},"line":161},"34":{"name":"(anonymous_34)","decl":{"start":{"line":162,"column":66},"end":{"line":162,"column":67}},"loc":{"start":{"line":162,"column":82},"end":{"line":171,"column":5}},"line":162},"35":{"name":"(anonymous_35)","decl":{"start":{"line":164,"column":144},"end":{"line":164,"column":145}},"loc":{"start":{"line":164,"column":164},"end":{"line":170,"column":7}},"line":164},"36":{"name":"(anonymous_36)","decl":{"start":{"line":172,"column":77},"end":{"line":172,"column":78}},"loc":{"start":{"line":172,"column":93},"end":{"line":180,"column":5}},"line":172},"37":{"name":"(anonymous_37)","decl":{"start":{"line":174,"column":135},"end":{"line":174,"column":136}},"loc":{"start":{"line":174,"column":155},"end":{"line":179,"column":7}},"line":174},"38":{"name":"(anonymous_38)","decl":{"start":{"line":181,"column":90},"end":{"line":181,"column":91}},"loc":{"start":{"line":181,"column":106},"end":{"line":189,"column":5}},"line":181},"39":{"name":"(anonymous_39)","decl":{"start":{"line":183,"column":136},"end":{"line":183,"column":137}},"loc":{"start":{"line":183,"column":156},"end":{"line":188,"column":7}},"line":183},"40":{"name":"(anonymous_40)","decl":{"start":{"line":190,"column":96},"end":{"line":190,"column":97}},"loc":{"start":{"line":190,"column":112},"end":{"line":198,"column":5}},"line":190},"41":{"name":"(anonymous_41)","decl":{"start":{"line":192,"column":139},"end":{"line":192,"column":140}},"loc":{"start":{"line":192,"column":159},"end":{"line":197,"column":7}},"line":192},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":31},"end":{"line":200,"column":32}},"loc":{"start":{"line":200,"column":43},"end":{"line":236,"column":3}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":201,"column":63},"end":{"line":201,"column":64}},"loc":{"start":{"line":201,"column":79},"end":{"line":208,"column":5}},"line":201},"44":{"name":"(anonymous_44)","decl":{"start":{"line":203,"column":115},"end":{"line":203,"column":116}},"loc":{"start":{"line":203,"column":135},"end":{"line":206,"column":7}},"line":203},"45":{"name":"(anonymous_45)","decl":{"start":{"line":209,"column":74},"end":{"line":209,"column":75}},"loc":{"start":{"line":209,"column":90},"end":{"line":217,"column":5}},"line":209},"46":{"name":"(anonymous_46)","decl":{"start":{"line":211,"column":114},"end":{"line":211,"column":115}},"loc":{"start":{"line":211,"column":134},"end":{"line":216,"column":7}},"line":211},"47":{"name":"(anonymous_47)","decl":{"start":{"line":218,"column":79},"end":{"line":218,"column":80}},"loc":{"start":{"line":218,"column":95},"end":{"line":226,"column":5}},"line":218},"48":{"name":"(anonymous_48)","decl":{"start":{"line":220,"column":115},"end":{"line":220,"column":116}},"loc":{"start":{"line":220,"column":135},"end":{"line":225,"column":7}},"line":220},"49":{"name":"(anonymous_49)","decl":{"start":{"line":227,"column":99},"end":{"line":227,"column":100}},"loc":{"start":{"line":227,"column":115},"end":{"line":235,"column":5}},"line":227},"50":{"name":"(anonymous_50)","decl":{"start":{"line":229,"column":115},"end":{"line":229,"column":116}},"loc":{"start":{"line":229,"column":135},"end":{"line":234,"column":7}},"line":229}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":0,"44":0,"45":0,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":0,"56":0,"57":0,"58":0,"59":0,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":0,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":1,"140":1,"141":1,"142":1,"143":1,"144":0,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":0},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":0,"16":0,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"b6d3d728e746d8f6bf90308417d5883dc86931ef","contentHash":"5d2462fcad3bc8d205ae464d4bb3ea35_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/search.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/search.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":0},"end":{"line":25,"column":30}},"12":{"start":{"line":27,"column":13},"end":{"line":27,"column":34}},"13":{"start":{"line":28,"column":0},"end":{"line":28,"column":39}},"14":{"start":{"line":29,"column":16},"end":{"line":29,"column":22}},"15":{"start":{"line":30,"column":17},"end":{"line":30,"column":23}},"16":{"start":{"line":31,"column":22},"end":{"line":31,"column":28}},"17":{"start":{"line":32,"column":12},"end":{"line":32,"column":36}},"18":{"start":{"line":33,"column":13},"end":{"line":33,"column":38}},"19":{"start":{"line":36,"column":0},"end":{"line":100,"column":3}},"20":{"start":{"line":37,"column":2},"end":{"line":42,"column":5}},"21":{"start":{"line":38,"column":4},"end":{"line":41,"column":7}},"22":{"start":{"line":39,"column":6},"end":{"line":39,"column":34}},"23":{"start":{"line":40,"column":6},"end":{"line":40,"column":13}},"24":{"start":{"line":43,"column":2},"end":{"line":48,"column":5}},"25":{"start":{"line":44,"column":4},"end":{"line":47,"column":7}},"26":{"start":{"line":45,"column":6},"end":{"line":45,"column":33}},"27":{"start":{"line":46,"column":6},"end":{"line":46,"column":13}},"28":{"start":{"line":49,"column":2},"end":{"line":54,"column":5}},"29":{"start":{"line":50,"column":4},"end":{"line":53,"column":7}},"30":{"start":{"line":51,"column":6},"end":{"line":51,"column":39}},"31":{"start":{"line":52,"column":6},"end":{"line":52,"column":13}},"32":{"start":{"line":56,"column":2},"end":{"line":72,"column":5}},"33":{"start":{"line":57,"column":4},"end":{"line":63,"column":7}},"34":{"start":{"line":58,"column":18},"end":{"line":58,"column":20}},"35":{"start":{"line":59,"column":6},"end":{"line":62,"column":9}},"36":{"start":{"line":60,"column":8},"end":{"line":60,"column":41}},"37":{"start":{"line":61,"column":8},"end":{"line":61,"column":64}},"38":{"start":{"line":64,"column":4},"end":{"line":71,"column":7}},"39":{"start":{"line":65,"column":18},"end":{"line":65,"column":24}},"40":{"start":{"line":66,"column":6},"end":{"line":70,"column":9}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":41}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":53}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":52}},"44":{"start":{"line":73,"column":2},"end":{"line":99,"column":5}},"45":{"start":{"line":74,"column":4},"end":{"line":80,"column":7}},"46":{"start":{"line":75,"column":18},"end":{"line":75,"column":20}},"47":{"start":{"line":76,"column":6},"end":{"line":79,"column":9}},"48":{"start":{"line":77,"column":8},"end":{"line":77,"column":41}},"49":{"start":{"line":78,"column":8},"end":{"line":78,"column":86}},"50":{"start":{"line":81,"column":4},"end":{"line":91,"column":7}},"51":{"start":{"line":82,"column":18},"end":{"line":82,"column":24}},"52":{"start":{"line":83,"column":6},"end":{"line":90,"column":9}},"53":{"start":{"line":84,"column":8},"end":{"line":84,"column":41}},"54":{"start":{"line":85,"column":8},"end":{"line":85,"column":54}},"55":{"start":{"line":86,"column":8},"end":{"line":86,"column":84}},"56":{"start":{"line":87,"column":8},"end":{"line":87,"column":96}},"57":{"start":{"line":88,"column":8},"end":{"line":88,"column":56}},"58":{"start":{"line":89,"column":8},"end":{"line":89,"column":78}},"59":{"start":{"line":92,"column":4},"end":{"line":98,"column":7}},"60":{"start":{"line":93,"column":18},"end":{"line":93,"column":22}},"61":{"start":{"line":94,"column":6},"end":{"line":97,"column":9}},"62":{"start":{"line":95,"column":8},"end":{"line":95,"column":41}},"63":{"start":{"line":96,"column":8},"end":{"line":96,"column":84}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":36,"column":19},"end":{"line":36,"column":20}},"loc":{"start":{"line":36,"column":31},"end":{"line":100,"column":1}},"line":36},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":9},"end":{"line":37,"column":10}},"loc":{"start":{"line":37,"column":25},"end":{"line":42,"column":3}},"line":37},"3":{"name":"(anonymous_3)","decl":{"start":{"line":38,"column":90},"end":{"line":38,"column":91}},"loc":{"start":{"line":38,"column":110},"end":{"line":41,"column":5}},"line":38},"4":{"name":"(anonymous_4)","decl":{"start":{"line":43,"column":9},"end":{"line":43,"column":10}},"loc":{"start":{"line":43,"column":25},"end":{"line":48,"column":3}},"line":43},"5":{"name":"(anonymous_5)","decl":{"start":{"line":44,"column":91},"end":{"line":44,"column":92}},"loc":{"start":{"line":44,"column":111},"end":{"line":47,"column":5}},"line":44},"6":{"name":"(anonymous_6)","decl":{"start":{"line":49,"column":9},"end":{"line":49,"column":10}},"loc":{"start":{"line":49,"column":25},"end":{"line":54,"column":3}},"line":49},"7":{"name":"(anonymous_7)","decl":{"start":{"line":50,"column":136},"end":{"line":50,"column":137}},"loc":{"start":{"line":50,"column":156},"end":{"line":53,"column":5}},"line":50},"8":{"name":"(anonymous_8)","decl":{"start":{"line":56,"column":38},"end":{"line":56,"column":39}},"loc":{"start":{"line":56,"column":50},"end":{"line":72,"column":3}},"line":56},"9":{"name":"(anonymous_9)","decl":{"start":{"line":57,"column":63},"end":{"line":57,"column":64}},"loc":{"start":{"line":57,"column":75},"end":{"line":63,"column":5}},"line":57},"10":{"name":"(anonymous_10)","decl":{"start":{"line":59,"column":126},"end":{"line":59,"column":127}},"loc":{"start":{"line":59,"column":146},"end":{"line":62,"column":7}},"line":59},"11":{"name":"(anonymous_11)","decl":{"start":{"line":64,"column":76},"end":{"line":64,"column":77}},"loc":{"start":{"line":64,"column":88},"end":{"line":71,"column":5}},"line":64},"12":{"name":"(anonymous_12)","decl":{"start":{"line":66,"column":126},"end":{"line":66,"column":127}},"loc":{"start":{"line":66,"column":146},"end":{"line":70,"column":7}},"line":66},"13":{"name":"(anonymous_13)","decl":{"start":{"line":73,"column":36},"end":{"line":73,"column":37}},"loc":{"start":{"line":73,"column":48},"end":{"line":99,"column":3}},"line":73},"14":{"name":"(anonymous_14)","decl":{"start":{"line":74,"column":63},"end":{"line":74,"column":64}},"loc":{"start":{"line":74,"column":75},"end":{"line":80,"column":5}},"line":74},"15":{"name":"(anonymous_15)","decl":{"start":{"line":76,"column":129},"end":{"line":76,"column":130}},"loc":{"start":{"line":76,"column":149},"end":{"line":79,"column":7}},"line":76},"16":{"name":"(anonymous_16)","decl":{"start":{"line":81,"column":67},"end":{"line":81,"column":68}},"loc":{"start":{"line":81,"column":79},"end":{"line":91,"column":5}},"line":81},"17":{"name":"(anonymous_17)","decl":{"start":{"line":83,"column":130},"end":{"line":83,"column":131}},"loc":{"start":{"line":83,"column":150},"end":{"line":90,"column":7}},"line":83},"18":{"name":"(anonymous_18)","decl":{"start":{"line":92,"column":70},"end":{"line":92,"column":71}},"loc":{"start":{"line":92,"column":82},"end":{"line":98,"column":5}},"line":92},"19":{"name":"(anonymous_19)","decl":{"start":{"line":94,"column":130},"end":{"line":94,"column":131}},"loc":{"start":{"line":94,"column":150},"end":{"line":97,"column":7}},"line":94}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":0,"38":1,"39":1,"40":1,"41":1,"42":0,"43":0,"44":1,"45":1,"46":1,"47":1,"48":1,"49":0,"50":1,"51":1,"52":1,"53":1,"54":0,"55":0,"56":0,"57":0,"58":0,"59":1,"60":1,"61":1,"62":1,"63":0},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1cefcdc6ec733ba336232f4e731e671c109981d4","contentHash":"c9ee84a134872aeb8ff7858e8ade4eb1_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/user.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/user.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":15},"end":{"line":31,"column":42}},"18":{"start":{"line":32,"column":13},"end":{"line":32,"column":38}},"19":{"start":{"line":33,"column":12},"end":{"line":33,"column":36}},"20":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"21":{"start":{"line":37,"column":0},"end":{"line":306,"column":3}},"22":{"start":{"line":38,"column":2},"end":{"line":43,"column":5}},"23":{"start":{"line":39,"column":4},"end":{"line":42,"column":7}},"24":{"start":{"line":40,"column":6},"end":{"line":40,"column":34}},"25":{"start":{"line":41,"column":6},"end":{"line":41,"column":13}},"26":{"start":{"line":44,"column":2},"end":{"line":49,"column":5}},"27":{"start":{"line":45,"column":4},"end":{"line":48,"column":7}},"28":{"start":{"line":46,"column":6},"end":{"line":46,"column":33}},"29":{"start":{"line":47,"column":6},"end":{"line":47,"column":13}},"30":{"start":{"line":50,"column":2},"end":{"line":55,"column":5}},"31":{"start":{"line":51,"column":4},"end":{"line":54,"column":7}},"32":{"start":{"line":52,"column":6},"end":{"line":52,"column":39}},"33":{"start":{"line":53,"column":6},"end":{"line":53,"column":13}},"34":{"start":{"line":57,"column":2},"end":{"line":305,"column":5}},"35":{"start":{"line":58,"column":4},"end":{"line":66,"column":7}},"36":{"start":{"line":59,"column":6},"end":{"line":65,"column":9}},"37":{"start":{"line":60,"column":8},"end":{"line":60,"column":41}},"38":{"start":{"line":61,"column":8},"end":{"line":61,"column":62}},"39":{"start":{"line":62,"column":8},"end":{"line":62,"column":82}},"40":{"start":{"line":63,"column":8},"end":{"line":63,"column":47}},"41":{"start":{"line":64,"column":8},"end":{"line":64,"column":15}},"42":{"start":{"line":68,"column":4},"end":{"line":76,"column":7}},"43":{"start":{"line":69,"column":6},"end":{"line":75,"column":9}},"44":{"start":{"line":70,"column":8},"end":{"line":70,"column":41}},"45":{"start":{"line":71,"column":8},"end":{"line":71,"column":62}},"46":{"start":{"line":72,"column":8},"end":{"line":72,"column":82}},"47":{"start":{"line":73,"column":8},"end":{"line":73,"column":47}},"48":{"start":{"line":74,"column":8},"end":{"line":74,"column":15}},"49":{"start":{"line":78,"column":4},"end":{"line":85,"column":7}},"50":{"start":{"line":79,"column":6},"end":{"line":84,"column":9}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":41}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":60}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":46}},"54":{"start":{"line":83,"column":8},"end":{"line":83,"column":15}},"55":{"start":{"line":87,"column":4},"end":{"line":97,"column":7}},"56":{"start":{"line":88,"column":6},"end":{"line":96,"column":9}},"57":{"start":{"line":89,"column":8},"end":{"line":95,"column":11}},"58":{"start":{"line":90,"column":10},"end":{"line":90,"column":43}},"59":{"start":{"line":91,"column":10},"end":{"line":91,"column":79}},"60":{"start":{"line":92,"column":10},"end":{"line":92,"column":48}},"61":{"start":{"line":93,"column":10},"end":{"line":93,"column":79}},"62":{"start":{"line":94,"column":10},"end":{"line":94,"column":17}},"63":{"start":{"line":99,"column":4},"end":{"line":134,"column":7}},"64":{"start":{"line":100,"column":6},"end":{"line":107,"column":9}},"65":{"start":{"line":101,"column":8},"end":{"line":106,"column":11}},"66":{"start":{"line":102,"column":10},"end":{"line":102,"column":43}},"67":{"start":{"line":103,"column":10},"end":{"line":103,"column":45}},"68":{"start":{"line":104,"column":10},"end":{"line":104,"column":64}},"69":{"start":{"line":105,"column":10},"end":{"line":105,"column":17}},"70":{"start":{"line":108,"column":6},"end":{"line":115,"column":9}},"71":{"start":{"line":109,"column":8},"end":{"line":114,"column":11}},"72":{"start":{"line":110,"column":10},"end":{"line":110,"column":43}},"73":{"start":{"line":111,"column":10},"end":{"line":111,"column":45}},"74":{"start":{"line":112,"column":10},"end":{"line":112,"column":68}},"75":{"start":{"line":113,"column":10},"end":{"line":113,"column":17}},"76":{"start":{"line":116,"column":6},"end":{"line":123,"column":9}},"77":{"start":{"line":117,"column":8},"end":{"line":122,"column":11}},"78":{"start":{"line":118,"column":10},"end":{"line":118,"column":43}},"79":{"start":{"line":119,"column":10},"end":{"line":119,"column":45}},"80":{"start":{"line":120,"column":10},"end":{"line":120,"column":64}},"81":{"start":{"line":121,"column":10},"end":{"line":121,"column":17}},"82":{"start":{"line":124,"column":6},"end":{"line":133,"column":9}},"83":{"start":{"line":125,"column":20},"end":{"line":125,"column":21}},"84":{"start":{"line":126,"column":8},"end":{"line":132,"column":11}},"85":{"start":{"line":127,"column":10},"end":{"line":127,"column":43}},"86":{"start":{"line":128,"column":10},"end":{"line":128,"column":45}},"87":{"start":{"line":129,"column":10},"end":{"line":129,"column":66}},"88":{"start":{"line":130,"column":10},"end":{"line":130,"column":61}},"89":{"start":{"line":131,"column":10},"end":{"line":131,"column":17}},"90":{"start":{"line":135,"column":4},"end":{"line":196,"column":7}},"91":{"start":{"line":136,"column":6},"end":{"line":148,"column":9}},"92":{"start":{"line":137,"column":17},"end":{"line":137,"column":18}},"93":{"start":{"line":138,"column":8},"end":{"line":147,"column":11}},"94":{"start":{"line":139,"column":10},"end":{"line":139,"column":43}},"95":{"start":{"line":140,"column":10},"end":{"line":140,"column":41}},"96":{"start":{"line":141,"column":10},"end":{"line":141,"column":60}},"97":{"start":{"line":142,"column":10},"end":{"line":142,"column":43}},"98":{"start":{"line":143,"column":10},"end":{"line":143,"column":54}},"99":{"start":{"line":144,"column":10},"end":{"line":144,"column":60}},"100":{"start":{"line":145,"column":10},"end":{"line":145,"column":47}},"101":{"start":{"line":146,"column":10},"end":{"line":146,"column":17}},"102":{"start":{"line":149,"column":6},"end":{"line":161,"column":9}},"103":{"start":{"line":150,"column":17},"end":{"line":150,"column":18}},"104":{"start":{"line":151,"column":8},"end":{"line":160,"column":11}},"105":{"start":{"line":152,"column":10},"end":{"line":152,"column":43}},"106":{"start":{"line":153,"column":10},"end":{"line":153,"column":41}},"107":{"start":{"line":154,"column":10},"end":{"line":154,"column":60}},"108":{"start":{"line":155,"column":10},"end":{"line":155,"column":40}},"109":{"start":{"line":156,"column":10},"end":{"line":156,"column":54}},"110":{"start":{"line":157,"column":10},"end":{"line":157,"column":60}},"111":{"start":{"line":158,"column":10},"end":{"line":158,"column":47}},"112":{"start":{"line":159,"column":10},"end":{"line":159,"column":17}},"113":{"start":{"line":162,"column":6},"end":{"line":169,"column":9}},"114":{"start":{"line":163,"column":17},"end":{"line":163,"column":29}},"115":{"start":{"line":164,"column":8},"end":{"line":168,"column":11}},"116":{"start":{"line":165,"column":10},"end":{"line":165,"column":43}},"117":{"start":{"line":166,"column":10},"end":{"line":166,"column":112}},"118":{"start":{"line":167,"column":10},"end":{"line":167,"column":17}},"119":{"start":{"line":170,"column":6},"end":{"line":178,"column":9}},"120":{"start":{"line":171,"column":17},"end":{"line":171,"column":18}},"121":{"start":{"line":172,"column":8},"end":{"line":176,"column":11}},"122":{"start":{"line":173,"column":10},"end":{"line":173,"column":43}},"123":{"start":{"line":174,"column":10},"end":{"line":174,"column":53}},"124":{"start":{"line":175,"column":10},"end":{"line":175,"column":65}},"125":{"start":{"line":177,"column":8},"end":{"line":177,"column":15}},"126":{"start":{"line":179,"column":6},"end":{"line":187,"column":9}},"127":{"start":{"line":180,"column":17},"end":{"line":180,"column":20}},"128":{"start":{"line":181,"column":8},"end":{"line":186,"column":11}},"129":{"start":{"line":182,"column":10},"end":{"line":182,"column":43}},"130":{"start":{"line":183,"column":10},"end":{"line":183,"column":55}},"131":{"start":{"line":184,"column":10},"end":{"line":184,"column":60}},"132":{"start":{"line":185,"column":10},"end":{"line":185,"column":17}},"133":{"start":{"line":188,"column":6},"end":{"line":195,"column":9}},"134":{"start":{"line":189,"column":17},"end":{"line":189,"column":35}},"135":{"start":{"line":190,"column":8},"end":{"line":194,"column":11}},"136":{"start":{"line":191,"column":10},"end":{"line":191,"column":43}},"137":{"start":{"line":192,"column":10},"end":{"line":192,"column":119}},"138":{"start":{"line":193,"column":10},"end":{"line":193,"column":17}},"139":{"start":{"line":197,"column":4},"end":{"line":246,"column":7}},"140":{"start":{"line":198,"column":6},"end":{"line":207,"column":9}},"141":{"start":{"line":199,"column":17},"end":{"line":199,"column":18}},"142":{"start":{"line":200,"column":8},"end":{"line":206,"column":11}},"143":{"start":{"line":201,"column":10},"end":{"line":201,"column":43}},"144":{"start":{"line":202,"column":10},"end":{"line":202,"column":45}},"145":{"start":{"line":203,"column":10},"end":{"line":203,"column":40}},"146":{"start":{"line":204,"column":10},"end":{"line":204,"column":55}},"147":{"start":{"line":205,"column":10},"end":{"line":205,"column":17}},"148":{"start":{"line":208,"column":6},"end":{"line":217,"column":9}},"149":{"start":{"line":209,"column":17},"end":{"line":209,"column":18}},"150":{"start":{"line":210,"column":8},"end":{"line":216,"column":11}},"151":{"start":{"line":211,"column":10},"end":{"line":211,"column":43}},"152":{"start":{"line":212,"column":10},"end":{"line":212,"column":45}},"153":{"start":{"line":213,"column":10},"end":{"line":213,"column":40}},"154":{"start":{"line":214,"column":10},"end":{"line":214,"column":62}},"155":{"start":{"line":215,"column":10},"end":{"line":215,"column":17}},"156":{"start":{"line":218,"column":6},"end":{"line":227,"column":9}},"157":{"start":{"line":219,"column":17},"end":{"line":219,"column":18}},"158":{"start":{"line":220,"column":8},"end":{"line":226,"column":11}},"159":{"start":{"line":221,"column":10},"end":{"line":221,"column":43}},"160":{"start":{"line":222,"column":10},"end":{"line":222,"column":45}},"161":{"start":{"line":223,"column":10},"end":{"line":223,"column":40}},"162":{"start":{"line":224,"column":10},"end":{"line":224,"column":56}},"163":{"start":{"line":225,"column":10},"end":{"line":225,"column":17}},"164":{"start":{"line":228,"column":6},"end":{"line":236,"column":9}},"165":{"start":{"line":229,"column":17},"end":{"line":229,"column":18}},"166":{"start":{"line":230,"column":8},"end":{"line":235,"column":11}},"167":{"start":{"line":231,"column":10},"end":{"line":231,"column":43}},"168":{"start":{"line":232,"column":10},"end":{"line":232,"column":45}},"169":{"start":{"line":233,"column":10},"end":{"line":233,"column":88}},"170":{"start":{"line":234,"column":10},"end":{"line":234,"column":17}},"171":{"start":{"line":237,"column":6},"end":{"line":245,"column":9}},"172":{"start":{"line":238,"column":17},"end":{"line":238,"column":21}},"173":{"start":{"line":239,"column":8},"end":{"line":244,"column":11}},"174":{"start":{"line":240,"column":10},"end":{"line":240,"column":43}},"175":{"start":{"line":241,"column":10},"end":{"line":241,"column":45}},"176":{"start":{"line":242,"column":10},"end":{"line":242,"column":88}},"177":{"start":{"line":243,"column":10},"end":{"line":243,"column":17}},"178":{"start":{"line":247,"column":4},"end":{"line":272,"column":7}},"179":{"start":{"line":248,"column":6},"end":{"line":254,"column":9}},"180":{"start":{"line":249,"column":17},"end":{"line":249,"column":18}},"181":{"start":{"line":250,"column":8},"end":{"line":253,"column":11}},"182":{"start":{"line":251,"column":10},"end":{"line":251,"column":43}},"183":{"start":{"line":252,"column":10},"end":{"line":252,"column":17}},"184":{"start":{"line":255,"column":6},"end":{"line":262,"column":9}},"185":{"start":{"line":256,"column":17},"end":{"line":256,"column":18}},"186":{"start":{"line":257,"column":8},"end":{"line":261,"column":11}},"187":{"start":{"line":258,"column":10},"end":{"line":258,"column":43}},"188":{"start":{"line":259,"column":10},"end":{"line":259,"column":89}},"189":{"start":{"line":260,"column":10},"end":{"line":260,"column":17}},"190":{"start":{"line":263,"column":6},"end":{"line":271,"column":9}},"191":{"start":{"line":264,"column":17},"end":{"line":264,"column":19}},"192":{"start":{"line":265,"column":8},"end":{"line":270,"column":11}},"193":{"start":{"line":266,"column":10},"end":{"line":266,"column":43}},"194":{"start":{"line":267,"column":10},"end":{"line":267,"column":45}},"195":{"start":{"line":268,"column":10},"end":{"line":268,"column":60}},"196":{"start":{"line":269,"column":10},"end":{"line":269,"column":17}},"197":{"start":{"line":273,"column":4},"end":{"line":304,"column":7}},"198":{"start":{"line":274,"column":6},"end":{"line":282,"column":9}},"199":{"start":{"line":275,"column":21},"end":{"line":275,"column":22}},"200":{"start":{"line":276,"column":8},"end":{"line":281,"column":11}},"201":{"start":{"line":277,"column":10},"end":{"line":277,"column":43}},"202":{"start":{"line":278,"column":10},"end":{"line":278,"column":42}},"203":{"start":{"line":279,"column":10},"end":{"line":279,"column":60}},"204":{"start":{"line":280,"column":10},"end":{"line":280,"column":17}},"205":{"start":{"line":283,"column":6},"end":{"line":292,"column":9}},"206":{"start":{"line":284,"column":21},"end":{"line":284,"column":22}},"207":{"start":{"line":285,"column":8},"end":{"line":291,"column":11}},"208":{"start":{"line":286,"column":10},"end":{"line":286,"column":43}},"209":{"start":{"line":287,"column":10},"end":{"line":287,"column":42}},"210":{"start":{"line":288,"column":10},"end":{"line":288,"column":64}},"211":{"start":{"line":289,"column":10},"end":{"line":289,"column":49}},"212":{"start":{"line":290,"column":10},"end":{"line":290,"column":17}},"213":{"start":{"line":293,"column":6},"end":{"line":303,"column":9}},"214":{"start":{"line":294,"column":21},"end":{"line":294,"column":22}},"215":{"start":{"line":295,"column":8},"end":{"line":302,"column":11}},"216":{"start":{"line":296,"column":10},"end":{"line":296,"column":43}},"217":{"start":{"line":297,"column":10},"end":{"line":297,"column":42}},"218":{"start":{"line":298,"column":10},"end":{"line":298,"column":56}},"219":{"start":{"line":299,"column":10},"end":{"line":299,"column":68}},"220":{"start":{"line":300,"column":10},"end":{"line":300,"column":85}},"221":{"start":{"line":301,"column":10},"end":{"line":301,"column":17}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":18},"end":{"line":37,"column":19}},"loc":{"start":{"line":37,"column":30},"end":{"line":306,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":10}},"loc":{"start":{"line":38,"column":25},"end":{"line":43,"column":3}},"line":38},"3":{"name":"(anonymous_3)","decl":{"start":{"line":39,"column":90},"end":{"line":39,"column":91}},"loc":{"start":{"line":39,"column":110},"end":{"line":42,"column":5}},"line":39},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":9},"end":{"line":44,"column":10}},"loc":{"start":{"line":44,"column":25},"end":{"line":49,"column":3}},"line":44},"5":{"name":"(anonymous_5)","decl":{"start":{"line":45,"column":91},"end":{"line":45,"column":92}},"loc":{"start":{"line":45,"column":111},"end":{"line":48,"column":5}},"line":45},"6":{"name":"(anonymous_6)","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":10}},"loc":{"start":{"line":50,"column":25},"end":{"line":55,"column":3}},"line":50},"7":{"name":"(anonymous_7)","decl":{"start":{"line":51,"column":136},"end":{"line":51,"column":137}},"loc":{"start":{"line":51,"column":156},"end":{"line":54,"column":5}},"line":51},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":31},"end":{"line":57,"column":32}},"loc":{"start":{"line":57,"column":43},"end":{"line":305,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":58,"column":75},"end":{"line":58,"column":76}},"loc":{"start":{"line":58,"column":91},"end":{"line":66,"column":5}},"line":58},"10":{"name":"(anonymous_10)","decl":{"start":{"line":59,"column":92},"end":{"line":59,"column":93}},"loc":{"start":{"line":59,"column":112},"end":{"line":65,"column":7}},"line":59},"11":{"name":"(anonymous_11)","decl":{"start":{"line":68,"column":59},"end":{"line":68,"column":60}},"loc":{"start":{"line":68,"column":75},"end":{"line":76,"column":5}},"line":68},"12":{"name":"(anonymous_12)","decl":{"start":{"line":69,"column":92},"end":{"line":69,"column":93}},"loc":{"start":{"line":69,"column":112},"end":{"line":75,"column":7}},"line":69},"13":{"name":"(anonymous_13)","decl":{"start":{"line":78,"column":50},"end":{"line":78,"column":51}},"loc":{"start":{"line":78,"column":66},"end":{"line":85,"column":5}},"line":78},"14":{"name":"(anonymous_14)","decl":{"start":{"line":79,"column":92},"end":{"line":79,"column":93}},"loc":{"start":{"line":79,"column":112},"end":{"line":84,"column":7}},"line":79},"15":{"name":"(anonymous_15)","decl":{"start":{"line":87,"column":34},"end":{"line":87,"column":35}},"loc":{"start":{"line":87,"column":46},"end":{"line":97,"column":5}},"line":87},"16":{"name":"(anonymous_16)","decl":{"start":{"line":88,"column":37},"end":{"line":88,"column":38}},"loc":{"start":{"line":88,"column":53},"end":{"line":96,"column":7}},"line":88},"17":{"name":"(anonymous_17)","decl":{"start":{"line":89,"column":92},"end":{"line":89,"column":93}},"loc":{"start":{"line":89,"column":112},"end":{"line":95,"column":9}},"line":89},"18":{"name":"(anonymous_18)","decl":{"start":{"line":99,"column":27},"end":{"line":99,"column":28}},"loc":{"start":{"line":99,"column":39},"end":{"line":134,"column":5}},"line":99},"19":{"name":"(anonymous_19)","decl":{"start":{"line":100,"column":58},"end":{"line":100,"column":59}},"loc":{"start":{"line":100,"column":74},"end":{"line":107,"column":7}},"line":100},"20":{"name":"(anonymous_20)","decl":{"start":{"line":101,"column":110},"end":{"line":101,"column":111}},"loc":{"start":{"line":101,"column":130},"end":{"line":106,"column":9}},"line":101},"21":{"name":"(anonymous_21)","decl":{"start":{"line":108,"column":74},"end":{"line":108,"column":75}},"loc":{"start":{"line":108,"column":90},"end":{"line":115,"column":7}},"line":108},"22":{"name":"(anonymous_22)","decl":{"start":{"line":109,"column":109},"end":{"line":109,"column":110}},"loc":{"start":{"line":109,"column":129},"end":{"line":114,"column":9}},"line":109},"23":{"name":"(anonymous_23)","decl":{"start":{"line":116,"column":66},"end":{"line":116,"column":67}},"loc":{"start":{"line":116,"column":82},"end":{"line":123,"column":7}},"line":116},"24":{"name":"(anonymous_24)","decl":{"start":{"line":117,"column":75},"end":{"line":117,"column":76}},"loc":{"start":{"line":117,"column":95},"end":{"line":122,"column":9}},"line":117},"25":{"name":"(anonymous_25)","decl":{"start":{"line":124,"column":63},"end":{"line":124,"column":64}},"loc":{"start":{"line":124,"column":79},"end":{"line":133,"column":7}},"line":124},"26":{"name":"(anonymous_26)","decl":{"start":{"line":126,"column":123},"end":{"line":126,"column":124}},"loc":{"start":{"line":126,"column":143},"end":{"line":132,"column":9}},"line":126},"27":{"name":"(anonymous_27)","decl":{"start":{"line":135,"column":32},"end":{"line":135,"column":33}},"loc":{"start":{"line":135,"column":44},"end":{"line":196,"column":5}},"line":135},"28":{"name":"(anonymous_28)","decl":{"start":{"line":136,"column":54},"end":{"line":136,"column":55}},"loc":{"start":{"line":136,"column":70},"end":{"line":148,"column":7}},"line":136},"29":{"name":"(anonymous_29)","decl":{"start":{"line":138,"column":116},"end":{"line":138,"column":117}},"loc":{"start":{"line":138,"column":136},"end":{"line":147,"column":9}},"line":138},"30":{"name":"(anonymous_30)","decl":{"start":{"line":149,"column":74},"end":{"line":149,"column":75}},"loc":{"start":{"line":149,"column":90},"end":{"line":161,"column":7}},"line":149},"31":{"name":"(anonymous_31)","decl":{"start":{"line":151,"column":115},"end":{"line":151,"column":116}},"loc":{"start":{"line":151,"column":135},"end":{"line":160,"column":9}},"line":151},"32":{"name":"(anonymous_32)","decl":{"start":{"line":162,"column":69},"end":{"line":162,"column":70}},"loc":{"start":{"line":162,"column":85},"end":{"line":169,"column":7}},"line":162},"33":{"name":"(anonymous_33)","decl":{"start":{"line":164,"column":116},"end":{"line":164,"column":117}},"loc":{"start":{"line":164,"column":136},"end":{"line":168,"column":9}},"line":164},"34":{"name":"(anonymous_34)","decl":{"start":{"line":170,"column":74},"end":{"line":170,"column":75}},"loc":{"start":{"line":170,"column":90},"end":{"line":178,"column":7}},"line":170},"35":{"name":"(anonymous_35)","decl":{"start":{"line":172,"column":117},"end":{"line":172,"column":118}},"loc":{"start":{"line":172,"column":137},"end":{"line":176,"column":9}},"line":172},"36":{"name":"(anonymous_36)","decl":{"start":{"line":179,"column":65},"end":{"line":179,"column":66}},"loc":{"start":{"line":179,"column":81},"end":{"line":187,"column":7}},"line":179},"37":{"name":"(anonymous_37)","decl":{"start":{"line":181,"column":116},"end":{"line":181,"column":117}},"loc":{"start":{"line":181,"column":136},"end":{"line":186,"column":9}},"line":181},"38":{"name":"(anonymous_38)","decl":{"start":{"line":188,"column":64},"end":{"line":188,"column":65}},"loc":{"start":{"line":188,"column":80},"end":{"line":195,"column":7}},"line":188},"39":{"name":"(anonymous_39)","decl":{"start":{"line":190,"column":116},"end":{"line":190,"column":117}},"loc":{"start":{"line":190,"column":136},"end":{"line":194,"column":9}},"line":190},"40":{"name":"(anonymous_40)","decl":{"start":{"line":197,"column":39},"end":{"line":197,"column":40}},"loc":{"start":{"line":197,"column":51},"end":{"line":246,"column":5}},"line":197},"41":{"name":"(anonymous_41)","decl":{"start":{"line":198,"column":73},"end":{"line":198,"column":74}},"loc":{"start":{"line":198,"column":89},"end":{"line":207,"column":7}},"line":198},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":146},"end":{"line":200,"column":147}},"loc":{"start":{"line":200,"column":166},"end":{"line":206,"column":9}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":69},"end":{"line":208,"column":70}},"loc":{"start":{"line":208,"column":85},"end":{"line":217,"column":7}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":210,"column":153},"end":{"line":210,"column":154}},"loc":{"start":{"line":210,"column":173},"end":{"line":216,"column":9}},"line":210},"45":{"name":"(anonymous_45)","decl":{"start":{"line":218,"column":72},"end":{"line":218,"column":73}},"loc":{"start":{"line":218,"column":88},"end":{"line":227,"column":7}},"line":218},"46":{"name":"(anonymous_46)","decl":{"start":{"line":220,"column":147},"end":{"line":220,"column":148}},"loc":{"start":{"line":220,"column":167},"end":{"line":226,"column":9}},"line":220},"47":{"name":"(anonymous_47)","decl":{"start":{"line":228,"column":102},"end":{"line":228,"column":103}},"loc":{"start":{"line":228,"column":118},"end":{"line":236,"column":7}},"line":228},"48":{"name":"(anonymous_48)","decl":{"start":{"line":230,"column":153},"end":{"line":230,"column":154}},"loc":{"start":{"line":230,"column":173},"end":{"line":235,"column":9}},"line":230},"49":{"name":"(anonymous_49)","decl":{"start":{"line":237,"column":99},"end":{"line":237,"column":100}},"loc":{"start":{"line":237,"column":115},"end":{"line":245,"column":7}},"line":237},"50":{"name":"(anonymous_50)","decl":{"start":{"line":239,"column":153},"end":{"line":239,"column":154}},"loc":{"start":{"line":239,"column":173},"end":{"line":244,"column":9}},"line":239},"51":{"name":"(anonymous_51)","decl":{"start":{"line":247,"column":35},"end":{"line":247,"column":36}},"loc":{"start":{"line":247,"column":47},"end":{"line":272,"column":5}},"line":247},"52":{"name":"(anonymous_52)","decl":{"start":{"line":248,"column":65},"end":{"line":248,"column":66}},"loc":{"start":{"line":248,"column":81},"end":{"line":254,"column":7}},"line":248},"53":{"name":"(anonymous_53)","decl":{"start":{"line":250,"column":119},"end":{"line":250,"column":120}},"loc":{"start":{"line":250,"column":139},"end":{"line":253,"column":9}},"line":250},"54":{"name":"(anonymous_54)","decl":{"start":{"line":255,"column":73},"end":{"line":255,"column":74}},"loc":{"start":{"line":255,"column":89},"end":{"line":262,"column":7}},"line":255},"55":{"name":"(anonymous_55)","decl":{"start":{"line":257,"column":118},"end":{"line":257,"column":119}},"loc":{"start":{"line":257,"column":138},"end":{"line":261,"column":9}},"line":257},"56":{"name":"(anonymous_56)","decl":{"start":{"line":263,"column":62},"end":{"line":263,"column":63}},"loc":{"start":{"line":263,"column":78},"end":{"line":271,"column":7}},"line":263},"57":{"name":"(anonymous_57)","decl":{"start":{"line":265,"column":119},"end":{"line":265,"column":120}},"loc":{"start":{"line":265,"column":139},"end":{"line":270,"column":9}},"line":265},"58":{"name":"(anonymous_58)","decl":{"start":{"line":273,"column":51},"end":{"line":273,"column":52}},"loc":{"start":{"line":273,"column":63},"end":{"line":304,"column":5}},"line":273},"59":{"name":"(anonymous_59)","decl":{"start":{"line":274,"column":68},"end":{"line":274,"column":69}},"loc":{"start":{"line":274,"column":84},"end":{"line":282,"column":7}},"line":274},"60":{"name":"(anonymous_60)","decl":{"start":{"line":276,"column":134},"end":{"line":276,"column":135}},"loc":{"start":{"line":276,"column":154},"end":{"line":281,"column":9}},"line":276},"61":{"name":"(anonymous_61)","decl":{"start":{"line":283,"column":70},"end":{"line":283,"column":71}},"loc":{"start":{"line":283,"column":86},"end":{"line":292,"column":7}},"line":283},"62":{"name":"(anonymous_62)","decl":{"start":{"line":285,"column":100},"end":{"line":285,"column":101}},"loc":{"start":{"line":285,"column":120},"end":{"line":291,"column":9}},"line":285},"63":{"name":"(anonymous_63)","decl":{"start":{"line":293,"column":69},"end":{"line":293,"column":70}},"loc":{"start":{"line":293,"column":85},"end":{"line":303,"column":7}},"line":293},"64":{"name":"(anonymous_64)","decl":{"start":{"line":295,"column":134},"end":{"line":295,"column":135}},"loc":{"start":{"line":295,"column":154},"end":{"line":302,"column":9}},"line":295}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":0,"124":0,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":1,"140":1,"141":1,"142":1,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1,"197":1,"198":1,"199":1,"200":1,"201":1,"202":1,"203":1,"204":1,"205":1,"206":1,"207":1,"208":1,"209":1,"210":1,"211":1,"212":1,"213":1,"214":1,"215":1,"216":1,"217":1,"218":1,"219":1,"220":1,"221":1},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"060516ee641f350d496788a93e3f15efcfed500f","contentHash":"f57e82a76a737be2530dffb11f4a5fbd_11.0.3"}} \ No newline at end of file diff --git a/.nyc_output/761fb25525ac9854b017da3143f5384b.json b/.nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json similarity index 100% rename from .nyc_output/761fb25525ac9854b017da3143f5384b.json rename to .nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json diff --git a/.nyc_output/d9387f41d819cd714da6161ea327df8e.json b/.nyc_output/d9387f41d819cd714da6161ea327df8e.json deleted file mode 100644 index 107ace2..0000000 --- a/.nyc_output/d9387f41d819cd714da6161ea327df8e.json +++ /dev/null @@ -1 +0,0 @@ -{"/Users/andeladeveloper/Documents/projects/document-manager/server/test/document.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/document.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":291,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":106,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":79,"column":7}},"38":{"start":{"line":64,"column":21},"end":{"line":69,"column":7}},"39":{"start":{"line":70,"column":6},"end":{"line":78,"column":9}},"40":{"start":{"line":71,"column":8},"end":{"line":71,"column":41}},"41":{"start":{"line":72,"column":8},"end":{"line":72,"column":43}},"42":{"start":{"line":73,"column":8},"end":{"line":73,"column":48}},"43":{"start":{"line":74,"column":8},"end":{"line":74,"column":54}},"44":{"start":{"line":75,"column":8},"end":{"line":75,"column":71}},"45":{"start":{"line":76,"column":8},"end":{"line":76,"column":51}},"46":{"start":{"line":77,"column":8},"end":{"line":77,"column":15}},"47":{"start":{"line":81,"column":4},"end":{"line":91,"column":7}},"48":{"start":{"line":82,"column":21},"end":{"line":86,"column":7}},"49":{"start":{"line":87,"column":6},"end":{"line":90,"column":9}},"50":{"start":{"line":88,"column":8},"end":{"line":88,"column":41}},"51":{"start":{"line":89,"column":8},"end":{"line":89,"column":67}},"52":{"start":{"line":92,"column":4},"end":{"line":105,"column":7}},"53":{"start":{"line":93,"column":21},"end":{"line":98,"column":7}},"54":{"start":{"line":99,"column":6},"end":{"line":104,"column":9}},"55":{"start":{"line":100,"column":8},"end":{"line":100,"column":41}},"56":{"start":{"line":101,"column":8},"end":{"line":101,"column":43}},"57":{"start":{"line":102,"column":8},"end":{"line":102,"column":62}},"58":{"start":{"line":103,"column":8},"end":{"line":103,"column":15}},"59":{"start":{"line":108,"column":2},"end":{"line":142,"column":5}},"60":{"start":{"line":109,"column":4},"end":{"line":116,"column":7}},"61":{"start":{"line":110,"column":6},"end":{"line":115,"column":9}},"62":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"63":{"start":{"line":112,"column":8},"end":{"line":112,"column":43}},"64":{"start":{"line":113,"column":8},"end":{"line":113,"column":66}},"65":{"start":{"line":114,"column":8},"end":{"line":114,"column":15}},"66":{"start":{"line":117,"column":4},"end":{"line":125,"column":7}},"67":{"start":{"line":118,"column":6},"end":{"line":124,"column":9}},"68":{"start":{"line":119,"column":8},"end":{"line":119,"column":41}},"69":{"start":{"line":120,"column":8},"end":{"line":120,"column":43}},"70":{"start":{"line":121,"column":8},"end":{"line":121,"column":62}},"71":{"start":{"line":122,"column":8},"end":{"line":122,"column":47}},"72":{"start":{"line":123,"column":8},"end":{"line":123,"column":15}},"73":{"start":{"line":126,"column":4},"end":{"line":133,"column":7}},"74":{"start":{"line":127,"column":18},"end":{"line":127,"column":19}},"75":{"start":{"line":128,"column":6},"end":{"line":132,"column":9}},"76":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"77":{"start":{"line":130,"column":8},"end":{"line":130,"column":43}},"78":{"start":{"line":131,"column":8},"end":{"line":131,"column":15}},"79":{"start":{"line":134,"column":4},"end":{"line":141,"column":7}},"80":{"start":{"line":135,"column":19},"end":{"line":135,"column":20}},"81":{"start":{"line":136,"column":6},"end":{"line":140,"column":9}},"82":{"start":{"line":137,"column":8},"end":{"line":137,"column":41}},"83":{"start":{"line":138,"column":8},"end":{"line":138,"column":43}},"84":{"start":{"line":139,"column":8},"end":{"line":139,"column":15}},"85":{"start":{"line":144,"column":2},"end":{"line":217,"column":5}},"86":{"start":{"line":145,"column":4},"end":{"line":153,"column":7}},"87":{"start":{"line":146,"column":23},"end":{"line":146,"column":24}},"88":{"start":{"line":147,"column":6},"end":{"line":152,"column":9}},"89":{"start":{"line":148,"column":8},"end":{"line":148,"column":41}},"90":{"start":{"line":149,"column":8},"end":{"line":149,"column":43}},"91":{"start":{"line":150,"column":8},"end":{"line":150,"column":62}},"92":{"start":{"line":151,"column":8},"end":{"line":151,"column":15}},"93":{"start":{"line":154,"column":4},"end":{"line":164,"column":7}},"94":{"start":{"line":155,"column":23},"end":{"line":155,"column":24}},"95":{"start":{"line":156,"column":6},"end":{"line":163,"column":9}},"96":{"start":{"line":157,"column":8},"end":{"line":157,"column":41}},"97":{"start":{"line":158,"column":8},"end":{"line":158,"column":43}},"98":{"start":{"line":159,"column":8},"end":{"line":159,"column":38}},"99":{"start":{"line":160,"column":8},"end":{"line":160,"column":56}},"100":{"start":{"line":161,"column":8},"end":{"line":161,"column":51}},"101":{"start":{"line":162,"column":8},"end":{"line":162,"column":15}},"102":{"start":{"line":165,"column":4},"end":{"line":173,"column":7}},"103":{"start":{"line":166,"column":23},"end":{"line":166,"column":24}},"104":{"start":{"line":167,"column":6},"end":{"line":172,"column":9}},"105":{"start":{"line":168,"column":8},"end":{"line":168,"column":41}},"106":{"start":{"line":169,"column":8},"end":{"line":169,"column":43}},"107":{"start":{"line":170,"column":8},"end":{"line":170,"column":88}},"108":{"start":{"line":171,"column":8},"end":{"line":171,"column":15}},"109":{"start":{"line":174,"column":4},"end":{"line":185,"column":7}},"110":{"start":{"line":175,"column":23},"end":{"line":175,"column":24}},"111":{"start":{"line":176,"column":6},"end":{"line":184,"column":9}},"112":{"start":{"line":177,"column":8},"end":{"line":177,"column":41}},"113":{"start":{"line":178,"column":8},"end":{"line":178,"column":43}},"114":{"start":{"line":179,"column":8},"end":{"line":179,"column":50}},"115":{"start":{"line":180,"column":8},"end":{"line":180,"column":54}},"116":{"start":{"line":181,"column":8},"end":{"line":181,"column":38}},"117":{"start":{"line":182,"column":8},"end":{"line":182,"column":42}},"118":{"start":{"line":183,"column":8},"end":{"line":183,"column":15}},"119":{"start":{"line":186,"column":4},"end":{"line":194,"column":7}},"120":{"start":{"line":187,"column":23},"end":{"line":187,"column":24}},"121":{"start":{"line":188,"column":6},"end":{"line":193,"column":9}},"122":{"start":{"line":189,"column":8},"end":{"line":189,"column":41}},"123":{"start":{"line":190,"column":8},"end":{"line":190,"column":43}},"124":{"start":{"line":191,"column":8},"end":{"line":191,"column":88}},"125":{"start":{"line":192,"column":8},"end":{"line":192,"column":15}},"126":{"start":{"line":195,"column":4},"end":{"line":205,"column":7}},"127":{"start":{"line":196,"column":23},"end":{"line":196,"column":24}},"128":{"start":{"line":197,"column":6},"end":{"line":204,"column":9}},"129":{"start":{"line":198,"column":8},"end":{"line":198,"column":41}},"130":{"start":{"line":199,"column":8},"end":{"line":199,"column":43}},"131":{"start":{"line":200,"column":8},"end":{"line":200,"column":38}},"132":{"start":{"line":201,"column":8},"end":{"line":201,"column":53}},"133":{"start":{"line":202,"column":8},"end":{"line":202,"column":47}},"134":{"start":{"line":203,"column":8},"end":{"line":203,"column":15}},"135":{"start":{"line":206,"column":4},"end":{"line":216,"column":7}},"136":{"start":{"line":207,"column":23},"end":{"line":207,"column":24}},"137":{"start":{"line":208,"column":6},"end":{"line":214,"column":9}},"138":{"start":{"line":209,"column":8},"end":{"line":209,"column":41}},"139":{"start":{"line":210,"column":8},"end":{"line":210,"column":43}},"140":{"start":{"line":211,"column":8},"end":{"line":211,"column":38}},"141":{"start":{"line":212,"column":8},"end":{"line":212,"column":53}},"142":{"start":{"line":213,"column":8},"end":{"line":213,"column":47}},"143":{"start":{"line":215,"column":6},"end":{"line":215,"column":13}},"144":{"start":{"line":219,"column":2},"end":{"line":255,"column":5}},"145":{"start":{"line":220,"column":4},"end":{"line":229,"column":7}},"146":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"147":{"start":{"line":222,"column":6},"end":{"line":228,"column":9}},"148":{"start":{"line":223,"column":8},"end":{"line":223,"column":41}},"149":{"start":{"line":224,"column":8},"end":{"line":224,"column":43}},"150":{"start":{"line":225,"column":8},"end":{"line":225,"column":38}},"151":{"start":{"line":226,"column":8},"end":{"line":226,"column":56}},"152":{"start":{"line":227,"column":8},"end":{"line":227,"column":15}},"153":{"start":{"line":230,"column":4},"end":{"line":238,"column":7}},"154":{"start":{"line":231,"column":15},"end":{"line":231,"column":16}},"155":{"start":{"line":232,"column":6},"end":{"line":237,"column":9}},"156":{"start":{"line":233,"column":8},"end":{"line":233,"column":41}},"157":{"start":{"line":234,"column":8},"end":{"line":234,"column":43}},"158":{"start":{"line":235,"column":8},"end":{"line":235,"column":88}},"159":{"start":{"line":236,"column":8},"end":{"line":236,"column":15}},"160":{"start":{"line":239,"column":4},"end":{"line":245,"column":7}},"161":{"start":{"line":240,"column":15},"end":{"line":240,"column":16}},"162":{"start":{"line":241,"column":6},"end":{"line":244,"column":9}},"163":{"start":{"line":242,"column":8},"end":{"line":242,"column":41}},"164":{"start":{"line":243,"column":8},"end":{"line":243,"column":15}},"165":{"start":{"line":246,"column":4},"end":{"line":254,"column":7}},"166":{"start":{"line":247,"column":15},"end":{"line":247,"column":17}},"167":{"start":{"line":248,"column":6},"end":{"line":253,"column":9}},"168":{"start":{"line":249,"column":8},"end":{"line":249,"column":41}},"169":{"start":{"line":250,"column":8},"end":{"line":250,"column":43}},"170":{"start":{"line":251,"column":8},"end":{"line":251,"column":62}},"171":{"start":{"line":252,"column":8},"end":{"line":252,"column":15}},"172":{"start":{"line":257,"column":2},"end":{"line":290,"column":5}},"173":{"start":{"line":258,"column":4},"end":{"line":264,"column":7}},"174":{"start":{"line":259,"column":15},"end":{"line":259,"column":16}},"175":{"start":{"line":260,"column":6},"end":{"line":263,"column":9}},"176":{"start":{"line":261,"column":8},"end":{"line":261,"column":41}},"177":{"start":{"line":262,"column":8},"end":{"line":262,"column":15}},"178":{"start":{"line":265,"column":4},"end":{"line":271,"column":7}},"179":{"start":{"line":266,"column":15},"end":{"line":266,"column":16}},"180":{"start":{"line":267,"column":6},"end":{"line":270,"column":9}},"181":{"start":{"line":268,"column":8},"end":{"line":268,"column":41}},"182":{"start":{"line":269,"column":8},"end":{"line":269,"column":15}},"183":{"start":{"line":272,"column":4},"end":{"line":280,"column":7}},"184":{"start":{"line":273,"column":15},"end":{"line":273,"column":16}},"185":{"start":{"line":274,"column":6},"end":{"line":279,"column":9}},"186":{"start":{"line":275,"column":8},"end":{"line":275,"column":41}},"187":{"start":{"line":276,"column":8},"end":{"line":276,"column":43}},"188":{"start":{"line":277,"column":8},"end":{"line":277,"column":90}},"189":{"start":{"line":278,"column":8},"end":{"line":278,"column":15}},"190":{"start":{"line":281,"column":4},"end":{"line":289,"column":7}},"191":{"start":{"line":282,"column":15},"end":{"line":282,"column":18}},"192":{"start":{"line":283,"column":6},"end":{"line":288,"column":9}},"193":{"start":{"line":284,"column":8},"end":{"line":284,"column":41}},"194":{"start":{"line":285,"column":8},"end":{"line":285,"column":43}},"195":{"start":{"line":286,"column":8},"end":{"line":286,"column":62}},"196":{"start":{"line":287,"column":8},"end":{"line":287,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":22},"end":{"line":38,"column":23}},"loc":{"start":{"line":38,"column":34},"end":{"line":291,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":29},"end":{"line":62,"column":30}},"loc":{"start":{"line":62,"column":41},"end":{"line":106,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":65},"end":{"line":63,"column":66}},"loc":{"start":{"line":63,"column":81},"end":{"line":79,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":70,"column":127},"end":{"line":70,"column":128}},"loc":{"start":{"line":70,"column":147},"end":{"line":78,"column":7}},"line":70},"12":{"name":"(anonymous_12)","decl":{"start":{"line":81,"column":48},"end":{"line":81,"column":49}},"loc":{"start":{"line":81,"column":60},"end":{"line":91,"column":5}},"line":81},"13":{"name":"(anonymous_13)","decl":{"start":{"line":87,"column":112},"end":{"line":87,"column":113}},"loc":{"start":{"line":87,"column":132},"end":{"line":90,"column":7}},"line":87},"14":{"name":"(anonymous_14)","decl":{"start":{"line":92,"column":77},"end":{"line":92,"column":78}},"loc":{"start":{"line":92,"column":93},"end":{"line":105,"column":5}},"line":92},"15":{"name":"(anonymous_15)","decl":{"start":{"line":99,"column":93},"end":{"line":99,"column":94}},"loc":{"start":{"line":99,"column":113},"end":{"line":104,"column":7}},"line":99},"16":{"name":"(anonymous_16)","decl":{"start":{"line":108,"column":29},"end":{"line":108,"column":30}},"loc":{"start":{"line":108,"column":41},"end":{"line":142,"column":3}},"line":108},"17":{"name":"(anonymous_17)","decl":{"start":{"line":109,"column":70},"end":{"line":109,"column":71}},"loc":{"start":{"line":109,"column":86},"end":{"line":116,"column":5}},"line":109},"18":{"name":"(anonymous_18)","decl":{"start":{"line":110,"column":111},"end":{"line":110,"column":112}},"loc":{"start":{"line":110,"column":131},"end":{"line":115,"column":7}},"line":110},"19":{"name":"(anonymous_19)","decl":{"start":{"line":117,"column":76},"end":{"line":117,"column":77}},"loc":{"start":{"line":117,"column":92},"end":{"line":125,"column":5}},"line":117},"20":{"name":"(anonymous_20)","decl":{"start":{"line":118,"column":78},"end":{"line":118,"column":79}},"loc":{"start":{"line":118,"column":98},"end":{"line":124,"column":7}},"line":118},"21":{"name":"(anonymous_21)","decl":{"start":{"line":126,"column":65},"end":{"line":126,"column":66}},"loc":{"start":{"line":126,"column":81},"end":{"line":133,"column":5}},"line":126},"22":{"name":"(anonymous_22)","decl":{"start":{"line":128,"column":126},"end":{"line":128,"column":127}},"loc":{"start":{"line":128,"column":146},"end":{"line":132,"column":7}},"line":128},"23":{"name":"(anonymous_23)","decl":{"start":{"line":134,"column":66},"end":{"line":134,"column":67}},"loc":{"start":{"line":134,"column":82},"end":{"line":141,"column":5}},"line":134},"24":{"name":"(anonymous_24)","decl":{"start":{"line":136,"column":127},"end":{"line":136,"column":128}},"loc":{"start":{"line":136,"column":147},"end":{"line":140,"column":7}},"line":136},"25":{"name":"(anonymous_25)","decl":{"start":{"line":144,"column":32},"end":{"line":144,"column":33}},"loc":{"start":{"line":144,"column":44},"end":{"line":217,"column":3}},"line":144},"26":{"name":"(anonymous_26)","decl":{"start":{"line":145,"column":58},"end":{"line":145,"column":59}},"loc":{"start":{"line":145,"column":74},"end":{"line":153,"column":5}},"line":145},"27":{"name":"(anonymous_27)","decl":{"start":{"line":147,"column":131},"end":{"line":147,"column":132}},"loc":{"start":{"line":147,"column":151},"end":{"line":152,"column":7}},"line":147},"28":{"name":"(anonymous_28)","decl":{"start":{"line":154,"column":49},"end":{"line":154,"column":50}},"loc":{"start":{"line":154,"column":65},"end":{"line":164,"column":5}},"line":154},"29":{"name":"(anonymous_29)","decl":{"start":{"line":156,"column":131},"end":{"line":156,"column":132}},"loc":{"start":{"line":156,"column":151},"end":{"line":163,"column":7}},"line":156},"30":{"name":"(anonymous_30)","decl":{"start":{"line":165,"column":81},"end":{"line":165,"column":82}},"loc":{"start":{"line":165,"column":97},"end":{"line":173,"column":5}},"line":165},"31":{"name":"(anonymous_31)","decl":{"start":{"line":167,"column":137},"end":{"line":167,"column":138}},"loc":{"start":{"line":167,"column":157},"end":{"line":172,"column":7}},"line":167},"32":{"name":"(anonymous_32)","decl":{"start":{"line":174,"column":77},"end":{"line":174,"column":78}},"loc":{"start":{"line":174,"column":93},"end":{"line":185,"column":5}},"line":174},"33":{"name":"(anonymous_33)","decl":{"start":{"line":176,"column":131},"end":{"line":176,"column":132}},"loc":{"start":{"line":176,"column":151},"end":{"line":184,"column":7}},"line":176},"34":{"name":"(anonymous_34)","decl":{"start":{"line":186,"column":80},"end":{"line":186,"column":81}},"loc":{"start":{"line":186,"column":96},"end":{"line":194,"column":5}},"line":186},"35":{"name":"(anonymous_35)","decl":{"start":{"line":188,"column":137},"end":{"line":188,"column":138}},"loc":{"start":{"line":188,"column":157},"end":{"line":193,"column":7}},"line":188},"36":{"name":"(anonymous_36)","decl":{"start":{"line":195,"column":71},"end":{"line":195,"column":72}},"loc":{"start":{"line":195,"column":87},"end":{"line":205,"column":5}},"line":195},"37":{"name":"(anonymous_37)","decl":{"start":{"line":197,"column":131},"end":{"line":197,"column":132}},"loc":{"start":{"line":197,"column":151},"end":{"line":204,"column":7}},"line":197},"38":{"name":"(anonymous_38)","decl":{"start":{"line":206,"column":61},"end":{"line":206,"column":62}},"loc":{"start":{"line":206,"column":77},"end":{"line":216,"column":5}},"line":206},"39":{"name":"(anonymous_39)","decl":{"start":{"line":208,"column":132},"end":{"line":208,"column":133}},"loc":{"start":{"line":208,"column":152},"end":{"line":214,"column":7}},"line":208},"40":{"name":"(anonymous_40)","decl":{"start":{"line":219,"column":33},"end":{"line":219,"column":34}},"loc":{"start":{"line":219,"column":45},"end":{"line":255,"column":3}},"line":219},"41":{"name":"(anonymous_41)","decl":{"start":{"line":220,"column":69},"end":{"line":220,"column":70}},"loc":{"start":{"line":220,"column":85},"end":{"line":229,"column":5}},"line":220},"42":{"name":"(anonymous_42)","decl":{"start":{"line":222,"column":151},"end":{"line":222,"column":152}},"loc":{"start":{"line":222,"column":171},"end":{"line":228,"column":7}},"line":222},"43":{"name":"(anonymous_43)","decl":{"start":{"line":230,"column":94},"end":{"line":230,"column":95}},"loc":{"start":{"line":230,"column":110},"end":{"line":238,"column":5}},"line":230},"44":{"name":"(anonymous_44)","decl":{"start":{"line":232,"column":163},"end":{"line":232,"column":164}},"loc":{"start":{"line":232,"column":183},"end":{"line":237,"column":7}},"line":232},"45":{"name":"(anonymous_45)","decl":{"start":{"line":239,"column":74},"end":{"line":239,"column":75}},"loc":{"start":{"line":239,"column":90},"end":{"line":245,"column":5}},"line":239},"46":{"name":"(anonymous_46)","decl":{"start":{"line":241,"column":146},"end":{"line":241,"column":147}},"loc":{"start":{"line":241,"column":166},"end":{"line":244,"column":7}},"line":241},"47":{"name":"(anonymous_47)","decl":{"start":{"line":246,"column":80},"end":{"line":246,"column":81}},"loc":{"start":{"line":246,"column":96},"end":{"line":254,"column":5}},"line":246},"48":{"name":"(anonymous_48)","decl":{"start":{"line":248,"column":145},"end":{"line":248,"column":146}},"loc":{"start":{"line":248,"column":165},"end":{"line":253,"column":7}},"line":248},"49":{"name":"(anonymous_49)","decl":{"start":{"line":257,"column":34},"end":{"line":257,"column":35}},"loc":{"start":{"line":257,"column":46},"end":{"line":290,"column":3}},"line":257},"50":{"name":"(anonymous_50)","decl":{"start":{"line":258,"column":64},"end":{"line":258,"column":65}},"loc":{"start":{"line":258,"column":80},"end":{"line":264,"column":5}},"line":258},"51":{"name":"(anonymous_51)","decl":{"start":{"line":260,"column":121},"end":{"line":260,"column":122}},"loc":{"start":{"line":260,"column":141},"end":{"line":263,"column":7}},"line":260},"52":{"name":"(anonymous_52)","decl":{"start":{"line":265,"column":60},"end":{"line":265,"column":61}},"loc":{"start":{"line":265,"column":76},"end":{"line":271,"column":5}},"line":265},"53":{"name":"(anonymous_53)","decl":{"start":{"line":267,"column":120},"end":{"line":267,"column":121}},"loc":{"start":{"line":267,"column":140},"end":{"line":270,"column":7}},"line":267},"54":{"name":"(anonymous_54)","decl":{"start":{"line":272,"column":77},"end":{"line":272,"column":78}},"loc":{"start":{"line":272,"column":93},"end":{"line":280,"column":5}},"line":272},"55":{"name":"(anonymous_55)","decl":{"start":{"line":274,"column":124},"end":{"line":274,"column":125}},"loc":{"start":{"line":274,"column":144},"end":{"line":279,"column":7}},"line":274},"56":{"name":"(anonymous_56)","decl":{"start":{"line":281,"column":63},"end":{"line":281,"column":64}},"loc":{"start":{"line":281,"column":79},"end":{"line":289,"column":5}},"line":281},"57":{"name":"(anonymous_57)","decl":{"start":{"line":283,"column":118},"end":{"line":283,"column":119}},"loc":{"start":{"line":283,"column":138},"end":{"line":288,"column":7}},"line":283}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":0,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":0,"140":0,"141":0,"142":0,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":0,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"9950cafa7535719075ca08f761476020d23ba2d4","contentHash":"2831e31d3c9421fa210c6980425495e9_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":49}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"5":{"start":{"line":15,"column":13},"end":{"line":17,"column":2}},"6":{"start":{"line":16,"column":2},"end":{"line":16,"column":63}},"7":{"start":{"line":19,"column":0},"end":{"line":19,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":44},"end":{"line":15,"column":45}},"loc":{"start":{"line":15,"column":56},"end":{"line":17,"column":1}},"line":15}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"type":"binary-expr","locations":[{"start":{"line":13,"column":11},"end":{"line":13,"column":27}},{"start":{"line":13,"column":31},"end":{"line":13,"column":35}}],"line":13}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1},"f":{"0":1,"1":1},"b":{"0":[1,0],"1":[1,1],"2":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"2c3f4d308d6c389ee08f6e68cdad1a35bf84c346","contentHash":"b011e4774c730a6764287d46023c385e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"4":{"start":{"line":13,"column":19},"end":{"line":13,"column":54}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":31}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":24},"end":{"line":19,"column":52}},"8":{"start":{"line":21,"column":25},"end":{"line":21,"column":66}},"9":{"start":{"line":23,"column":14},"end":{"line":23,"column":34}},"10":{"start":{"line":25,"column":15},"end":{"line":25,"column":46}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":10},"end":{"line":29,"column":34}},"13":{"start":{"line":31,"column":0},"end":{"line":31,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":37}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":62}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":43}},"17":{"start":{"line":37,"column":0},"end":{"line":46,"column":3}},"18":{"start":{"line":38,"column":13},"end":{"line":38,"column":21}},"19":{"start":{"line":39,"column":13},"end":{"line":39,"column":18}},"20":{"start":{"line":40,"column":2},"end":{"line":44,"column":4}},"21":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"22":{"start":{"line":41,"column":14},"end":{"line":41,"column":21}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":25}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":16}},"25":{"start":{"line":45,"column":2},"end":{"line":45,"column":9}},"26":{"start":{"line":49,"column":0},"end":{"line":49,"column":37}},"27":{"start":{"line":51,"column":0},"end":{"line":51,"column":22}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":8},"end":{"line":37,"column":9}},"loc":{"start":{"line":37,"column":34},"end":{"line":46,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":13},"end":{"line":40,"column":14}},"loc":{"start":{"line":40,"column":29},"end":{"line":44,"column":3}},"line":40}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27},"2":{"loc":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"type":"if","locations":[{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},{"start":{"line":41,"column":4},"end":{"line":41,"column":21}}],"line":41}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":76,"19":76,"20":76,"21":106,"22":4,"23":102,"24":102,"25":76,"26":1,"27":1},"f":{"0":5,"1":76,"2":106},"b":{"0":[1,4],"1":[5,5],"2":[4,102]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"631ffa56d34b584cfaaf514a9d3aab5ddb9550d2","contentHash":"68477734160cec3adc5d527b8a040a9b_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":31}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":33}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":17},"end":{"line":19,"column":39}},"8":{"start":{"line":21,"column":18},"end":{"line":21,"column":52}},"9":{"start":{"line":23,"column":13},"end":{"line":23,"column":31}},"10":{"start":{"line":25,"column":14},"end":{"line":25,"column":44}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":13},"end":{"line":29,"column":39}},"13":{"start":{"line":32,"column":0},"end":{"line":32,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":40}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":46}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":38}},"17":{"start":{"line":37,"column":0},"end":{"line":37,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1},"f":{"0":5},"b":{"0":[4,1],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"242d65573f043ccce04223bd6f51cdda15503f5f","contentHash":"3a58cb6f4391326b95f0cf67e2d870a0_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":34}},"10":{"start":{"line":30,"column":0},"end":{"line":32,"column":29}},"11":{"start":{"line":34,"column":0},"end":{"line":42,"column":64}},"12":{"start":{"line":44,"column":0},"end":{"line":46,"column":67}},"13":{"start":{"line":48,"column":0},"end":{"line":48,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a4c38addb0d124dbae4b2d5ea8e6e3d38cf94991","contentHash":"b6e317aa7a985adf5a98d45b1aa5fd24_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":20},"end":{"line":11,"column":43}},"4":{"start":{"line":13,"column":21},"end":{"line":13,"column":58}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"8":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"9":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"10":{"start":{"line":25,"column":0},"end":{"line":25,"column":27}},"11":{"start":{"line":27,"column":16},"end":{"line":27,"column":38}},"12":{"start":{"line":28,"column":15},"end":{"line":28,"column":40}},"13":{"start":{"line":29,"column":11},"end":{"line":29,"column":32}},"14":{"start":{"line":30,"column":15},"end":{"line":30,"column":50}},"15":{"start":{"line":39,"column":14},"end":{"line":39,"column":29}},"16":{"start":{"line":40,"column":15},"end":{"line":40,"column":31}},"17":{"start":{"line":41,"column":2},"end":{"line":54,"column":5}},"18":{"start":{"line":45,"column":15},"end":{"line":45,"column":24}},"19":{"start":{"line":46,"column":16},"end":{"line":46,"column":26}},"20":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"21":{"start":{"line":53,"column":4},"end":{"line":53,"column":39}},"22":{"start":{"line":64,"column":2},"end":{"line":64,"column":59}},"23":{"start":{"line":65,"column":2},"end":{"line":65,"column":59}},"24":{"start":{"line":66,"column":2},"end":{"line":66,"column":53}},"25":{"start":{"line":67,"column":2},"end":{"line":67,"column":59}},"26":{"start":{"line":68,"column":2},"end":{"line":68,"column":59}},"27":{"start":{"line":69,"column":2},"end":{"line":69,"column":85}},"28":{"start":{"line":70,"column":15},"end":{"line":70,"column":37}},"29":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"30":{"start":{"line":73,"column":4},"end":{"line":73,"column":45}},"31":{"start":{"line":75,"column":4},"end":{"line":95,"column":7}},"32":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"33":{"start":{"line":79,"column":8},"end":{"line":93,"column":11}},"34":{"start":{"line":86,"column":10},"end":{"line":90,"column":13}},"35":{"start":{"line":92,"column":10},"end":{"line":92,"column":38}},"36":{"start":{"line":106,"column":2},"end":{"line":106,"column":53}},"37":{"start":{"line":107,"column":2},"end":{"line":107,"column":59}},"38":{"start":{"line":108,"column":2},"end":{"line":108,"column":59}},"39":{"start":{"line":110,"column":15},"end":{"line":110,"column":37}},"40":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"41":{"start":{"line":113,"column":4},"end":{"line":113,"column":45}},"42":{"start":{"line":115,"column":4},"end":{"line":147,"column":7}},"43":{"start":{"line":118,"column":25},"end":{"line":118,"column":32}},"44":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"45":{"start":{"line":120,"column":8},"end":{"line":122,"column":63}},"46":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"47":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":125,"column":24},"end":{"line":130,"column":11}},"49":{"start":{"line":131,"column":22},"end":{"line":133,"column":12}},"50":{"start":{"line":134,"column":10},"end":{"line":137,"column":13}},"51":{"start":{"line":139,"column":10},"end":{"line":142,"column":13}},"52":{"start":{"line":146,"column":6},"end":{"line":146,"column":41}},"53":{"start":{"line":158,"column":18},"end":{"line":158,"column":39}},"54":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"55":{"start":{"line":160,"column":4},"end":{"line":162,"column":7}},"56":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"57":{"start":{"line":165,"column":4},"end":{"line":167,"column":7}},"58":{"start":{"line":169,"column":2},"end":{"line":181,"column":5}},"59":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"60":{"start":{"line":176,"column":6},"end":{"line":176,"column":58}},"61":{"start":{"line":178,"column":4},"end":{"line":178,"column":31}},"62":{"start":{"line":180,"column":4},"end":{"line":180,"column":39}},"63":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"64":{"start":{"line":192,"column":4},"end":{"line":194,"column":7}},"65":{"start":{"line":196,"column":15},"end":{"line":196,"column":36}},"66":{"start":{"line":197,"column":2},"end":{"line":225,"column":5}},"67":{"start":{"line":198,"column":4},"end":{"line":224,"column":7}},"68":{"start":{"line":199,"column":6},"end":{"line":223,"column":9}},"69":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"70":{"start":{"line":201,"column":10},"end":{"line":201,"column":69}},"71":{"start":{"line":203,"column":8},"end":{"line":220,"column":11}},"72":{"start":{"line":210,"column":10},"end":{"line":217,"column":13}},"73":{"start":{"line":219,"column":10},"end":{"line":219,"column":45}},"74":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"75":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"76":{"start":{"line":236,"column":4},"end":{"line":238,"column":7}},"77":{"start":{"line":240,"column":2},"end":{"line":252,"column":5}},"78":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"79":{"start":{"line":242,"column":6},"end":{"line":242,"column":65}},"80":{"start":{"line":244,"column":4},"end":{"line":249,"column":7}},"81":{"start":{"line":245,"column":6},"end":{"line":246,"column":57}},"82":{"start":{"line":248,"column":6},"end":{"line":248,"column":41}},"83":{"start":{"line":251,"column":4},"end":{"line":251,"column":39}},"84":{"start":{"line":263,"column":14},"end":{"line":263,"column":29}},"85":{"start":{"line":264,"column":15},"end":{"line":264,"column":31}},"86":{"start":{"line":265,"column":2},"end":{"line":290,"column":5}},"87":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"88":{"start":{"line":267,"column":6},"end":{"line":269,"column":9}},"89":{"start":{"line":271,"column":4},"end":{"line":287,"column":7}},"90":{"start":{"line":278,"column":21},"end":{"line":278,"column":31}},"91":{"start":{"line":279,"column":18},"end":{"line":279,"column":29}},"92":{"start":{"line":281,"column":6},"end":{"line":284,"column":9}},"93":{"start":{"line":286,"column":6},"end":{"line":286,"column":41}},"94":{"start":{"line":289,"column":4},"end":{"line":289,"column":39}},"95":{"start":{"line":293,"column":0},"end":{"line":301,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"getUsers","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":17}},"loc":{"start":{"line":38,"column":28},"end":{"line":55,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":44,"column":10},"end":{"line":44,"column":11}},"loc":{"start":{"line":44,"column":26},"end":{"line":52,"column":3}},"line":44},"3":{"name":"(anonymous_3)","decl":{"start":{"line":52,"column":11},"end":{"line":52,"column":12}},"loc":{"start":{"line":52,"column":28},"end":{"line":54,"column":3}},"line":52},"4":{"name":"createUser","decl":{"start":{"line":63,"column":9},"end":{"line":63,"column":19}},"loc":{"start":{"line":63,"column":30},"end":{"line":97,"column":1}},"line":63},"5":{"name":"(anonymous_5)","decl":{"start":{"line":77,"column":12},"end":{"line":77,"column":13}},"loc":{"start":{"line":77,"column":33},"end":{"line":95,"column":5}},"line":77},"6":{"name":"(anonymous_6)","decl":{"start":{"line":85,"column":16},"end":{"line":85,"column":17}},"loc":{"start":{"line":85,"column":39},"end":{"line":91,"column":9}},"line":85},"7":{"name":"(anonymous_7)","decl":{"start":{"line":91,"column":17},"end":{"line":91,"column":18}},"loc":{"start":{"line":91,"column":34},"end":{"line":93,"column":9}},"line":91},"8":{"name":"login","decl":{"start":{"line":105,"column":9},"end":{"line":105,"column":14}},"loc":{"start":{"line":105,"column":25},"end":{"line":149,"column":1}},"line":105},"9":{"name":"(anonymous_9)","decl":{"start":{"line":117,"column":12},"end":{"line":117,"column":13}},"loc":{"start":{"line":117,"column":28},"end":{"line":145,"column":5}},"line":117},"10":{"name":"(anonymous_10)","decl":{"start":{"line":145,"column":13},"end":{"line":145,"column":14}},"loc":{"start":{"line":145,"column":30},"end":{"line":147,"column":5}},"line":145},"11":{"name":"findUser","decl":{"start":{"line":157,"column":9},"end":{"line":157,"column":17}},"loc":{"start":{"line":157,"column":28},"end":{"line":182,"column":1}},"line":157},"12":{"name":"(anonymous_12)","decl":{"start":{"line":174,"column":10},"end":{"line":174,"column":11}},"loc":{"start":{"line":174,"column":26},"end":{"line":179,"column":3}},"line":174},"13":{"name":"(anonymous_13)","decl":{"start":{"line":179,"column":11},"end":{"line":179,"column":12}},"loc":{"start":{"line":179,"column":28},"end":{"line":181,"column":3}},"line":179},"14":{"name":"updateUser","decl":{"start":{"line":190,"column":9},"end":{"line":190,"column":19}},"loc":{"start":{"line":190,"column":30},"end":{"line":226,"column":1}},"line":190},"15":{"name":"(anonymous_15)","decl":{"start":{"line":197,"column":31},"end":{"line":197,"column":32}},"loc":{"start":{"line":197,"column":52},"end":{"line":225,"column":3}},"line":197},"16":{"name":"(anonymous_16)","decl":{"start":{"line":198,"column":51},"end":{"line":198,"column":52}},"loc":{"start":{"line":198,"column":72},"end":{"line":224,"column":5}},"line":198},"17":{"name":"(anonymous_17)","decl":{"start":{"line":199,"column":33},"end":{"line":199,"column":34}},"loc":{"start":{"line":199,"column":49},"end":{"line":221,"column":7}},"line":199},"18":{"name":"(anonymous_18)","decl":{"start":{"line":209,"column":16},"end":{"line":209,"column":17}},"loc":{"start":{"line":209,"column":39},"end":{"line":218,"column":9}},"line":209},"19":{"name":"(anonymous_19)","decl":{"start":{"line":218,"column":17},"end":{"line":218,"column":18}},"loc":{"start":{"line":218,"column":34},"end":{"line":220,"column":9}},"line":218},"20":{"name":"(anonymous_20)","decl":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"loc":{"start":{"line":221,"column":32},"end":{"line":223,"column":7}},"line":221},"21":{"name":"deleteUser","decl":{"start":{"line":234,"column":9},"end":{"line":234,"column":19}},"loc":{"start":{"line":234,"column":30},"end":{"line":253,"column":1}},"line":234},"22":{"name":"(anonymous_22)","decl":{"start":{"line":240,"column":43},"end":{"line":240,"column":44}},"loc":{"start":{"line":240,"column":59},"end":{"line":250,"column":3}},"line":240},"23":{"name":"(anonymous_23)","decl":{"start":{"line":244,"column":31},"end":{"line":244,"column":32}},"loc":{"start":{"line":244,"column":43},"end":{"line":247,"column":5}},"line":244},"24":{"name":"(anonymous_24)","decl":{"start":{"line":247,"column":13},"end":{"line":247,"column":14}},"loc":{"start":{"line":247,"column":30},"end":{"line":249,"column":5}},"line":247},"25":{"name":"(anonymous_25)","decl":{"start":{"line":250,"column":11},"end":{"line":250,"column":12}},"loc":{"start":{"line":250,"column":28},"end":{"line":252,"column":3}},"line":250},"26":{"name":"getUserDocuments","decl":{"start":{"line":262,"column":9},"end":{"line":262,"column":25}},"loc":{"start":{"line":262,"column":36},"end":{"line":291,"column":1}},"line":262},"27":{"name":"(anonymous_27)","decl":{"start":{"line":265,"column":36},"end":{"line":265,"column":37}},"loc":{"start":{"line":265,"column":52},"end":{"line":288,"column":3}},"line":265},"28":{"name":"(anonymous_28)","decl":{"start":{"line":277,"column":12},"end":{"line":277,"column":13}},"loc":{"start":{"line":277,"column":29},"end":{"line":285,"column":5}},"line":277},"29":{"name":"(anonymous_29)","decl":{"start":{"line":285,"column":13},"end":{"line":285,"column":14}},"loc":{"start":{"line":285,"column":30},"end":{"line":287,"column":5}},"line":285},"30":{"name":"(anonymous_30)","decl":{"start":{"line":288,"column":11},"end":{"line":288,"column":12}},"loc":{"start":{"line":288,"column":28},"end":{"line":290,"column":3}},"line":288}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23},"2":{"loc":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},{"start":{"line":72,"column":2},"end":{"line":96,"column":3}}],"line":72},"3":{"loc":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"type":"if","locations":[{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},{"start":{"line":78,"column":6},"end":{"line":94,"column":7}}],"line":78},"4":{"loc":{"start":{"line":84,"column":18},"end":{"line":84,"column":38}},"type":"binary-expr","locations":[{"start":{"line":84,"column":18},"end":{"line":84,"column":33}},{"start":{"line":84,"column":37},"end":{"line":84,"column":38}}],"line":84},"5":{"loc":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"type":"if","locations":[{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},{"start":{"line":112,"column":2},"end":{"line":148,"column":3}}],"line":112},"6":{"loc":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},{"start":{"line":119,"column":6},"end":{"line":144,"column":7}}],"line":119},"7":{"loc":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},{"start":{"line":123,"column":13},"end":{"line":144,"column":7}}],"line":123},"8":{"loc":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"type":"if","locations":[{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},{"start":{"line":124,"column":8},"end":{"line":143,"column":9}}],"line":124},"9":{"loc":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"type":"if","locations":[{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},{"start":{"line":159,"column":2},"end":{"line":163,"column":3}}],"line":159},"10":{"loc":{"start":{"line":159,"column":6},"end":{"line":159,"column":62}},"type":"binary-expr","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":34}},{"start":{"line":159,"column":38},"end":{"line":159,"column":62}}],"line":159},"11":{"loc":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},{"start":{"line":164,"column":2},"end":{"line":168,"column":3}}],"line":164},"12":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"13":{"loc":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"type":"if","locations":[{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},{"start":{"line":191,"column":2},"end":{"line":195,"column":3}}],"line":191},"14":{"loc":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"type":"if","locations":[{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},{"start":{"line":200,"column":8},"end":{"line":202,"column":9}}],"line":200},"15":{"loc":{"start":{"line":204,"column":20},"end":{"line":204,"column":54}},"type":"binary-expr","locations":[{"start":{"line":204,"column":20},"end":{"line":204,"column":37}},{"start":{"line":204,"column":41},"end":{"line":204,"column":54}}],"line":204},"16":{"loc":{"start":{"line":205,"column":20},"end":{"line":205,"column":54}},"type":"binary-expr","locations":[{"start":{"line":205,"column":20},"end":{"line":205,"column":37}},{"start":{"line":205,"column":41},"end":{"line":205,"column":54}}],"line":205},"17":{"loc":{"start":{"line":206,"column":17},"end":{"line":206,"column":45}},"type":"binary-expr","locations":[{"start":{"line":206,"column":17},"end":{"line":206,"column":31}},{"start":{"line":206,"column":35},"end":{"line":206,"column":45}}],"line":206},"18":{"loc":{"start":{"line":207,"column":20},"end":{"line":207,"column":41}},"type":"binary-expr","locations":[{"start":{"line":207,"column":20},"end":{"line":207,"column":24}},{"start":{"line":207,"column":28},"end":{"line":207,"column":41}}],"line":207},"19":{"loc":{"start":{"line":208,"column":18},"end":{"line":208,"column":48}},"type":"binary-expr","locations":[{"start":{"line":208,"column":18},"end":{"line":208,"column":33}},{"start":{"line":208,"column":37},"end":{"line":208,"column":48}}],"line":208},"20":{"loc":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"type":"if","locations":[{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},{"start":{"line":235,"column":2},"end":{"line":239,"column":3}}],"line":235},"21":{"loc":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},{"start":{"line":241,"column":4},"end":{"line":243,"column":5}}],"line":241},"22":{"loc":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"type":"if","locations":[{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},{"start":{"line":266,"column":4},"end":{"line":270,"column":5}}],"line":266}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":4,"10":1,"11":1,"12":1,"13":1,"14":1,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":0,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":0,"31":1,"32":1,"33":1,"34":1,"35":0,"36":15,"37":15,"38":15,"39":15,"40":15,"41":0,"42":15,"43":15,"44":15,"45":1,"46":14,"47":14,"48":13,"49":13,"50":13,"51":1,"52":0,"53":5,"54":5,"55":0,"56":5,"57":1,"58":4,"59":3,"60":1,"61":3,"62":1,"63":5,"64":2,"65":3,"66":3,"67":3,"68":3,"69":3,"70":0,"71":3,"72":3,"73":0,"74":0,"75":3,"76":1,"77":2,"78":2,"79":1,"80":1,"81":1,"82":0,"83":0,"84":2,"85":2,"86":2,"87":2,"88":1,"89":1,"90":1,"91":1,"92":1,"93":0,"94":0,"95":1},"f":{"0":4,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":15,"9":15,"10":0,"11":5,"12":3,"13":1,"14":5,"15":3,"16":3,"17":3,"18":3,"19":0,"20":0,"21":3,"22":2,"23":1,"24":0,"25":0,"26":2,"27":2,"28":1,"29":0,"30":0},"b":{"0":[0,4],"1":[4,4],"2":[0,1],"3":[1,0],"4":[1,0],"5":[0,15],"6":[1,14],"7":[14,0],"8":[13,1],"9":[0,5],"10":[5,4],"11":[1,4],"12":[1,2],"13":[2,3],"14":[0,3],"15":[3,2],"16":[3,2],"17":[3,2],"18":[3,3],"19":[3,3],"20":[1,2],"21":[1,1],"22":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a873f3a1e83910dd4a7534a9fab6445e85d48e8a","contentHash":"8f158652d1e645800e331a339c32bd94_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":10,"column":1}},"1":{"start":{"line":4,"column":2},"end":{"line":9,"column":4}},"2":{"start":{"line":12,"column":0},"end":{"line":12,"column":55}}},"fnMap":{"0":{"name":"paginationMetaData","decl":{"start":{"line":3,"column":34},"end":{"line":3,"column":52}},"loc":{"start":{"line":3,"column":75},"end":{"line":10,"column":1}},"line":3}},"branchMap":{},"s":{"0":1,"1":6,"2":1},"f":{"0":6},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"4465f4d163a5ad4fee78e39a1eef0f59ca60bcc2","contentHash":"65216cd25fbea3beb9fe0dfec073fc7e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js","statementMap":{"0":{"start":{"line":3,"column":9},"end":{"line":3,"column":22}},"1":{"start":{"line":4,"column":11},"end":{"line":4,"column":26}},"2":{"start":{"line":5,"column":16},"end":{"line":5,"column":36}},"3":{"start":{"line":7,"column":15},"end":{"line":7,"column":45}},"4":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"5":{"start":{"line":9,"column":13},"end":{"line":9,"column":48}},"6":{"start":{"line":11,"column":9},"end":{"line":11,"column":11}},"7":{"start":{"line":13,"column":16},"end":{"line":13,"column":22}},"8":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"9":{"start":{"line":15,"column":2},"end":{"line":15,"column":66}},"10":{"start":{"line":17,"column":2},"end":{"line":17,"column":87}},"11":{"start":{"line":20,"column":0},"end":{"line":25,"column":3}},"12":{"start":{"line":21,"column":2},"end":{"line":21,"column":82}},"13":{"start":{"line":23,"column":14},"end":{"line":23,"column":58}},"14":{"start":{"line":24,"column":2},"end":{"line":24,"column":25}},"15":{"start":{"line":27,"column":0},"end":{"line":31,"column":3}},"16":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"17":{"start":{"line":29,"column":4},"end":{"line":29,"column":32}},"18":{"start":{"line":33,"column":0},"end":{"line":33,"column":25}},"19":{"start":{"line":34,"column":0},"end":{"line":34,"column":25}},"20":{"start":{"line":36,"column":0},"end":{"line":36,"column":20}},"21":{"start":{"line":38,"column":0},"end":{"line":38,"column":25}},"22":{"start":{"line":39,"column":0},"end":{"line":39,"column":25}},"23":{"start":{"line":41,"column":0},"end":{"line":41,"column":20}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":33},"end":{"line":20,"column":34}},"loc":{"start":{"line":20,"column":49},"end":{"line":22,"column":1}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":22,"column":11},"end":{"line":22,"column":12}},"loc":{"start":{"line":22,"column":27},"end":{"line":25,"column":1}},"line":22},"2":{"name":"(anonymous_2)","decl":{"start":{"line":27,"column":24},"end":{"line":27,"column":25}},"loc":{"start":{"line":27,"column":45},"end":{"line":31,"column":1}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"type":"binary-expr","locations":[{"start":{"line":8,"column":10},"end":{"line":8,"column":30}},{"start":{"line":8,"column":34},"end":{"line":8,"column":47}}],"line":8},"1":{"loc":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"type":"if","locations":[{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},{"start":{"line":14,"column":0},"end":{"line":18,"column":1}}],"line":14},"2":{"loc":{"start":{"line":21,"column":9},"end":{"line":21,"column":81}},"type":"binary-expr","locations":[{"start":{"line":21,"column":9},"end":{"line":21,"column":32}},{"start":{"line":21,"column":36},"end":{"line":21,"column":53}},{"start":{"line":21,"column":57},"end":{"line":21,"column":81}}],"line":21},"3":{"loc":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"type":"if","locations":[{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},{"start":{"line":28,"column":2},"end":{"line":30,"column":3}}],"line":28}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":1,"11":1,"12":4,"13":3,"14":3,"15":1,"16":3,"17":3,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1},"f":{"0":4,"1":3,"2":3},"b":{"0":[1,0],"1":[0,1],"2":[4,4,3],"3":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"873e872266ec01d9da7d7ec0d8cff9eeebab65b3","contentHash":"147d2f5ce718f5d34ee69e59b4b18b17_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":27,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a1ab92e502a6f44216fbf97c5e3b416d2cdd1c15","contentHash":"bfdbdb10808231c6b80faf6c05504184_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":30,"column":2}},"1":{"start":{"line":4,"column":17},"end":{"line":22,"column":4}},"2":{"start":{"line":23,"column":2},"end":{"line":28,"column":4}},"3":{"start":{"line":25,"column":4},"end":{"line":27,"column":7}},"4":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":30,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":23,"column":23},"end":{"line":23,"column":24}},"loc":{"start":{"line":23,"column":41},"end":{"line":28,"column":3}},"line":23}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"40f538af399cb910f51ef1c6e4b9fa7626ac8040","contentHash":"ebe8d40228054cd49ad96bbdc1301e25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":18,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":10,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":13,"column":4},"end":{"line":15,"column":7}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":18,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":11,"column":19},"end":{"line":11,"column":20}},"loc":{"start":{"line":11,"column":37},"end":{"line":16,"column":3}},"line":11}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1aba90d94e80bdb0379ea9ddd4c53cf22a593f71","contentHash":"b22cffd605cf93f69a3f2719a0d065e3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":42,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":28,"column":4}},"2":{"start":{"line":29,"column":2},"end":{"line":40,"column":4}},"3":{"start":{"line":31,"column":4},"end":{"line":35,"column":7}},"4":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"5":{"start":{"line":41,"column":2},"end":{"line":41,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":42,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":19},"end":{"line":29,"column":20}},"loc":{"start":{"line":29,"column":37},"end":{"line":40,"column":3}},"line":29}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1296338becccf35da8d16bf6f6a410038393a663","contentHash":"e3e5a8798513104b93e617b86fce0484_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":20},"end":{"line":7,"column":43}},"2":{"start":{"line":9,"column":21},"end":{"line":9,"column":58}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":16},"end":{"line":13,"column":38}},"5":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"6":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"7":{"start":{"line":18,"column":4},"end":{"line":25,"column":7}},"8":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"9":{"start":{"line":20,"column":8},"end":{"line":20,"column":79}},"10":{"start":{"line":22,"column":8},"end":{"line":22,"column":30}},"11":{"start":{"line":23,"column":8},"end":{"line":23,"column":15}},"12":{"start":{"line":27,"column":4},"end":{"line":30,"column":7}},"13":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"14":{"start":{"line":36,"column":4},"end":{"line":36,"column":11}},"15":{"start":{"line":38,"column":4},"end":{"line":40,"column":7}},"16":{"start":{"line":44,"column":0},"end":{"line":44,"column":73}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"verifyToken","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":20}},"loc":{"start":{"line":15,"column":37},"end":{"line":32,"column":1}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":18,"column":52},"end":{"line":18,"column":53}},"loc":{"start":{"line":18,"column":76},"end":{"line":25,"column":5}},"line":18},"3":{"name":"adminAccess","decl":{"start":{"line":34,"column":9},"end":{"line":34,"column":20}},"loc":{"start":{"line":34,"column":37},"end":{"line":42,"column":1}},"line":34}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"type":"binary-expr","locations":[{"start":{"line":16,"column":14},"end":{"line":16,"column":39}},{"start":{"line":16,"column":43},"end":{"line":16,"column":72}}],"line":16},"3":{"loc":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},{"start":{"line":17,"column":2},"end":{"line":31,"column":3}}],"line":17},"4":{"loc":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"type":"if","locations":[{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},{"start":{"line":19,"column":6},"end":{"line":24,"column":7}}],"line":19},"5":{"loc":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},{"start":{"line":35,"column":2},"end":{"line":41,"column":3}}],"line":35}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":60,"6":60,"7":56,"8":56,"9":0,"10":56,"11":56,"12":4,"13":21,"14":15,"15":6,"16":1},"f":{"0":1,"1":60,"2":56,"3":21},"b":{"0":[0,1],"1":[1,1],"2":[60,4],"3":[56,4],"4":[0,56],"5":[15,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ecc14d1e97432b8e57f39e5c505683a335fe6c8b","contentHash":"319c6e9c3dd86dee4e26cb1f933899cc_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":46}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":25,"column":90}},"10":{"start":{"line":27,"column":0},"end":{"line":29,"column":95}},"11":{"start":{"line":31,"column":0},"end":{"line":31,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"68b3619793c37e6d78583f4e6d35dc746e22808b","contentHash":"1708591ee5a07428c3cfae7deaa863aa_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":20},"end":{"line":28,"column":31}},"10":{"start":{"line":29,"column":14},"end":{"line":29,"column":29}},"11":{"start":{"line":30,"column":15},"end":{"line":30,"column":31}},"12":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"13":{"start":{"line":32,"column":4},"end":{"line":34,"column":7}},"14":{"start":{"line":36,"column":2},"end":{"line":58,"column":5}},"15":{"start":{"line":46,"column":15},"end":{"line":46,"column":24}},"16":{"start":{"line":47,"column":16},"end":{"line":47,"column":26}},"17":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"18":{"start":{"line":50,"column":6},"end":{"line":50,"column":65}},"19":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"20":{"start":{"line":57,"column":4},"end":{"line":57,"column":39}},"21":{"start":{"line":69,"column":14},"end":{"line":69,"column":29}},"22":{"start":{"line":70,"column":15},"end":{"line":70,"column":31}},"23":{"start":{"line":71,"column":20},"end":{"line":71,"column":31}},"24":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"25":{"start":{"line":73,"column":4},"end":{"line":75,"column":7}},"26":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"27":{"start":{"line":78,"column":4},"end":{"line":106,"column":7}},"28":{"start":{"line":94,"column":21},"end":{"line":94,"column":31}},"29":{"start":{"line":95,"column":18},"end":{"line":95,"column":29}},"30":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"31":{"start":{"line":98,"column":8},"end":{"line":98,"column":64}},"32":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"33":{"start":{"line":105,"column":6},"end":{"line":105,"column":41}},"34":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"35":{"start":{"line":108,"column":4},"end":{"line":140,"column":7}},"36":{"start":{"line":128,"column":21},"end":{"line":128,"column":31}},"37":{"start":{"line":129,"column":18},"end":{"line":129,"column":29}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"39":{"start":{"line":132,"column":8},"end":{"line":132,"column":64}},"40":{"start":{"line":134,"column":6},"end":{"line":137,"column":9}},"41":{"start":{"line":139,"column":6},"end":{"line":139,"column":41}},"42":{"start":{"line":144,"column":0},"end":{"line":144,"column":79}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"searchUser","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":19}},"loc":{"start":{"line":27,"column":30},"end":{"line":59,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":45,"column":10},"end":{"line":45,"column":11}},"loc":{"start":{"line":45,"column":26},"end":{"line":56,"column":3}},"line":45},"3":{"name":"(anonymous_3)","decl":{"start":{"line":56,"column":11},"end":{"line":56,"column":12}},"loc":{"start":{"line":56,"column":28},"end":{"line":58,"column":3}},"line":56},"4":{"name":"searchDocuments","decl":{"start":{"line":68,"column":9},"end":{"line":68,"column":24}},"loc":{"start":{"line":68,"column":35},"end":{"line":142,"column":1}},"line":68},"5":{"name":"(anonymous_5)","decl":{"start":{"line":93,"column":12},"end":{"line":93,"column":13}},"loc":{"start":{"line":93,"column":29},"end":{"line":104,"column":5}},"line":93},"6":{"name":"(anonymous_6)","decl":{"start":{"line":104,"column":13},"end":{"line":104,"column":14}},"loc":{"start":{"line":104,"column":30},"end":{"line":106,"column":5}},"line":104},"7":{"name":"(anonymous_7)","decl":{"start":{"line":127,"column":12},"end":{"line":127,"column":13}},"loc":{"start":{"line":127,"column":29},"end":{"line":138,"column":5}},"line":127},"8":{"name":"(anonymous_8)","decl":{"start":{"line":138,"column":13},"end":{"line":138,"column":14}},"loc":{"start":{"line":138,"column":30},"end":{"line":140,"column":5}},"line":138}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"type":"if","locations":[{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},{"start":{"line":31,"column":2},"end":{"line":35,"column":3}}],"line":31},"3":{"loc":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"type":"if","locations":[{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},{"start":{"line":49,"column":4},"end":{"line":51,"column":5}}],"line":49},"4":{"loc":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},{"start":{"line":72,"column":2},"end":{"line":76,"column":3}}],"line":72},"5":{"loc":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},{"start":{"line":77,"column":2},"end":{"line":141,"column":3}}],"line":77},"6":{"loc":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"type":"if","locations":[{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},{"start":{"line":97,"column":6},"end":{"line":99,"column":7}}],"line":97},"7":{"loc":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},{"start":{"line":107,"column":9},"end":{"line":141,"column":3}}],"line":107},"8":{"loc":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"type":"if","locations":[{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},{"start":{"line":131,"column":6},"end":{"line":133,"column":7}}],"line":131}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,2],"1":[2,2],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"6efc7327907302db1883f00d2862afff115a5da3","contentHash":"50e871939ef4ea62c58b58df2dfa2014_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":17},"end":{"line":11,"column":52}},"4":{"start":{"line":13,"column":18},"end":{"line":13,"column":52}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":70}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":72}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63cb1e0c24d02fe76a86b13384c3b6510a628d08","contentHash":"befe059d51eace8d5b2b154e0976915f_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":2},"end":{"line":28,"column":53}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":57}},"11":{"start":{"line":30,"column":2},"end":{"line":30,"column":59}},"12":{"start":{"line":32,"column":15},"end":{"line":32,"column":37}},"13":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"14":{"start":{"line":35,"column":4},"end":{"line":35,"column":45}},"15":{"start":{"line":37,"column":4},"end":{"line":59,"column":7}},"16":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"17":{"start":{"line":43,"column":8},"end":{"line":52,"column":11}},"18":{"start":{"line":49,"column":10},"end":{"line":49,"column":56}},"19":{"start":{"line":51,"column":10},"end":{"line":51,"column":45}},"20":{"start":{"line":54,"column":6},"end":{"line":56,"column":9}},"21":{"start":{"line":58,"column":6},"end":{"line":58,"column":41}},"22":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"23":{"start":{"line":71,"column":4},"end":{"line":71,"column":27}},"24":{"start":{"line":73,"column":14},"end":{"line":73,"column":35}},"25":{"start":{"line":74,"column":2},"end":{"line":97,"column":5}},"26":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"27":{"start":{"line":76,"column":6},"end":{"line":78,"column":9}},"28":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"29":{"start":{"line":81,"column":6},"end":{"line":83,"column":9}},"30":{"start":{"line":85,"column":4},"end":{"line":94,"column":7}},"31":{"start":{"line":91,"column":6},"end":{"line":91,"column":44}},"32":{"start":{"line":93,"column":6},"end":{"line":93,"column":41}},"33":{"start":{"line":96,"column":4},"end":{"line":96,"column":39}},"34":{"start":{"line":107,"column":14},"end":{"line":107,"column":29}},"35":{"start":{"line":108,"column":15},"end":{"line":108,"column":31}},"36":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"37":{"start":{"line":110,"column":4},"end":{"line":132,"column":7}},"38":{"start":{"line":123,"column":21},"end":{"line":123,"column":30}},"39":{"start":{"line":124,"column":18},"end":{"line":124,"column":28}},"40":{"start":{"line":126,"column":6},"end":{"line":129,"column":9}},"41":{"start":{"line":131,"column":6},"end":{"line":131,"column":41}},"42":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"43":{"start":{"line":134,"column":4},"end":{"line":160,"column":7}},"44":{"start":{"line":151,"column":21},"end":{"line":151,"column":31}},"45":{"start":{"line":152,"column":18},"end":{"line":152,"column":29}},"46":{"start":{"line":154,"column":6},"end":{"line":157,"column":9}},"47":{"start":{"line":159,"column":6},"end":{"line":159,"column":41}},"48":{"start":{"line":171,"column":2},"end":{"line":203,"column":5}},"49":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"50":{"start":{"line":173,"column":6},"end":{"line":173,"column":62}},"51":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"52":{"start":{"line":176,"column":6},"end":{"line":176,"column":22}},"53":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"54":{"start":{"line":179,"column":6},"end":{"line":179,"column":44}},"55":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"56":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"57":{"start":{"line":183,"column":8},"end":{"line":185,"column":11}},"58":{"start":{"line":187,"column":6},"end":{"line":187,"column":44}},"59":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"60":{"start":{"line":190,"column":6},"end":{"line":199,"column":9}},"61":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"62":{"start":{"line":192,"column":10},"end":{"line":194,"column":13}},"63":{"start":{"line":196,"column":8},"end":{"line":196,"column":46}},"64":{"start":{"line":198,"column":8},"end":{"line":198,"column":43}},"65":{"start":{"line":202,"column":4},"end":{"line":202,"column":39}},"66":{"start":{"line":214,"column":2},"end":{"line":230,"column":5}},"67":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"68":{"start":{"line":216,"column":6},"end":{"line":216,"column":62}},"69":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"70":{"start":{"line":219,"column":6},"end":{"line":221,"column":9}},"71":{"start":{"line":223,"column":4},"end":{"line":227,"column":7}},"72":{"start":{"line":224,"column":6},"end":{"line":224,"column":80}},"73":{"start":{"line":226,"column":6},"end":{"line":226,"column":41}},"74":{"start":{"line":229,"column":4},"end":{"line":229,"column":39}},"75":{"start":{"line":233,"column":0},"end":{"line":238,"column":35}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"createDocument","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":23}},"loc":{"start":{"line":27,"column":34},"end":{"line":61,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":41,"column":12},"end":{"line":41,"column":13}},"loc":{"start":{"line":41,"column":32},"end":{"line":57,"column":5}},"line":41},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":16},"end":{"line":48,"column":17}},"loc":{"start":{"line":48,"column":44},"end":{"line":50,"column":9}},"line":48},"4":{"name":"(anonymous_4)","decl":{"start":{"line":50,"column":17},"end":{"line":50,"column":18}},"loc":{"start":{"line":50,"column":34},"end":{"line":52,"column":9}},"line":50},"5":{"name":"(anonymous_5)","decl":{"start":{"line":57,"column":13},"end":{"line":57,"column":14}},"loc":{"start":{"line":57,"column":30},"end":{"line":59,"column":5}},"line":57},"6":{"name":"updateDocument","decl":{"start":{"line":69,"column":9},"end":{"line":69,"column":23}},"loc":{"start":{"line":69,"column":34},"end":{"line":98,"column":1}},"line":69},"7":{"name":"(anonymous_7)","decl":{"start":{"line":74,"column":39},"end":{"line":74,"column":40}},"loc":{"start":{"line":74,"column":59},"end":{"line":95,"column":3}},"line":74},"8":{"name":"(anonymous_8)","decl":{"start":{"line":90,"column":12},"end":{"line":90,"column":13}},"loc":{"start":{"line":90,"column":24},"end":{"line":92,"column":5}},"line":90},"9":{"name":"(anonymous_9)","decl":{"start":{"line":92,"column":13},"end":{"line":92,"column":14}},"loc":{"start":{"line":92,"column":30},"end":{"line":94,"column":5}},"line":92},"10":{"name":"(anonymous_10)","decl":{"start":{"line":95,"column":11},"end":{"line":95,"column":12}},"loc":{"start":{"line":95,"column":28},"end":{"line":97,"column":3}},"line":95},"11":{"name":"getAllDocument","decl":{"start":{"line":106,"column":9},"end":{"line":106,"column":23}},"loc":{"start":{"line":106,"column":34},"end":{"line":162,"column":1}},"line":106},"12":{"name":"(anonymous_12)","decl":{"start":{"line":122,"column":12},"end":{"line":122,"column":13}},"loc":{"start":{"line":122,"column":28},"end":{"line":130,"column":5}},"line":122},"13":{"name":"(anonymous_13)","decl":{"start":{"line":130,"column":13},"end":{"line":130,"column":14}},"loc":{"start":{"line":130,"column":30},"end":{"line":132,"column":5}},"line":130},"14":{"name":"(anonymous_14)","decl":{"start":{"line":150,"column":12},"end":{"line":150,"column":13}},"loc":{"start":{"line":150,"column":29},"end":{"line":158,"column":5}},"line":150},"15":{"name":"(anonymous_15)","decl":{"start":{"line":158,"column":13},"end":{"line":158,"column":14}},"loc":{"start":{"line":158,"column":30},"end":{"line":160,"column":5}},"line":158},"16":{"name":"findDocument","decl":{"start":{"line":170,"column":9},"end":{"line":170,"column":21}},"loc":{"start":{"line":170,"column":32},"end":{"line":204,"column":1}},"line":170},"17":{"name":"(anonymous_17)","decl":{"start":{"line":171,"column":47},"end":{"line":171,"column":48}},"loc":{"start":{"line":171,"column":67},"end":{"line":201,"column":3}},"line":171},"18":{"name":"(anonymous_18)","decl":{"start":{"line":190,"column":66},"end":{"line":190,"column":67}},"loc":{"start":{"line":190,"column":91},"end":{"line":197,"column":7}},"line":190},"19":{"name":"(anonymous_19)","decl":{"start":{"line":197,"column":15},"end":{"line":197,"column":16}},"loc":{"start":{"line":197,"column":32},"end":{"line":199,"column":7}},"line":197},"20":{"name":"(anonymous_20)","decl":{"start":{"line":201,"column":11},"end":{"line":201,"column":12}},"loc":{"start":{"line":201,"column":28},"end":{"line":203,"column":3}},"line":201},"21":{"name":"deleteDocument","decl":{"start":{"line":213,"column":9},"end":{"line":213,"column":23}},"loc":{"start":{"line":213,"column":34},"end":{"line":231,"column":1}},"line":213},"22":{"name":"(anonymous_22)","decl":{"start":{"line":214,"column":47},"end":{"line":214,"column":48}},"loc":{"start":{"line":214,"column":67},"end":{"line":228,"column":3}},"line":214},"23":{"name":"(anonymous_23)","decl":{"start":{"line":223,"column":35},"end":{"line":223,"column":36}},"loc":{"start":{"line":223,"column":47},"end":{"line":225,"column":5}},"line":223},"24":{"name":"(anonymous_24)","decl":{"start":{"line":225,"column":13},"end":{"line":225,"column":14}},"loc":{"start":{"line":225,"column":30},"end":{"line":227,"column":5}},"line":225},"25":{"name":"(anonymous_25)","decl":{"start":{"line":228,"column":11},"end":{"line":228,"column":12}},"loc":{"start":{"line":228,"column":28},"end":{"line":230,"column":3}},"line":228}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},{"start":{"line":34,"column":2},"end":{"line":60,"column":3}}],"line":34},"3":{"loc":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"type":"if","locations":[{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},{"start":{"line":42,"column":6},"end":{"line":53,"column":7}}],"line":42},"4":{"loc":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"type":"if","locations":[{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},{"start":{"line":70,"column":2},"end":{"line":72,"column":3}}],"line":70},"5":{"loc":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},{"start":{"line":75,"column":4},"end":{"line":79,"column":5}}],"line":75},"6":{"loc":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"type":"if","locations":[{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},{"start":{"line":80,"column":4},"end":{"line":84,"column":5}}],"line":80},"7":{"loc":{"start":{"line":86,"column":13},"end":{"line":86,"column":45}},"type":"binary-expr","locations":[{"start":{"line":86,"column":13},"end":{"line":86,"column":27}},{"start":{"line":86,"column":31},"end":{"line":86,"column":45}}],"line":86},"8":{"loc":{"start":{"line":87,"column":15},"end":{"line":87,"column":51}},"type":"binary-expr","locations":[{"start":{"line":87,"column":15},"end":{"line":87,"column":31}},{"start":{"line":87,"column":35},"end":{"line":87,"column":51}}],"line":87},"9":{"loc":{"start":{"line":88,"column":14},"end":{"line":88,"column":47}},"type":"binary-expr","locations":[{"start":{"line":88,"column":14},"end":{"line":88,"column":28}},{"start":{"line":88,"column":32},"end":{"line":88,"column":47}}],"line":88},"10":{"loc":{"start":{"line":89,"column":14},"end":{"line":89,"column":48}},"type":"binary-expr","locations":[{"start":{"line":89,"column":14},"end":{"line":89,"column":29}},{"start":{"line":89,"column":33},"end":{"line":89,"column":48}}],"line":89},"11":{"loc":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},{"start":{"line":109,"column":2},"end":{"line":161,"column":3}}],"line":109},"12":{"loc":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},{"start":{"line":133,"column":9},"end":{"line":161,"column":3}}],"line":133},"13":{"loc":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},{"start":{"line":172,"column":4},"end":{"line":174,"column":5}}],"line":172},"14":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"15":{"loc":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"type":"if","locations":[{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},{"start":{"line":178,"column":4},"end":{"line":180,"column":5}}],"line":178},"16":{"loc":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"type":"if","locations":[{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},{"start":{"line":181,"column":4},"end":{"line":188,"column":5}}],"line":181},"17":{"loc":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"type":"if","locations":[{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},{"start":{"line":182,"column":6},"end":{"line":186,"column":7}}],"line":182},"18":{"loc":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"type":"if","locations":[{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},{"start":{"line":189,"column":4},"end":{"line":200,"column":5}}],"line":189},"19":{"loc":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"type":"if","locations":[{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},{"start":{"line":191,"column":8},"end":{"line":195,"column":9}}],"line":191},"20":{"loc":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"type":"if","locations":[{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},{"start":{"line":215,"column":4},"end":{"line":217,"column":5}}],"line":215},"21":{"loc":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"type":"if","locations":[{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},{"start":{"line":218,"column":4},"end":{"line":222,"column":5}}],"line":218},"22":{"loc":{"start":{"line":218,"column":8},"end":{"line":218,"column":86}},"type":"binary-expr","locations":[{"start":{"line":218,"column":8},"end":{"line":218,"column":32}},{"start":{"line":218,"column":36},"end":{"line":218,"column":86}}],"line":218}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":2,"10":2,"11":2,"12":2,"13":2,"14":1,"15":1,"16":1,"17":1,"18":1,"19":0,"20":0,"21":0,"22":4,"23":0,"24":4,"25":4,"26":4,"27":1,"28":3,"29":2,"30":1,"31":1,"32":0,"33":0,"34":3,"35":3,"36":3,"37":0,"38":0,"39":0,"40":0,"41":0,"42":3,"43":3,"44":3,"45":3,"46":3,"47":0,"48":7,"49":7,"50":1,"51":7,"52":1,"53":6,"54":1,"55":4,"56":2,"57":1,"58":1,"59":2,"60":2,"61":2,"62":1,"63":1,"64":0,"65":1,"66":4,"67":4,"68":1,"69":4,"70":1,"71":2,"72":2,"73":0,"74":1,"75":1},"f":{"0":2,"1":2,"2":1,"3":1,"4":0,"5":0,"6":4,"7":4,"8":1,"9":0,"10":0,"11":3,"12":0,"13":0,"14":3,"15":0,"16":7,"17":7,"18":2,"19":0,"20":1,"21":4,"22":4,"23":2,"24":0,"25":1},"b":{"0":[0,2],"1":[2,2],"2":[1,1],"3":[1,0],"4":[0,4],"5":[1,3],"6":[2,1],"7":[1,0],"8":[1,1],"9":[1,1],"10":[1,1],"11":[0,3],"12":[3,0],"13":[1,6],"14":[1,6],"15":[1,4],"16":[2,2],"17":[1,1],"18":[2,0],"19":[1,1],"20":[1,3],"21":[1,2],"22":[4,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0a4bf26938869e9b89bab568412c349bc1ff0083","contentHash":"deda95ed23abba3b13e7ef198467fe3e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":90}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":92}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63a3e651f707e94ed97ec659690592a0c340c6bd","contentHash":"85e8e83b7f1e99d944d489a44ed72bce_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":6,"column":13},"end":{"line":6,"column":33}},"2":{"start":{"line":8,"column":11},"end":{"line":8,"column":22}},"3":{"start":{"line":17,"column":2},"end":{"line":17,"column":53}},"4":{"start":{"line":19,"column":15},"end":{"line":19,"column":37}},"5":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"6":{"start":{"line":21,"column":4},"end":{"line":21,"column":45}},"7":{"start":{"line":23,"column":4},"end":{"line":40,"column":7}},"8":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"9":{"start":{"line":27,"column":8},"end":{"line":36,"column":11}},"10":{"start":{"line":30,"column":10},"end":{"line":33,"column":13}},"11":{"start":{"line":35,"column":10},"end":{"line":35,"column":33}},"12":{"start":{"line":39,"column":6},"end":{"line":39,"column":29}},"13":{"start":{"line":51,"column":2},"end":{"line":55,"column":5}},"14":{"start":{"line":52,"column":4},"end":{"line":52,"column":38}},"15":{"start":{"line":54,"column":4},"end":{"line":54,"column":27}},"16":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"17":{"start":{"line":66,"column":4},"end":{"line":68,"column":7}},"18":{"start":{"line":70,"column":4},"end":{"line":79,"column":7}},"19":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"20":{"start":{"line":72,"column":8},"end":{"line":74,"column":11}},"21":{"start":{"line":76,"column":6},"end":{"line":76,"column":33}},"22":{"start":{"line":78,"column":6},"end":{"line":78,"column":41}},"23":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"24":{"start":{"line":91,"column":4},"end":{"line":91,"column":90}},"25":{"start":{"line":93,"column":2},"end":{"line":111,"column":5}},"26":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"27":{"start":{"line":95,"column":6},"end":{"line":97,"column":9}},"28":{"start":{"line":99,"column":4},"end":{"line":108,"column":7}},"29":{"start":{"line":102,"column":6},"end":{"line":105,"column":9}},"30":{"start":{"line":107,"column":6},"end":{"line":107,"column":41}},"31":{"start":{"line":110,"column":4},"end":{"line":110,"column":39}},"32":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"33":{"start":{"line":122,"column":4},"end":{"line":122,"column":90}},"34":{"start":{"line":124,"column":2},"end":{"line":139,"column":5}},"35":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"36":{"start":{"line":126,"column":6},"end":{"line":128,"column":9}},"37":{"start":{"line":130,"column":4},"end":{"line":136,"column":7}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":9}},"39":{"start":{"line":135,"column":6},"end":{"line":135,"column":41}},"40":{"start":{"line":138,"column":4},"end":{"line":138,"column":27}},"41":{"start":{"line":142,"column":0},"end":{"line":142,"column":133}}},"fnMap":{"0":{"name":"createRole","decl":{"start":{"line":16,"column":9},"end":{"line":16,"column":19}},"loc":{"start":{"line":16,"column":30},"end":{"line":42,"column":1}},"line":16},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":12},"end":{"line":25,"column":13}},"loc":{"start":{"line":25,"column":41},"end":{"line":38,"column":5}},"line":25},"2":{"name":"(anonymous_2)","decl":{"start":{"line":29,"column":16},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":32},"end":{"line":34,"column":9}},"line":29},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":17},"end":{"line":34,"column":18}},"loc":{"start":{"line":34,"column":34},"end":{"line":36,"column":9}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":38,"column":13},"end":{"line":38,"column":14}},"loc":{"start":{"line":38,"column":30},"end":{"line":40,"column":5}},"line":38},"5":{"name":"getRoles","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":17}},"loc":{"start":{"line":50,"column":28},"end":{"line":56,"column":1}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":29},"end":{"line":51,"column":30}},"loc":{"start":{"line":51,"column":45},"end":{"line":53,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":53,"column":11},"end":{"line":53,"column":12}},"loc":{"start":{"line":53,"column":28},"end":{"line":55,"column":3}},"line":53},"8":{"name":"findRole","decl":{"start":{"line":64,"column":9},"end":{"line":64,"column":17}},"loc":{"start":{"line":64,"column":28},"end":{"line":81,"column":1}},"line":64},"9":{"name":"(anonymous_9)","decl":{"start":{"line":70,"column":38},"end":{"line":70,"column":39}},"loc":{"start":{"line":70,"column":54},"end":{"line":77,"column":5}},"line":70},"10":{"name":"(anonymous_10)","decl":{"start":{"line":77,"column":13},"end":{"line":77,"column":14}},"loc":{"start":{"line":77,"column":30},"end":{"line":79,"column":5}},"line":77},"11":{"name":"updateRole","decl":{"start":{"line":89,"column":9},"end":{"line":89,"column":19}},"loc":{"start":{"line":89,"column":30},"end":{"line":112,"column":1}},"line":89},"12":{"name":"(anonymous_12)","decl":{"start":{"line":93,"column":43},"end":{"line":93,"column":44}},"loc":{"start":{"line":93,"column":59},"end":{"line":109,"column":3}},"line":93},"13":{"name":"(anonymous_13)","decl":{"start":{"line":101,"column":12},"end":{"line":101,"column":13}},"loc":{"start":{"line":101,"column":24},"end":{"line":106,"column":5}},"line":101},"14":{"name":"(anonymous_14)","decl":{"start":{"line":106,"column":13},"end":{"line":106,"column":14}},"loc":{"start":{"line":106,"column":30},"end":{"line":108,"column":5}},"line":106},"15":{"name":"(anonymous_15)","decl":{"start":{"line":109,"column":11},"end":{"line":109,"column":12}},"loc":{"start":{"line":109,"column":28},"end":{"line":111,"column":3}},"line":109},"16":{"name":"deleteRole","decl":{"start":{"line":120,"column":9},"end":{"line":120,"column":19}},"loc":{"start":{"line":120,"column":30},"end":{"line":140,"column":1}},"line":120},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":43},"end":{"line":124,"column":44}},"loc":{"start":{"line":124,"column":59},"end":{"line":137,"column":3}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":130,"column":31},"end":{"line":130,"column":32}},"loc":{"start":{"line":130,"column":43},"end":{"line":134,"column":5}},"line":130},"19":{"name":"(anonymous_19)","decl":{"start":{"line":134,"column":13},"end":{"line":134,"column":14}},"loc":{"start":{"line":134,"column":30},"end":{"line":136,"column":5}},"line":134},"20":{"name":"(anonymous_20)","decl":{"start":{"line":137,"column":11},"end":{"line":137,"column":12}},"loc":{"start":{"line":137,"column":28},"end":{"line":139,"column":3}},"line":137}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},{"start":{"line":20,"column":2},"end":{"line":41,"column":3}}],"line":20},"1":{"loc":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"type":"if","locations":[{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},{"start":{"line":26,"column":6},"end":{"line":37,"column":7}}],"line":26},"2":{"loc":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"type":"if","locations":[{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},{"start":{"line":65,"column":2},"end":{"line":80,"column":3}}],"line":65},"3":{"loc":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"type":"if","locations":[{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},{"start":{"line":71,"column":6},"end":{"line":75,"column":7}}],"line":71},"4":{"loc":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"type":"if","locations":[{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},{"start":{"line":90,"column":2},"end":{"line":92,"column":3}}],"line":90},"5":{"loc":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},{"start":{"line":94,"column":4},"end":{"line":98,"column":5}}],"line":94},"6":{"loc":{"start":{"line":100,"column":13},"end":{"line":100,"column":41}},"type":"binary-expr","locations":[{"start":{"line":100,"column":13},"end":{"line":100,"column":27}},{"start":{"line":100,"column":31},"end":{"line":100,"column":41}}],"line":100},"7":{"loc":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"type":"if","locations":[{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},{"start":{"line":121,"column":2},"end":{"line":123,"column":3}}],"line":121},"8":{"loc":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"type":"if","locations":[{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},{"start":{"line":125,"column":4},"end":{"line":129,"column":5}}],"line":125}},"s":{"0":1,"1":1,"2":1,"3":3,"4":3,"5":3,"6":0,"7":3,"8":2,"9":2,"10":2,"11":0,"12":1,"13":1,"14":1,"15":0,"16":4,"17":1,"18":3,"19":2,"20":1,"21":1,"22":1,"23":3,"24":0,"25":3,"26":2,"27":1,"28":1,"29":1,"30":0,"31":1,"32":2,"33":0,"34":2,"35":2,"36":1,"37":2,"38":0,"39":1,"40":1,"41":1},"f":{"0":3,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":4,"9":2,"10":1,"11":3,"12":2,"13":1,"14":0,"15":1,"16":2,"17":2,"18":0,"19":1,"20":1},"b":{"0":[0,3],"1":[2,0],"2":[1,3],"3":[1,1],"4":[0,3],"5":[1,1],"6":[1,0],"7":[0,2],"8":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"30145fbb54f2bf78417895e538ec3aa77aa3022b","contentHash":"d0043f60ddb6921c54c62da8d1dd2774_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/mockData.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/mockData.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":26}},"5":{"start":{"line":15,"column":0},"end":{"line":54,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1},"b":{"0":[0,1],"1":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"c665441a3872939aae11e0aaaa2edd23055ddeb5","contentHash":"16d073a0b97072f3cf41cab373a16067_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/role.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/role.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":245,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":101,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":72,"column":7}},"38":{"start":{"line":64,"column":6},"end":{"line":70,"column":9}},"39":{"start":{"line":65,"column":8},"end":{"line":65,"column":41}},"40":{"start":{"line":66,"column":8},"end":{"line":66,"column":43}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":69}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":50}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":76}},"44":{"start":{"line":71,"column":6},"end":{"line":71,"column":13}},"45":{"start":{"line":73,"column":4},"end":{"line":81,"column":7}},"46":{"start":{"line":74,"column":6},"end":{"line":79,"column":9}},"47":{"start":{"line":75,"column":8},"end":{"line":75,"column":41}},"48":{"start":{"line":76,"column":8},"end":{"line":76,"column":43}},"49":{"start":{"line":77,"column":8},"end":{"line":77,"column":69}},"50":{"start":{"line":78,"column":8},"end":{"line":78,"column":50}},"51":{"start":{"line":80,"column":6},"end":{"line":80,"column":13}},"52":{"start":{"line":82,"column":4},"end":{"line":92,"column":7}},"53":{"start":{"line":83,"column":17},"end":{"line":85,"column":7}},"54":{"start":{"line":86,"column":6},"end":{"line":91,"column":9}},"55":{"start":{"line":87,"column":8},"end":{"line":87,"column":41}},"56":{"start":{"line":88,"column":8},"end":{"line":88,"column":43}},"57":{"start":{"line":89,"column":8},"end":{"line":89,"column":66}},"58":{"start":{"line":90,"column":8},"end":{"line":90,"column":15}},"59":{"start":{"line":93,"column":4},"end":{"line":100,"column":7}},"60":{"start":{"line":94,"column":6},"end":{"line":99,"column":9}},"61":{"start":{"line":95,"column":8},"end":{"line":95,"column":41}},"62":{"start":{"line":96,"column":8},"end":{"line":96,"column":43}},"63":{"start":{"line":97,"column":8},"end":{"line":97,"column":69}},"64":{"start":{"line":98,"column":8},"end":{"line":98,"column":15}},"65":{"start":{"line":103,"column":2},"end":{"line":123,"column":5}},"66":{"start":{"line":104,"column":4},"end":{"line":115,"column":7}},"67":{"start":{"line":105,"column":6},"end":{"line":114,"column":9}},"68":{"start":{"line":106,"column":8},"end":{"line":106,"column":41}},"69":{"start":{"line":107,"column":8},"end":{"line":107,"column":43}},"70":{"start":{"line":108,"column":8},"end":{"line":108,"column":42}},"71":{"start":{"line":109,"column":8},"end":{"line":109,"column":41}},"72":{"start":{"line":110,"column":8},"end":{"line":110,"column":50}},"73":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"74":{"start":{"line":112,"column":8},"end":{"line":112,"column":56}},"75":{"start":{"line":113,"column":8},"end":{"line":113,"column":15}},"76":{"start":{"line":116,"column":4},"end":{"line":122,"column":7}},"77":{"start":{"line":117,"column":6},"end":{"line":121,"column":9}},"78":{"start":{"line":118,"column":8},"end":{"line":118,"column":41}},"79":{"start":{"line":119,"column":8},"end":{"line":119,"column":66}},"80":{"start":{"line":120,"column":8},"end":{"line":120,"column":15}},"81":{"start":{"line":125,"column":2},"end":{"line":168,"column":5}},"82":{"start":{"line":126,"column":4},"end":{"line":135,"column":7}},"83":{"start":{"line":127,"column":15},"end":{"line":127,"column":16}},"84":{"start":{"line":128,"column":6},"end":{"line":134,"column":9}},"85":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"86":{"start":{"line":130,"column":8},"end":{"line":130,"column":40}},"87":{"start":{"line":131,"column":8},"end":{"line":131,"column":53}},"88":{"start":{"line":132,"column":8},"end":{"line":132,"column":40}},"89":{"start":{"line":133,"column":8},"end":{"line":133,"column":15}},"90":{"start":{"line":136,"column":4},"end":{"line":143,"column":7}},"91":{"start":{"line":137,"column":15},"end":{"line":137,"column":16}},"92":{"start":{"line":138,"column":6},"end":{"line":142,"column":9}},"93":{"start":{"line":139,"column":8},"end":{"line":139,"column":41}},"94":{"start":{"line":140,"column":8},"end":{"line":140,"column":66}},"95":{"start":{"line":141,"column":8},"end":{"line":141,"column":15}},"96":{"start":{"line":144,"column":4},"end":{"line":151,"column":7}},"97":{"start":{"line":145,"column":15},"end":{"line":145,"column":27}},"98":{"start":{"line":146,"column":6},"end":{"line":150,"column":9}},"99":{"start":{"line":147,"column":8},"end":{"line":147,"column":41}},"100":{"start":{"line":148,"column":8},"end":{"line":148,"column":90}},"101":{"start":{"line":149,"column":8},"end":{"line":149,"column":15}},"102":{"start":{"line":152,"column":4},"end":{"line":159,"column":7}},"103":{"start":{"line":153,"column":15},"end":{"line":153,"column":18}},"104":{"start":{"line":154,"column":6},"end":{"line":158,"column":9}},"105":{"start":{"line":155,"column":8},"end":{"line":155,"column":41}},"106":{"start":{"line":156,"column":8},"end":{"line":156,"column":58}},"107":{"start":{"line":157,"column":8},"end":{"line":157,"column":15}},"108":{"start":{"line":160,"column":4},"end":{"line":167,"column":7}},"109":{"start":{"line":161,"column":15},"end":{"line":161,"column":36}},"110":{"start":{"line":162,"column":6},"end":{"line":166,"column":9}},"111":{"start":{"line":163,"column":8},"end":{"line":163,"column":41}},"112":{"start":{"line":164,"column":8},"end":{"line":164,"column":95}},"113":{"start":{"line":165,"column":8},"end":{"line":165,"column":15}},"114":{"start":{"line":169,"column":2},"end":{"line":207,"column":5}},"115":{"start":{"line":170,"column":4},"end":{"line":179,"column":7}},"116":{"start":{"line":171,"column":15},"end":{"line":171,"column":16}},"117":{"start":{"line":172,"column":6},"end":{"line":178,"column":9}},"118":{"start":{"line":173,"column":8},"end":{"line":173,"column":41}},"119":{"start":{"line":174,"column":8},"end":{"line":174,"column":43}},"120":{"start":{"line":175,"column":8},"end":{"line":175,"column":69}},"121":{"start":{"line":176,"column":8},"end":{"line":176,"column":50}},"122":{"start":{"line":177,"column":8},"end":{"line":177,"column":15}},"123":{"start":{"line":180,"column":4},"end":{"line":188,"column":7}},"124":{"start":{"line":181,"column":15},"end":{"line":181,"column":16}},"125":{"start":{"line":182,"column":6},"end":{"line":187,"column":9}},"126":{"start":{"line":183,"column":8},"end":{"line":183,"column":41}},"127":{"start":{"line":184,"column":8},"end":{"line":184,"column":43}},"128":{"start":{"line":185,"column":8},"end":{"line":185,"column":66}},"129":{"start":{"line":186,"column":8},"end":{"line":186,"column":15}},"130":{"start":{"line":189,"column":4},"end":{"line":197,"column":7}},"131":{"start":{"line":190,"column":15},"end":{"line":190,"column":18}},"132":{"start":{"line":191,"column":6},"end":{"line":196,"column":9}},"133":{"start":{"line":192,"column":8},"end":{"line":192,"column":41}},"134":{"start":{"line":193,"column":8},"end":{"line":193,"column":43}},"135":{"start":{"line":194,"column":8},"end":{"line":194,"column":60}},"136":{"start":{"line":195,"column":8},"end":{"line":195,"column":15}},"137":{"start":{"line":198,"column":4},"end":{"line":206,"column":7}},"138":{"start":{"line":199,"column":15},"end":{"line":199,"column":31}},"139":{"start":{"line":200,"column":6},"end":{"line":205,"column":9}},"140":{"start":{"line":201,"column":8},"end":{"line":201,"column":41}},"141":{"start":{"line":202,"column":8},"end":{"line":202,"column":43}},"142":{"start":{"line":203,"column":8},"end":{"line":203,"column":95}},"143":{"start":{"line":204,"column":8},"end":{"line":204,"column":15}},"144":{"start":{"line":208,"column":2},"end":{"line":244,"column":5}},"145":{"start":{"line":209,"column":4},"end":{"line":216,"column":7}},"146":{"start":{"line":210,"column":15},"end":{"line":210,"column":16}},"147":{"start":{"line":211,"column":6},"end":{"line":214,"column":9}},"148":{"start":{"line":212,"column":8},"end":{"line":212,"column":41}},"149":{"start":{"line":213,"column":8},"end":{"line":213,"column":43}},"150":{"start":{"line":215,"column":6},"end":{"line":215,"column":13}},"151":{"start":{"line":217,"column":4},"end":{"line":225,"column":7}},"152":{"start":{"line":218,"column":15},"end":{"line":218,"column":16}},"153":{"start":{"line":219,"column":6},"end":{"line":224,"column":9}},"154":{"start":{"line":220,"column":8},"end":{"line":220,"column":41}},"155":{"start":{"line":221,"column":8},"end":{"line":221,"column":43}},"156":{"start":{"line":222,"column":8},"end":{"line":222,"column":66}},"157":{"start":{"line":223,"column":8},"end":{"line":223,"column":15}},"158":{"start":{"line":226,"column":4},"end":{"line":234,"column":7}},"159":{"start":{"line":227,"column":15},"end":{"line":227,"column":18}},"160":{"start":{"line":228,"column":6},"end":{"line":233,"column":9}},"161":{"start":{"line":229,"column":8},"end":{"line":229,"column":41}},"162":{"start":{"line":230,"column":8},"end":{"line":230,"column":43}},"163":{"start":{"line":231,"column":8},"end":{"line":231,"column":60}},"164":{"start":{"line":232,"column":8},"end":{"line":232,"column":15}},"165":{"start":{"line":235,"column":4},"end":{"line":243,"column":7}},"166":{"start":{"line":236,"column":15},"end":{"line":236,"column":31}},"167":{"start":{"line":237,"column":6},"end":{"line":242,"column":9}},"168":{"start":{"line":238,"column":8},"end":{"line":238,"column":41}},"169":{"start":{"line":239,"column":8},"end":{"line":239,"column":43}},"170":{"start":{"line":240,"column":8},"end":{"line":240,"column":95}},"171":{"start":{"line":241,"column":8},"end":{"line":241,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":18},"end":{"line":38,"column":19}},"loc":{"start":{"line":38,"column":30},"end":{"line":245,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":25},"end":{"line":62,"column":26}},"loc":{"start":{"line":62,"column":37},"end":{"line":101,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":56},"end":{"line":63,"column":57}},"loc":{"start":{"line":63,"column":72},"end":{"line":72,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":64,"column":136},"end":{"line":64,"column":137}},"loc":{"start":{"line":64,"column":156},"end":{"line":70,"column":7}},"line":64},"12":{"name":"(anonymous_12)","decl":{"start":{"line":73,"column":56},"end":{"line":73,"column":57}},"loc":{"start":{"line":73,"column":72},"end":{"line":81,"column":5}},"line":73},"13":{"name":"(anonymous_13)","decl":{"start":{"line":74,"column":133},"end":{"line":74,"column":134}},"loc":{"start":{"line":74,"column":153},"end":{"line":79,"column":7}},"line":74},"14":{"name":"(anonymous_14)","decl":{"start":{"line":82,"column":61},"end":{"line":82,"column":62}},"loc":{"start":{"line":82,"column":77},"end":{"line":92,"column":5}},"line":82},"15":{"name":"(anonymous_15)","decl":{"start":{"line":86,"column":120},"end":{"line":86,"column":121}},"loc":{"start":{"line":86,"column":140},"end":{"line":91,"column":7}},"line":86},"16":{"name":"(anonymous_16)","decl":{"start":{"line":93,"column":62},"end":{"line":93,"column":63}},"loc":{"start":{"line":93,"column":78},"end":{"line":100,"column":5}},"line":93},"17":{"name":"(anonymous_17)","decl":{"start":{"line":94,"column":131},"end":{"line":94,"column":132}},"loc":{"start":{"line":94,"column":151},"end":{"line":99,"column":7}},"line":94},"18":{"name":"(anonymous_18)","decl":{"start":{"line":103,"column":24},"end":{"line":103,"column":25}},"loc":{"start":{"line":103,"column":36},"end":{"line":123,"column":3}},"line":103},"19":{"name":"(anonymous_19)","decl":{"start":{"line":104,"column":59},"end":{"line":104,"column":60}},"loc":{"start":{"line":104,"column":75},"end":{"line":115,"column":5}},"line":104},"20":{"name":"(anonymous_20)","decl":{"start":{"line":105,"column":106},"end":{"line":105,"column":107}},"loc":{"start":{"line":105,"column":126},"end":{"line":114,"column":7}},"line":105},"21":{"name":"(anonymous_21)","decl":{"start":{"line":116,"column":64},"end":{"line":116,"column":65}},"loc":{"start":{"line":116,"column":80},"end":{"line":122,"column":5}},"line":116},"22":{"name":"(anonymous_22)","decl":{"start":{"line":117,"column":105},"end":{"line":117,"column":106}},"loc":{"start":{"line":117,"column":125},"end":{"line":121,"column":7}},"line":117},"23":{"name":"(anonymous_23)","decl":{"start":{"line":125,"column":28},"end":{"line":125,"column":29}},"loc":{"start":{"line":125,"column":40},"end":{"line":168,"column":3}},"line":125},"24":{"name":"(anonymous_24)","decl":{"start":{"line":126,"column":58},"end":{"line":126,"column":59}},"loc":{"start":{"line":126,"column":74},"end":{"line":135,"column":5}},"line":126},"25":{"name":"(anonymous_25)","decl":{"start":{"line":128,"column":112},"end":{"line":128,"column":113}},"loc":{"start":{"line":128,"column":132},"end":{"line":134,"column":7}},"line":128},"26":{"name":"(anonymous_26)","decl":{"start":{"line":136,"column":70},"end":{"line":136,"column":71}},"loc":{"start":{"line":136,"column":86},"end":{"line":143,"column":5}},"line":136},"27":{"name":"(anonymous_27)","decl":{"start":{"line":138,"column":111},"end":{"line":138,"column":112}},"loc":{"start":{"line":138,"column":131},"end":{"line":142,"column":7}},"line":138},"28":{"name":"(anonymous_28)","decl":{"start":{"line":144,"column":78},"end":{"line":144,"column":79}},"loc":{"start":{"line":144,"column":94},"end":{"line":151,"column":5}},"line":144},"29":{"name":"(anonymous_29)","decl":{"start":{"line":146,"column":112},"end":{"line":146,"column":113}},"loc":{"start":{"line":146,"column":132},"end":{"line":150,"column":7}},"line":146},"30":{"name":"(anonymous_30)","decl":{"start":{"line":152,"column":69},"end":{"line":152,"column":70}},"loc":{"start":{"line":152,"column":85},"end":{"line":159,"column":5}},"line":152},"31":{"name":"(anonymous_31)","decl":{"start":{"line":154,"column":112},"end":{"line":154,"column":113}},"loc":{"start":{"line":154,"column":132},"end":{"line":158,"column":7}},"line":154},"32":{"name":"(anonymous_32)","decl":{"start":{"line":160,"column":68},"end":{"line":160,"column":69}},"loc":{"start":{"line":160,"column":84},"end":{"line":167,"column":5}},"line":160},"33":{"name":"(anonymous_33)","decl":{"start":{"line":162,"column":112},"end":{"line":162,"column":113}},"loc":{"start":{"line":162,"column":132},"end":{"line":166,"column":7}},"line":162},"34":{"name":"(anonymous_34)","decl":{"start":{"line":169,"column":28},"end":{"line":169,"column":29}},"loc":{"start":{"line":169,"column":40},"end":{"line":207,"column":3}},"line":169},"35":{"name":"(anonymous_35)","decl":{"start":{"line":170,"column":66},"end":{"line":170,"column":67}},"loc":{"start":{"line":170,"column":82},"end":{"line":179,"column":5}},"line":170},"36":{"name":"(anonymous_36)","decl":{"start":{"line":172,"column":144},"end":{"line":172,"column":145}},"loc":{"start":{"line":172,"column":164},"end":{"line":178,"column":7}},"line":172},"37":{"name":"(anonymous_37)","decl":{"start":{"line":180,"column":77},"end":{"line":180,"column":78}},"loc":{"start":{"line":180,"column":93},"end":{"line":188,"column":5}},"line":180},"38":{"name":"(anonymous_38)","decl":{"start":{"line":182,"column":135},"end":{"line":182,"column":136}},"loc":{"start":{"line":182,"column":155},"end":{"line":187,"column":7}},"line":182},"39":{"name":"(anonymous_39)","decl":{"start":{"line":189,"column":90},"end":{"line":189,"column":91}},"loc":{"start":{"line":189,"column":106},"end":{"line":197,"column":5}},"line":189},"40":{"name":"(anonymous_40)","decl":{"start":{"line":191,"column":136},"end":{"line":191,"column":137}},"loc":{"start":{"line":191,"column":156},"end":{"line":196,"column":7}},"line":191},"41":{"name":"(anonymous_41)","decl":{"start":{"line":198,"column":96},"end":{"line":198,"column":97}},"loc":{"start":{"line":198,"column":112},"end":{"line":206,"column":5}},"line":198},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":139},"end":{"line":200,"column":140}},"loc":{"start":{"line":200,"column":159},"end":{"line":205,"column":7}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":31},"end":{"line":208,"column":32}},"loc":{"start":{"line":208,"column":43},"end":{"line":244,"column":3}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":209,"column":63},"end":{"line":209,"column":64}},"loc":{"start":{"line":209,"column":79},"end":{"line":216,"column":5}},"line":209},"45":{"name":"(anonymous_45)","decl":{"start":{"line":211,"column":115},"end":{"line":211,"column":116}},"loc":{"start":{"line":211,"column":135},"end":{"line":214,"column":7}},"line":211},"46":{"name":"(anonymous_46)","decl":{"start":{"line":217,"column":74},"end":{"line":217,"column":75}},"loc":{"start":{"line":217,"column":90},"end":{"line":225,"column":5}},"line":217},"47":{"name":"(anonymous_47)","decl":{"start":{"line":219,"column":114},"end":{"line":219,"column":115}},"loc":{"start":{"line":219,"column":134},"end":{"line":224,"column":7}},"line":219},"48":{"name":"(anonymous_48)","decl":{"start":{"line":226,"column":79},"end":{"line":226,"column":80}},"loc":{"start":{"line":226,"column":95},"end":{"line":234,"column":5}},"line":226},"49":{"name":"(anonymous_49)","decl":{"start":{"line":228,"column":115},"end":{"line":228,"column":116}},"loc":{"start":{"line":228,"column":135},"end":{"line":233,"column":7}},"line":228},"50":{"name":"(anonymous_50)","decl":{"start":{"line":235,"column":99},"end":{"line":235,"column":100}},"loc":{"start":{"line":235,"column":115},"end":{"line":243,"column":5}},"line":235},"51":{"name":"(anonymous_51)","decl":{"start":{"line":237,"column":115},"end":{"line":237,"column":116}},"loc":{"start":{"line":237,"column":135},"end":{"line":242,"column":7}},"line":237}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":0,"49":0,"50":0,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":0,"63":0,"64":0,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":0,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":1,"139":1,"140":1,"141":1,"142":1,"143":0,"144":1,"145":1,"146":1,"147":1,"148":1,"149":0,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":0,"167":0,"168":0,"169":0,"170":0,"171":0},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":0,"51":0},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d9c57213fc2a56b5354ab1d6480399426f8d3d21","contentHash":"e9ffe18e982a467134829351068b6216_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/search.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/search.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":21},"end":{"line":33,"column":27}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":13},"end":{"line":35,"column":38}},"20":{"start":{"line":38,"column":0},"end":{"line":106,"column":3}},"21":{"start":{"line":39,"column":2},"end":{"line":44,"column":5}},"22":{"start":{"line":40,"column":4},"end":{"line":43,"column":7}},"23":{"start":{"line":41,"column":6},"end":{"line":41,"column":34}},"24":{"start":{"line":42,"column":6},"end":{"line":42,"column":13}},"25":{"start":{"line":45,"column":2},"end":{"line":50,"column":5}},"26":{"start":{"line":46,"column":4},"end":{"line":49,"column":7}},"27":{"start":{"line":47,"column":6},"end":{"line":47,"column":33}},"28":{"start":{"line":48,"column":6},"end":{"line":48,"column":13}},"29":{"start":{"line":51,"column":2},"end":{"line":56,"column":5}},"30":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"31":{"start":{"line":53,"column":6},"end":{"line":53,"column":39}},"32":{"start":{"line":54,"column":6},"end":{"line":54,"column":13}},"33":{"start":{"line":57,"column":2},"end":{"line":60,"column":5}},"34":{"start":{"line":58,"column":4},"end":{"line":58,"column":76}},"35":{"start":{"line":59,"column":4},"end":{"line":59,"column":11}},"36":{"start":{"line":62,"column":2},"end":{"line":78,"column":5}},"37":{"start":{"line":63,"column":4},"end":{"line":69,"column":7}},"38":{"start":{"line":64,"column":18},"end":{"line":64,"column":20}},"39":{"start":{"line":65,"column":6},"end":{"line":68,"column":9}},"40":{"start":{"line":66,"column":8},"end":{"line":66,"column":41}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":62}},"42":{"start":{"line":70,"column":4},"end":{"line":77,"column":7}},"43":{"start":{"line":71,"column":18},"end":{"line":71,"column":24}},"44":{"start":{"line":72,"column":6},"end":{"line":76,"column":9}},"45":{"start":{"line":73,"column":8},"end":{"line":73,"column":41}},"46":{"start":{"line":74,"column":8},"end":{"line":74,"column":53}},"47":{"start":{"line":75,"column":8},"end":{"line":75,"column":52}},"48":{"start":{"line":79,"column":2},"end":{"line":105,"column":5}},"49":{"start":{"line":80,"column":4},"end":{"line":86,"column":7}},"50":{"start":{"line":81,"column":18},"end":{"line":81,"column":20}},"51":{"start":{"line":82,"column":6},"end":{"line":85,"column":9}},"52":{"start":{"line":83,"column":8},"end":{"line":83,"column":41}},"53":{"start":{"line":84,"column":8},"end":{"line":84,"column":86}},"54":{"start":{"line":87,"column":4},"end":{"line":97,"column":7}},"55":{"start":{"line":88,"column":18},"end":{"line":88,"column":24}},"56":{"start":{"line":89,"column":6},"end":{"line":96,"column":9}},"57":{"start":{"line":90,"column":8},"end":{"line":90,"column":41}},"58":{"start":{"line":91,"column":8},"end":{"line":91,"column":54}},"59":{"start":{"line":92,"column":8},"end":{"line":92,"column":84}},"60":{"start":{"line":93,"column":8},"end":{"line":93,"column":96}},"61":{"start":{"line":94,"column":8},"end":{"line":94,"column":56}},"62":{"start":{"line":95,"column":8},"end":{"line":95,"column":78}},"63":{"start":{"line":98,"column":4},"end":{"line":104,"column":7}},"64":{"start":{"line":99,"column":18},"end":{"line":99,"column":22}},"65":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"66":{"start":{"line":101,"column":8},"end":{"line":101,"column":41}},"67":{"start":{"line":102,"column":8},"end":{"line":102,"column":84}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":38,"column":18},"end":{"line":38,"column":19}},"loc":{"start":{"line":38,"column":30},"end":{"line":106,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":39,"column":9},"end":{"line":39,"column":10}},"loc":{"start":{"line":39,"column":25},"end":{"line":44,"column":3}},"line":39},"3":{"name":"(anonymous_3)","decl":{"start":{"line":40,"column":90},"end":{"line":40,"column":91}},"loc":{"start":{"line":40,"column":110},"end":{"line":43,"column":5}},"line":40},"4":{"name":"(anonymous_4)","decl":{"start":{"line":45,"column":9},"end":{"line":45,"column":10}},"loc":{"start":{"line":45,"column":25},"end":{"line":50,"column":3}},"line":45},"5":{"name":"(anonymous_5)","decl":{"start":{"line":46,"column":91},"end":{"line":46,"column":92}},"loc":{"start":{"line":46,"column":111},"end":{"line":49,"column":5}},"line":46},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":9},"end":{"line":51,"column":10}},"loc":{"start":{"line":51,"column":25},"end":{"line":56,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":52,"column":136},"end":{"line":52,"column":137}},"loc":{"start":{"line":52,"column":156},"end":{"line":55,"column":5}},"line":52},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":8},"end":{"line":57,"column":9}},"loc":{"start":{"line":57,"column":24},"end":{"line":60,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":62,"column":38},"end":{"line":62,"column":39}},"loc":{"start":{"line":62,"column":50},"end":{"line":78,"column":3}},"line":62},"10":{"name":"(anonymous_10)","decl":{"start":{"line":63,"column":63},"end":{"line":63,"column":64}},"loc":{"start":{"line":63,"column":75},"end":{"line":69,"column":5}},"line":63},"11":{"name":"(anonymous_11)","decl":{"start":{"line":65,"column":126},"end":{"line":65,"column":127}},"loc":{"start":{"line":65,"column":146},"end":{"line":68,"column":7}},"line":65},"12":{"name":"(anonymous_12)","decl":{"start":{"line":70,"column":76},"end":{"line":70,"column":77}},"loc":{"start":{"line":70,"column":88},"end":{"line":77,"column":5}},"line":70},"13":{"name":"(anonymous_13)","decl":{"start":{"line":72,"column":126},"end":{"line":72,"column":127}},"loc":{"start":{"line":72,"column":146},"end":{"line":76,"column":7}},"line":72},"14":{"name":"(anonymous_14)","decl":{"start":{"line":79,"column":36},"end":{"line":79,"column":37}},"loc":{"start":{"line":79,"column":48},"end":{"line":105,"column":3}},"line":79},"15":{"name":"(anonymous_15)","decl":{"start":{"line":80,"column":63},"end":{"line":80,"column":64}},"loc":{"start":{"line":80,"column":75},"end":{"line":86,"column":5}},"line":80},"16":{"name":"(anonymous_16)","decl":{"start":{"line":82,"column":129},"end":{"line":82,"column":130}},"loc":{"start":{"line":82,"column":149},"end":{"line":85,"column":7}},"line":82},"17":{"name":"(anonymous_17)","decl":{"start":{"line":87,"column":67},"end":{"line":87,"column":68}},"loc":{"start":{"line":87,"column":79},"end":{"line":97,"column":5}},"line":87},"18":{"name":"(anonymous_18)","decl":{"start":{"line":89,"column":130},"end":{"line":89,"column":131}},"loc":{"start":{"line":89,"column":150},"end":{"line":96,"column":7}},"line":89},"19":{"name":"(anonymous_19)","decl":{"start":{"line":98,"column":70},"end":{"line":98,"column":71}},"loc":{"start":{"line":98,"column":82},"end":{"line":104,"column":5}},"line":98},"20":{"name":"(anonymous_20)","decl":{"start":{"line":100,"column":130},"end":{"line":100,"column":131}},"loc":{"start":{"line":100,"column":150},"end":{"line":103,"column":7}},"line":100}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":0,"33":1,"34":1,"35":1,"36":1,"37":1,"38":0,"39":0,"40":0,"41":0,"42":1,"43":0,"44":0,"45":0,"46":0,"47":0,"48":1,"49":1,"50":0,"51":0,"52":0,"53":0,"54":1,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":1,"64":0,"65":0,"66":0,"67":0},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":0,"11":0,"12":0,"13":0,"14":1,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a316d6b4cf5da750d781196c11f29a87e0f7c33b","contentHash":"dd9562f69019012ae13dbefda8bb9d25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/user.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/user.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":35}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"9":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":37}},"11":{"start":{"line":25,"column":17},"end":{"line":25,"column":50}},"12":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"13":{"start":{"line":29,"column":13},"end":{"line":29,"column":34}},"14":{"start":{"line":30,"column":0},"end":{"line":30,"column":39}},"15":{"start":{"line":31,"column":16},"end":{"line":31,"column":22}},"16":{"start":{"line":32,"column":17},"end":{"line":32,"column":23}},"17":{"start":{"line":33,"column":22},"end":{"line":33,"column":28}},"18":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"19":{"start":{"line":35,"column":15},"end":{"line":35,"column":42}},"20":{"start":{"line":36,"column":13},"end":{"line":36,"column":38}},"21":{"start":{"line":37,"column":12},"end":{"line":37,"column":36}},"22":{"start":{"line":38,"column":12},"end":{"line":38,"column":36}},"23":{"start":{"line":41,"column":0},"end":{"line":314,"column":3}},"24":{"start":{"line":42,"column":2},"end":{"line":47,"column":5}},"25":{"start":{"line":43,"column":4},"end":{"line":46,"column":7}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":34}},"27":{"start":{"line":45,"column":6},"end":{"line":45,"column":13}},"28":{"start":{"line":48,"column":2},"end":{"line":53,"column":5}},"29":{"start":{"line":49,"column":4},"end":{"line":52,"column":7}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":33}},"31":{"start":{"line":51,"column":6},"end":{"line":51,"column":13}},"32":{"start":{"line":54,"column":2},"end":{"line":59,"column":5}},"33":{"start":{"line":55,"column":4},"end":{"line":58,"column":7}},"34":{"start":{"line":56,"column":6},"end":{"line":56,"column":39}},"35":{"start":{"line":57,"column":6},"end":{"line":57,"column":13}},"36":{"start":{"line":60,"column":2},"end":{"line":63,"column":5}},"37":{"start":{"line":61,"column":4},"end":{"line":61,"column":76}},"38":{"start":{"line":62,"column":4},"end":{"line":62,"column":11}},"39":{"start":{"line":65,"column":2},"end":{"line":313,"column":5}},"40":{"start":{"line":66,"column":4},"end":{"line":74,"column":7}},"41":{"start":{"line":67,"column":6},"end":{"line":73,"column":9}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":41}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":62}},"44":{"start":{"line":70,"column":8},"end":{"line":70,"column":82}},"45":{"start":{"line":71,"column":8},"end":{"line":71,"column":47}},"46":{"start":{"line":72,"column":8},"end":{"line":72,"column":15}},"47":{"start":{"line":76,"column":4},"end":{"line":84,"column":7}},"48":{"start":{"line":77,"column":6},"end":{"line":83,"column":9}},"49":{"start":{"line":78,"column":8},"end":{"line":78,"column":41}},"50":{"start":{"line":79,"column":8},"end":{"line":79,"column":62}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":82}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":47}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":15}},"54":{"start":{"line":86,"column":4},"end":{"line":93,"column":7}},"55":{"start":{"line":87,"column":6},"end":{"line":92,"column":9}},"56":{"start":{"line":88,"column":8},"end":{"line":88,"column":41}},"57":{"start":{"line":89,"column":8},"end":{"line":89,"column":60}},"58":{"start":{"line":90,"column":8},"end":{"line":90,"column":46}},"59":{"start":{"line":91,"column":8},"end":{"line":91,"column":15}},"60":{"start":{"line":95,"column":4},"end":{"line":105,"column":7}},"61":{"start":{"line":96,"column":6},"end":{"line":104,"column":9}},"62":{"start":{"line":97,"column":8},"end":{"line":103,"column":11}},"63":{"start":{"line":98,"column":10},"end":{"line":98,"column":43}},"64":{"start":{"line":99,"column":10},"end":{"line":99,"column":79}},"65":{"start":{"line":100,"column":10},"end":{"line":100,"column":48}},"66":{"start":{"line":101,"column":10},"end":{"line":101,"column":79}},"67":{"start":{"line":102,"column":10},"end":{"line":102,"column":17}},"68":{"start":{"line":107,"column":4},"end":{"line":142,"column":7}},"69":{"start":{"line":108,"column":6},"end":{"line":115,"column":9}},"70":{"start":{"line":109,"column":8},"end":{"line":114,"column":11}},"71":{"start":{"line":110,"column":10},"end":{"line":110,"column":43}},"72":{"start":{"line":111,"column":10},"end":{"line":111,"column":45}},"73":{"start":{"line":112,"column":10},"end":{"line":112,"column":64}},"74":{"start":{"line":113,"column":10},"end":{"line":113,"column":17}},"75":{"start":{"line":116,"column":6},"end":{"line":123,"column":9}},"76":{"start":{"line":117,"column":8},"end":{"line":122,"column":11}},"77":{"start":{"line":118,"column":10},"end":{"line":118,"column":43}},"78":{"start":{"line":119,"column":10},"end":{"line":119,"column":45}},"79":{"start":{"line":120,"column":10},"end":{"line":120,"column":68}},"80":{"start":{"line":121,"column":10},"end":{"line":121,"column":17}},"81":{"start":{"line":124,"column":6},"end":{"line":131,"column":9}},"82":{"start":{"line":125,"column":8},"end":{"line":130,"column":11}},"83":{"start":{"line":126,"column":10},"end":{"line":126,"column":43}},"84":{"start":{"line":127,"column":10},"end":{"line":127,"column":45}},"85":{"start":{"line":128,"column":10},"end":{"line":128,"column":64}},"86":{"start":{"line":129,"column":10},"end":{"line":129,"column":17}},"87":{"start":{"line":132,"column":6},"end":{"line":141,"column":9}},"88":{"start":{"line":133,"column":20},"end":{"line":133,"column":21}},"89":{"start":{"line":134,"column":8},"end":{"line":140,"column":11}},"90":{"start":{"line":135,"column":10},"end":{"line":135,"column":43}},"91":{"start":{"line":136,"column":10},"end":{"line":136,"column":45}},"92":{"start":{"line":137,"column":10},"end":{"line":137,"column":66}},"93":{"start":{"line":138,"column":10},"end":{"line":138,"column":61}},"94":{"start":{"line":139,"column":10},"end":{"line":139,"column":17}},"95":{"start":{"line":143,"column":4},"end":{"line":204,"column":7}},"96":{"start":{"line":144,"column":6},"end":{"line":156,"column":9}},"97":{"start":{"line":145,"column":17},"end":{"line":145,"column":18}},"98":{"start":{"line":146,"column":8},"end":{"line":155,"column":11}},"99":{"start":{"line":147,"column":10},"end":{"line":147,"column":43}},"100":{"start":{"line":148,"column":10},"end":{"line":148,"column":41}},"101":{"start":{"line":149,"column":10},"end":{"line":149,"column":60}},"102":{"start":{"line":150,"column":10},"end":{"line":150,"column":43}},"103":{"start":{"line":151,"column":10},"end":{"line":151,"column":54}},"104":{"start":{"line":152,"column":10},"end":{"line":152,"column":60}},"105":{"start":{"line":153,"column":10},"end":{"line":153,"column":47}},"106":{"start":{"line":154,"column":10},"end":{"line":154,"column":17}},"107":{"start":{"line":157,"column":6},"end":{"line":169,"column":9}},"108":{"start":{"line":158,"column":17},"end":{"line":158,"column":18}},"109":{"start":{"line":159,"column":8},"end":{"line":168,"column":11}},"110":{"start":{"line":160,"column":10},"end":{"line":160,"column":43}},"111":{"start":{"line":161,"column":10},"end":{"line":161,"column":41}},"112":{"start":{"line":162,"column":10},"end":{"line":162,"column":60}},"113":{"start":{"line":163,"column":10},"end":{"line":163,"column":40}},"114":{"start":{"line":164,"column":10},"end":{"line":164,"column":54}},"115":{"start":{"line":165,"column":10},"end":{"line":165,"column":60}},"116":{"start":{"line":166,"column":10},"end":{"line":166,"column":47}},"117":{"start":{"line":167,"column":10},"end":{"line":167,"column":17}},"118":{"start":{"line":170,"column":6},"end":{"line":177,"column":9}},"119":{"start":{"line":171,"column":17},"end":{"line":171,"column":29}},"120":{"start":{"line":172,"column":8},"end":{"line":176,"column":11}},"121":{"start":{"line":173,"column":10},"end":{"line":173,"column":43}},"122":{"start":{"line":174,"column":10},"end":{"line":174,"column":112}},"123":{"start":{"line":175,"column":10},"end":{"line":175,"column":17}},"124":{"start":{"line":178,"column":6},"end":{"line":186,"column":9}},"125":{"start":{"line":179,"column":17},"end":{"line":179,"column":18}},"126":{"start":{"line":180,"column":8},"end":{"line":184,"column":11}},"127":{"start":{"line":181,"column":10},"end":{"line":181,"column":43}},"128":{"start":{"line":182,"column":10},"end":{"line":182,"column":53}},"129":{"start":{"line":183,"column":10},"end":{"line":183,"column":65}},"130":{"start":{"line":185,"column":8},"end":{"line":185,"column":15}},"131":{"start":{"line":187,"column":6},"end":{"line":195,"column":9}},"132":{"start":{"line":188,"column":17},"end":{"line":188,"column":20}},"133":{"start":{"line":189,"column":8},"end":{"line":194,"column":11}},"134":{"start":{"line":190,"column":10},"end":{"line":190,"column":43}},"135":{"start":{"line":191,"column":10},"end":{"line":191,"column":55}},"136":{"start":{"line":192,"column":10},"end":{"line":192,"column":60}},"137":{"start":{"line":193,"column":10},"end":{"line":193,"column":17}},"138":{"start":{"line":196,"column":6},"end":{"line":203,"column":9}},"139":{"start":{"line":197,"column":17},"end":{"line":197,"column":35}},"140":{"start":{"line":198,"column":8},"end":{"line":202,"column":11}},"141":{"start":{"line":199,"column":10},"end":{"line":199,"column":43}},"142":{"start":{"line":200,"column":10},"end":{"line":200,"column":119}},"143":{"start":{"line":201,"column":10},"end":{"line":201,"column":17}},"144":{"start":{"line":205,"column":4},"end":{"line":254,"column":7}},"145":{"start":{"line":206,"column":6},"end":{"line":215,"column":9}},"146":{"start":{"line":207,"column":17},"end":{"line":207,"column":18}},"147":{"start":{"line":208,"column":8},"end":{"line":214,"column":11}},"148":{"start":{"line":209,"column":10},"end":{"line":209,"column":43}},"149":{"start":{"line":210,"column":10},"end":{"line":210,"column":45}},"150":{"start":{"line":211,"column":10},"end":{"line":211,"column":40}},"151":{"start":{"line":212,"column":10},"end":{"line":212,"column":55}},"152":{"start":{"line":213,"column":10},"end":{"line":213,"column":17}},"153":{"start":{"line":216,"column":6},"end":{"line":225,"column":9}},"154":{"start":{"line":217,"column":17},"end":{"line":217,"column":18}},"155":{"start":{"line":218,"column":8},"end":{"line":224,"column":11}},"156":{"start":{"line":219,"column":10},"end":{"line":219,"column":43}},"157":{"start":{"line":220,"column":10},"end":{"line":220,"column":45}},"158":{"start":{"line":221,"column":10},"end":{"line":221,"column":40}},"159":{"start":{"line":222,"column":10},"end":{"line":222,"column":62}},"160":{"start":{"line":223,"column":10},"end":{"line":223,"column":17}},"161":{"start":{"line":226,"column":6},"end":{"line":235,"column":9}},"162":{"start":{"line":227,"column":17},"end":{"line":227,"column":18}},"163":{"start":{"line":228,"column":8},"end":{"line":234,"column":11}},"164":{"start":{"line":229,"column":10},"end":{"line":229,"column":43}},"165":{"start":{"line":230,"column":10},"end":{"line":230,"column":45}},"166":{"start":{"line":231,"column":10},"end":{"line":231,"column":40}},"167":{"start":{"line":232,"column":10},"end":{"line":232,"column":56}},"168":{"start":{"line":233,"column":10},"end":{"line":233,"column":17}},"169":{"start":{"line":236,"column":6},"end":{"line":244,"column":9}},"170":{"start":{"line":237,"column":17},"end":{"line":237,"column":18}},"171":{"start":{"line":238,"column":8},"end":{"line":243,"column":11}},"172":{"start":{"line":239,"column":10},"end":{"line":239,"column":43}},"173":{"start":{"line":240,"column":10},"end":{"line":240,"column":45}},"174":{"start":{"line":241,"column":10},"end":{"line":241,"column":88}},"175":{"start":{"line":242,"column":10},"end":{"line":242,"column":17}},"176":{"start":{"line":245,"column":6},"end":{"line":253,"column":9}},"177":{"start":{"line":246,"column":17},"end":{"line":246,"column":21}},"178":{"start":{"line":247,"column":8},"end":{"line":252,"column":11}},"179":{"start":{"line":248,"column":10},"end":{"line":248,"column":43}},"180":{"start":{"line":249,"column":10},"end":{"line":249,"column":45}},"181":{"start":{"line":250,"column":10},"end":{"line":250,"column":88}},"182":{"start":{"line":251,"column":10},"end":{"line":251,"column":17}},"183":{"start":{"line":255,"column":4},"end":{"line":280,"column":7}},"184":{"start":{"line":256,"column":6},"end":{"line":262,"column":9}},"185":{"start":{"line":257,"column":17},"end":{"line":257,"column":18}},"186":{"start":{"line":258,"column":8},"end":{"line":261,"column":11}},"187":{"start":{"line":259,"column":10},"end":{"line":259,"column":43}},"188":{"start":{"line":260,"column":10},"end":{"line":260,"column":17}},"189":{"start":{"line":263,"column":6},"end":{"line":270,"column":9}},"190":{"start":{"line":264,"column":17},"end":{"line":264,"column":18}},"191":{"start":{"line":265,"column":8},"end":{"line":269,"column":11}},"192":{"start":{"line":266,"column":10},"end":{"line":266,"column":43}},"193":{"start":{"line":267,"column":10},"end":{"line":267,"column":89}},"194":{"start":{"line":268,"column":10},"end":{"line":268,"column":17}},"195":{"start":{"line":271,"column":6},"end":{"line":279,"column":9}},"196":{"start":{"line":272,"column":17},"end":{"line":272,"column":19}},"197":{"start":{"line":273,"column":8},"end":{"line":278,"column":11}},"198":{"start":{"line":274,"column":10},"end":{"line":274,"column":43}},"199":{"start":{"line":275,"column":10},"end":{"line":275,"column":45}},"200":{"start":{"line":276,"column":10},"end":{"line":276,"column":60}},"201":{"start":{"line":277,"column":10},"end":{"line":277,"column":17}},"202":{"start":{"line":281,"column":4},"end":{"line":312,"column":7}},"203":{"start":{"line":282,"column":6},"end":{"line":290,"column":9}},"204":{"start":{"line":283,"column":21},"end":{"line":283,"column":22}},"205":{"start":{"line":284,"column":8},"end":{"line":289,"column":11}},"206":{"start":{"line":285,"column":10},"end":{"line":285,"column":43}},"207":{"start":{"line":286,"column":10},"end":{"line":286,"column":42}},"208":{"start":{"line":287,"column":10},"end":{"line":287,"column":60}},"209":{"start":{"line":288,"column":10},"end":{"line":288,"column":17}},"210":{"start":{"line":291,"column":6},"end":{"line":300,"column":9}},"211":{"start":{"line":292,"column":21},"end":{"line":292,"column":22}},"212":{"start":{"line":293,"column":8},"end":{"line":299,"column":11}},"213":{"start":{"line":294,"column":10},"end":{"line":294,"column":43}},"214":{"start":{"line":295,"column":10},"end":{"line":295,"column":42}},"215":{"start":{"line":296,"column":10},"end":{"line":296,"column":64}},"216":{"start":{"line":297,"column":10},"end":{"line":297,"column":49}},"217":{"start":{"line":298,"column":10},"end":{"line":298,"column":17}},"218":{"start":{"line":301,"column":6},"end":{"line":311,"column":9}},"219":{"start":{"line":302,"column":21},"end":{"line":302,"column":22}},"220":{"start":{"line":303,"column":8},"end":{"line":310,"column":11}},"221":{"start":{"line":304,"column":10},"end":{"line":304,"column":43}},"222":{"start":{"line":305,"column":10},"end":{"line":305,"column":42}},"223":{"start":{"line":306,"column":10},"end":{"line":306,"column":56}},"224":{"start":{"line":307,"column":10},"end":{"line":307,"column":68}},"225":{"start":{"line":308,"column":10},"end":{"line":308,"column":85}},"226":{"start":{"line":309,"column":10},"end":{"line":309,"column":17}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":41,"column":18},"end":{"line":41,"column":19}},"loc":{"start":{"line":41,"column":30},"end":{"line":314,"column":1}},"line":41},"2":{"name":"(anonymous_2)","decl":{"start":{"line":42,"column":9},"end":{"line":42,"column":10}},"loc":{"start":{"line":42,"column":25},"end":{"line":47,"column":3}},"line":42},"3":{"name":"(anonymous_3)","decl":{"start":{"line":43,"column":90},"end":{"line":43,"column":91}},"loc":{"start":{"line":43,"column":110},"end":{"line":46,"column":5}},"line":43},"4":{"name":"(anonymous_4)","decl":{"start":{"line":48,"column":9},"end":{"line":48,"column":10}},"loc":{"start":{"line":48,"column":25},"end":{"line":53,"column":3}},"line":48},"5":{"name":"(anonymous_5)","decl":{"start":{"line":49,"column":91},"end":{"line":49,"column":92}},"loc":{"start":{"line":49,"column":111},"end":{"line":52,"column":5}},"line":49},"6":{"name":"(anonymous_6)","decl":{"start":{"line":54,"column":9},"end":{"line":54,"column":10}},"loc":{"start":{"line":54,"column":25},"end":{"line":59,"column":3}},"line":54},"7":{"name":"(anonymous_7)","decl":{"start":{"line":55,"column":136},"end":{"line":55,"column":137}},"loc":{"start":{"line":55,"column":156},"end":{"line":58,"column":5}},"line":55},"8":{"name":"(anonymous_8)","decl":{"start":{"line":60,"column":8},"end":{"line":60,"column":9}},"loc":{"start":{"line":60,"column":24},"end":{"line":63,"column":3}},"line":60},"9":{"name":"(anonymous_9)","decl":{"start":{"line":65,"column":31},"end":{"line":65,"column":32}},"loc":{"start":{"line":65,"column":43},"end":{"line":313,"column":3}},"line":65},"10":{"name":"(anonymous_10)","decl":{"start":{"line":66,"column":75},"end":{"line":66,"column":76}},"loc":{"start":{"line":66,"column":91},"end":{"line":74,"column":5}},"line":66},"11":{"name":"(anonymous_11)","decl":{"start":{"line":67,"column":92},"end":{"line":67,"column":93}},"loc":{"start":{"line":67,"column":112},"end":{"line":73,"column":7}},"line":67},"12":{"name":"(anonymous_12)","decl":{"start":{"line":76,"column":59},"end":{"line":76,"column":60}},"loc":{"start":{"line":76,"column":75},"end":{"line":84,"column":5}},"line":76},"13":{"name":"(anonymous_13)","decl":{"start":{"line":77,"column":92},"end":{"line":77,"column":93}},"loc":{"start":{"line":77,"column":112},"end":{"line":83,"column":7}},"line":77},"14":{"name":"(anonymous_14)","decl":{"start":{"line":86,"column":50},"end":{"line":86,"column":51}},"loc":{"start":{"line":86,"column":66},"end":{"line":93,"column":5}},"line":86},"15":{"name":"(anonymous_15)","decl":{"start":{"line":87,"column":92},"end":{"line":87,"column":93}},"loc":{"start":{"line":87,"column":112},"end":{"line":92,"column":7}},"line":87},"16":{"name":"(anonymous_16)","decl":{"start":{"line":95,"column":34},"end":{"line":95,"column":35}},"loc":{"start":{"line":95,"column":46},"end":{"line":105,"column":5}},"line":95},"17":{"name":"(anonymous_17)","decl":{"start":{"line":96,"column":37},"end":{"line":96,"column":38}},"loc":{"start":{"line":96,"column":53},"end":{"line":104,"column":7}},"line":96},"18":{"name":"(anonymous_18)","decl":{"start":{"line":97,"column":92},"end":{"line":97,"column":93}},"loc":{"start":{"line":97,"column":112},"end":{"line":103,"column":9}},"line":97},"19":{"name":"(anonymous_19)","decl":{"start":{"line":107,"column":27},"end":{"line":107,"column":28}},"loc":{"start":{"line":107,"column":39},"end":{"line":142,"column":5}},"line":107},"20":{"name":"(anonymous_20)","decl":{"start":{"line":108,"column":58},"end":{"line":108,"column":59}},"loc":{"start":{"line":108,"column":74},"end":{"line":115,"column":7}},"line":108},"21":{"name":"(anonymous_21)","decl":{"start":{"line":109,"column":110},"end":{"line":109,"column":111}},"loc":{"start":{"line":109,"column":130},"end":{"line":114,"column":9}},"line":109},"22":{"name":"(anonymous_22)","decl":{"start":{"line":116,"column":74},"end":{"line":116,"column":75}},"loc":{"start":{"line":116,"column":90},"end":{"line":123,"column":7}},"line":116},"23":{"name":"(anonymous_23)","decl":{"start":{"line":117,"column":109},"end":{"line":117,"column":110}},"loc":{"start":{"line":117,"column":129},"end":{"line":122,"column":9}},"line":117},"24":{"name":"(anonymous_24)","decl":{"start":{"line":124,"column":66},"end":{"line":124,"column":67}},"loc":{"start":{"line":124,"column":82},"end":{"line":131,"column":7}},"line":124},"25":{"name":"(anonymous_25)","decl":{"start":{"line":125,"column":75},"end":{"line":125,"column":76}},"loc":{"start":{"line":125,"column":95},"end":{"line":130,"column":9}},"line":125},"26":{"name":"(anonymous_26)","decl":{"start":{"line":132,"column":63},"end":{"line":132,"column":64}},"loc":{"start":{"line":132,"column":79},"end":{"line":141,"column":7}},"line":132},"27":{"name":"(anonymous_27)","decl":{"start":{"line":134,"column":123},"end":{"line":134,"column":124}},"loc":{"start":{"line":134,"column":143},"end":{"line":140,"column":9}},"line":134},"28":{"name":"(anonymous_28)","decl":{"start":{"line":143,"column":32},"end":{"line":143,"column":33}},"loc":{"start":{"line":143,"column":44},"end":{"line":204,"column":5}},"line":143},"29":{"name":"(anonymous_29)","decl":{"start":{"line":144,"column":54},"end":{"line":144,"column":55}},"loc":{"start":{"line":144,"column":70},"end":{"line":156,"column":7}},"line":144},"30":{"name":"(anonymous_30)","decl":{"start":{"line":146,"column":116},"end":{"line":146,"column":117}},"loc":{"start":{"line":146,"column":136},"end":{"line":155,"column":9}},"line":146},"31":{"name":"(anonymous_31)","decl":{"start":{"line":157,"column":74},"end":{"line":157,"column":75}},"loc":{"start":{"line":157,"column":90},"end":{"line":169,"column":7}},"line":157},"32":{"name":"(anonymous_32)","decl":{"start":{"line":159,"column":115},"end":{"line":159,"column":116}},"loc":{"start":{"line":159,"column":135},"end":{"line":168,"column":9}},"line":159},"33":{"name":"(anonymous_33)","decl":{"start":{"line":170,"column":69},"end":{"line":170,"column":70}},"loc":{"start":{"line":170,"column":85},"end":{"line":177,"column":7}},"line":170},"34":{"name":"(anonymous_34)","decl":{"start":{"line":172,"column":116},"end":{"line":172,"column":117}},"loc":{"start":{"line":172,"column":136},"end":{"line":176,"column":9}},"line":172},"35":{"name":"(anonymous_35)","decl":{"start":{"line":178,"column":74},"end":{"line":178,"column":75}},"loc":{"start":{"line":178,"column":90},"end":{"line":186,"column":7}},"line":178},"36":{"name":"(anonymous_36)","decl":{"start":{"line":180,"column":117},"end":{"line":180,"column":118}},"loc":{"start":{"line":180,"column":137},"end":{"line":184,"column":9}},"line":180},"37":{"name":"(anonymous_37)","decl":{"start":{"line":187,"column":65},"end":{"line":187,"column":66}},"loc":{"start":{"line":187,"column":81},"end":{"line":195,"column":7}},"line":187},"38":{"name":"(anonymous_38)","decl":{"start":{"line":189,"column":116},"end":{"line":189,"column":117}},"loc":{"start":{"line":189,"column":136},"end":{"line":194,"column":9}},"line":189},"39":{"name":"(anonymous_39)","decl":{"start":{"line":196,"column":64},"end":{"line":196,"column":65}},"loc":{"start":{"line":196,"column":80},"end":{"line":203,"column":7}},"line":196},"40":{"name":"(anonymous_40)","decl":{"start":{"line":198,"column":116},"end":{"line":198,"column":117}},"loc":{"start":{"line":198,"column":136},"end":{"line":202,"column":9}},"line":198},"41":{"name":"(anonymous_41)","decl":{"start":{"line":205,"column":39},"end":{"line":205,"column":40}},"loc":{"start":{"line":205,"column":51},"end":{"line":254,"column":5}},"line":205},"42":{"name":"(anonymous_42)","decl":{"start":{"line":206,"column":73},"end":{"line":206,"column":74}},"loc":{"start":{"line":206,"column":89},"end":{"line":215,"column":7}},"line":206},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":146},"end":{"line":208,"column":147}},"loc":{"start":{"line":208,"column":166},"end":{"line":214,"column":9}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":216,"column":69},"end":{"line":216,"column":70}},"loc":{"start":{"line":216,"column":85},"end":{"line":225,"column":7}},"line":216},"45":{"name":"(anonymous_45)","decl":{"start":{"line":218,"column":153},"end":{"line":218,"column":154}},"loc":{"start":{"line":218,"column":173},"end":{"line":224,"column":9}},"line":218},"46":{"name":"(anonymous_46)","decl":{"start":{"line":226,"column":72},"end":{"line":226,"column":73}},"loc":{"start":{"line":226,"column":88},"end":{"line":235,"column":7}},"line":226},"47":{"name":"(anonymous_47)","decl":{"start":{"line":228,"column":147},"end":{"line":228,"column":148}},"loc":{"start":{"line":228,"column":167},"end":{"line":234,"column":9}},"line":228},"48":{"name":"(anonymous_48)","decl":{"start":{"line":236,"column":102},"end":{"line":236,"column":103}},"loc":{"start":{"line":236,"column":118},"end":{"line":244,"column":7}},"line":236},"49":{"name":"(anonymous_49)","decl":{"start":{"line":238,"column":153},"end":{"line":238,"column":154}},"loc":{"start":{"line":238,"column":173},"end":{"line":243,"column":9}},"line":238},"50":{"name":"(anonymous_50)","decl":{"start":{"line":245,"column":99},"end":{"line":245,"column":100}},"loc":{"start":{"line":245,"column":115},"end":{"line":253,"column":7}},"line":245},"51":{"name":"(anonymous_51)","decl":{"start":{"line":247,"column":153},"end":{"line":247,"column":154}},"loc":{"start":{"line":247,"column":173},"end":{"line":252,"column":9}},"line":247},"52":{"name":"(anonymous_52)","decl":{"start":{"line":255,"column":35},"end":{"line":255,"column":36}},"loc":{"start":{"line":255,"column":47},"end":{"line":280,"column":5}},"line":255},"53":{"name":"(anonymous_53)","decl":{"start":{"line":256,"column":65},"end":{"line":256,"column":66}},"loc":{"start":{"line":256,"column":81},"end":{"line":262,"column":7}},"line":256},"54":{"name":"(anonymous_54)","decl":{"start":{"line":258,"column":119},"end":{"line":258,"column":120}},"loc":{"start":{"line":258,"column":139},"end":{"line":261,"column":9}},"line":258},"55":{"name":"(anonymous_55)","decl":{"start":{"line":263,"column":73},"end":{"line":263,"column":74}},"loc":{"start":{"line":263,"column":89},"end":{"line":270,"column":7}},"line":263},"56":{"name":"(anonymous_56)","decl":{"start":{"line":265,"column":118},"end":{"line":265,"column":119}},"loc":{"start":{"line":265,"column":138},"end":{"line":269,"column":9}},"line":265},"57":{"name":"(anonymous_57)","decl":{"start":{"line":271,"column":62},"end":{"line":271,"column":63}},"loc":{"start":{"line":271,"column":78},"end":{"line":279,"column":7}},"line":271},"58":{"name":"(anonymous_58)","decl":{"start":{"line":273,"column":119},"end":{"line":273,"column":120}},"loc":{"start":{"line":273,"column":139},"end":{"line":278,"column":9}},"line":273},"59":{"name":"(anonymous_59)","decl":{"start":{"line":281,"column":51},"end":{"line":281,"column":52}},"loc":{"start":{"line":281,"column":63},"end":{"line":312,"column":5}},"line":281},"60":{"name":"(anonymous_60)","decl":{"start":{"line":282,"column":68},"end":{"line":282,"column":69}},"loc":{"start":{"line":282,"column":84},"end":{"line":290,"column":7}},"line":282},"61":{"name":"(anonymous_61)","decl":{"start":{"line":284,"column":134},"end":{"line":284,"column":135}},"loc":{"start":{"line":284,"column":154},"end":{"line":289,"column":9}},"line":284},"62":{"name":"(anonymous_62)","decl":{"start":{"line":291,"column":70},"end":{"line":291,"column":71}},"loc":{"start":{"line":291,"column":86},"end":{"line":300,"column":7}},"line":291},"63":{"name":"(anonymous_63)","decl":{"start":{"line":293,"column":100},"end":{"line":293,"column":101}},"loc":{"start":{"line":293,"column":120},"end":{"line":299,"column":9}},"line":293},"64":{"name":"(anonymous_64)","decl":{"start":{"line":301,"column":69},"end":{"line":301,"column":70}},"loc":{"start":{"line":301,"column":85},"end":{"line":311,"column":7}},"line":301},"65":{"name":"(anonymous_65)","decl":{"start":{"line":303,"column":134},"end":{"line":303,"column":135}},"loc":{"start":{"line":303,"column":154},"end":{"line":310,"column":9}},"line":303}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":6,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":0,"129":0,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":1,"139":1,"140":1,"141":1,"142":1,"143":0,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1,"197":1,"198":1,"199":1,"200":1,"201":1,"202":1,"203":1,"204":1,"205":1,"206":1,"207":1,"208":1,"209":1,"210":1,"211":1,"212":1,"213":1,"214":1,"215":1,"216":1,"217":1,"218":1,"219":1,"220":1,"221":1,"222":1,"223":1,"224":1,"225":1,"226":1},"f":{"0":6,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1},"b":{"0":[2,4],"1":[6,6]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"713a643645eedc6218cd0bff22af62fbb26e9d38","contentHash":"f3d48e125f75eafa9592af49762a9de6_11.0.3"}} \ No newline at end of file diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index eb98eb7..eff9866 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index 4255d98..f15ff6d 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index 053bc6d..b9f1bc4 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index d3ee812..f5846ae 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -88,14 +88,14 @@

1x   1x -76x -76x -76x +81x +81x +81x +110x +106x 106x -102x -102x   -76x +81x       @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index fb72392..2c3a47d 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 29ea6cc..4d61cbd 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -721,7 +721,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 6b24c05..8ee86ad 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,9 +20,9 @@

- 72.73% + 72.29% Statements - 168/231 + 167/231
72.41% @@ -30,14 +30,14 @@

84/116

- 64.29% + 63.1% Functions - 54/84 + 53/84
- 72.73% + 72.29% Lines - 168/231 + 167/231
@@ -73,15 +73,15 @@

roles.js -
- 82.5% - 33/40 +
+ 80% + 32/40 72.22% 13/18 - 80.95% - 17/21 - 82.5% - 33/40 + 76.19% + 16/21 + 80% + 32/40 @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index 6bdbfc9..52845e2 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -20,9 +20,9 @@

- 82.5% + 80% Statements - 33/40 + 32/40
72.22% @@ -30,14 +30,14 @@

13/18

- 80.95% + 76.19% Functions - 17/21 + 16/21
- 82.5% + 80% Lines - 33/40 + 32/40
@@ -188,13 +188,13 @@

      -3x +2x   -3x -3x +2x +2x     -3x +2x     2x @@ -209,7 +209,7 @@

      -1x +        @@ -289,11 +289,11 @@

      -2x +3x       -2x +3x   2x 1x @@ -307,7 +307,7 @@

    1x -1x +2x       @@ -343,7 +343,7 @@

res.json(error.errors); }); } - }).catch(error => res.json(error)); + }).catch(error => res.json(error)); } }   @@ -451,7 +451,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index d3f8d61..423e165 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -424,7 +424,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index dd0541b..fd8dcb8 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -901,7 +901,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index 48bb521..15e61a2 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index 1c02c5e..06ba426 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index da5ce39..46e3e38 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -84,14 +84,14 @@

      +64x +64x 60x 60x -56x -56x     -56x -56x +60x +60x       @@ -103,10 +103,10 @@

      -21x +25x 15x   -6x +10x       @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index 5443129..4a038f9 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 340a973..e98b306 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -136,7 +136,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 28dc52a..70f0017 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index 6d63c9e..c3a7641 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 3452507..465c4b5 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -100,7 +100,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 5993531..42bb2e6 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -169,7 +169,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index 9926d4d..f9a832d 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index b2b92d0..3f0dc53 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index 02905fb..46fd940 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index 6c9f27a..96af5c7 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index e6e99b5..cd0743f 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index cddcc51..aeb1c2b 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html new file mode 100644 index 0000000..a5e278c --- /dev/null +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -0,0 +1,1136 @@ + + + + Code coverage report for document-manager/server/test/controllers/document.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test/controllers document.spec.js +

+
+
+ 96.74% + Statements + 178/184 +
+
+ 100% + Branches + 0/0 +
+
+ 98.21% + Functions + 55/56 +
+
+ 96.7% + Lines + 176/182 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +3581x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +  +1x +  +  +  +  +1x +1x +1x +1x +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +1x +  +  +  +1x +  +  +  +1x +  +1x +  +  +  +  +  +1x +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +  +  +  +  +  +1x +  +  +  +1x +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../../index';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Documents', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('/POST Document', () => {
+    it('should add a new document if the user is authenticated', (done) => {
+      const document = {
+        title: 'boromir-team',
+        content: 'Andela is really awesome!!!',
+        access: 'public',
+        userId: 2,
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .send(document)
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(201);
+        expect(res.body).to.be.a('object');
+        expect(res.body).to.have.property('id');
+        expect(res.body.title).to.eql('boromir-team');
+        expect(res.body.content).to.eql('Andela is really awesome!!!');
+        expect(res.body.access).to.equal('public');
+        done();
+      });
+    });
+ 
+    it('Should fail if document already exist', () => {
+      const document = {
+        title: 'John team',
+        content: 'eze goes to school',
+        access: 'public',
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body.message).to.eql('Document already exists');
+      });
+    });
+    it('should fail to add a new document if the user is not authenticated',
+    (done) => {
+      const document = {
+        title: 'boromir-team',
+        content: 'Andela is really awesome !!!',
+        value: 'private',
+        userId: 2,
+      };
+      request(server)
+      .post('/api/v1/documents')
+      .send(document)
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('No token provided.');
+        done();
+      });
+    });
+  });
+ 
+  describe('/GET Documents', () => {
+    it('Should get all documents for the user that is authenticated',
+    (done) => {
+      request(server)
+      .get('/api/v1/documents')
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body).to.be.a('object');
+        expect(res.body).to.have.keys(['document', 'pagination']);
+        done();
+      });
+    });
+    it('should fail to get all documents if the user is not authenticated',
+    (done) => {
+      request(server)
+      .get('/api/v1/documents/')
+      .end((err, res) => {
+        expect(res.status).to.equal(403);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).be.eql('No token provided.');
+        expect(res.body.success).to.eql(false);
+        done();
+      });
+    });
+    it('Should get all documents with correct limit as a query', (done) => {
+      const limit = 1;
+      request(server)
+        .get(`/api/v1/documents?limit=${limit}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          done();
+        });
+    });
+    it('Should get all documents with correct offset as a query', (done) => {
+      const offset = 0;
+      request(server)
+        .get(`/api/v1/documents?limit=${offset}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET/:id Document', () => {
+    it('Should fail to get document if it doesn`t exist', (done) => {
+      const documentId = 8;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document not found');
+          done();
+        });
+    });
+    it('Should get all public regardless of id', (done) => {
+      const documentId = 4;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(4);
+          expect(res.body.title).to.equal('boromir-team');
+          expect(res.body.access).to.equal('public');
+          done();
+        });
+    });
+    it('Should fail to get a private document if the requester does not own it',
+    (done) => {
+      const documentId = 2;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to view this document');
+          done();
+        });
+    });
+    it('Should get a private document the where the requester is the owner',
+    (done) => {
+      const documentId = 2;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.access).to.eql('private');
+          expect(res.body.title).to.eql('John naddddd');
+          expect(res.body.id).to.eql(2);
+          expect(res.body.userId).to.eql(2);
+          done();
+        });
+    });
+    it('Should fail get a role document if the users are not on the same role',
+    (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to view this document');
+          done();
+        });
+    });
+    it('Should get a role document if the users are on the same role',
+    (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(3);
+          expect(res.body.title).to.eql('James Hannn');
+          expect(res.body.access).to.eql('role');
+          done();
+        });
+    });
+    it('Should get a role document if the user is an admin', (done) => {
+      const documentId = 3;
+      request(server)
+        .get(`/api/v1/documents/${documentId}/`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.id).to.eql(3);
+          expect(res.body.title).to.eql('James Hannn');
+          expect(res.body.access).to.eql('role');
+        });
+      done();
+    });
+  });
+ 
+  describe('/PUT/:id, Document', () => {
+    it('Should update a document by id if the user has the same id',
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: userToken })
+          .send({ title: 'wreck it ralph' })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.id).to.eql(2);
+            expect(res.body.title).to.eql('wreck it ralph');
+            done();
+          });
+      });
+    it(`Should fail to update a document by
+      id if the user does not have the same id`,
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: sampleUserToken })
+          .send({ title: 'spiderman Homecoming' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to edit this document');
+            done();
+          });
+      });
+    it('Should not update a document by id if the user has admin access',
+      (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/documents/${id}`)
+          .set({ authorization: adminToken })
+          .send({ title: 'wreck it' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            done();
+          });
+      });
+    it('Should fail to update a document by id if the document does not exist',
+      (done) => {
+        const id = 10;
+        request(server)
+        .put(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .send({ title: 'Deadpool' })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document Not Found');
+          done();
+        });
+      });
+  });
+ 
+  describe('DELETE/:id Document', () => {
+    it('Should delete a document if the user has admin access', (done) => {
+      const id = 3;
+      request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          done();
+        });
+    });
+    it('Should delete a document if the user is the owner', (done) => {
+      const id = 2;
+      request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          done();
+        });
+    });
+    it('Should fail to delete the document given the user is not the owner',
+    (done) => {
+      const id = 1;
+      chai.request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: sampleUserToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql('You are not authorized to delete this document');
+          done();
+        });
+    });
+    it('Should fail to delete if the document does not exist', (done) => {
+      const id = 234;
+      chai.request(server)
+        .delete(`/api/v1/documents/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Document not found');
+          done();
+        });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html new file mode 100644 index 0000000..3a8f473 --- /dev/null +++ b/coverage/document-manager/server/test/controllers/index.html @@ -0,0 +1,145 @@ + + + + Code coverage report for document-manager/server/test/controllers + + + + + + + +
+
+

+ All files document-manager/server/test/controllers +

+
+
+ 94.93% + Statements + 581/612 +
+
+ 100% + Branches + 0/0 +
+
+ 98.41% + Functions + 186/189 +
+
+ 94.87% + Lines + 573/604 +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
document.spec.js
96.74%178/184100%0/098.21%55/5696.7%176/182
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
92.45%147/159100%0/096%48/5092.36%145/157
search.spec.js
82.14%46/56100%0/0100%19/1981.48%44/54
user.spec.js
98.58%208/211100%0/0100%64/6498.56%206/209
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html new file mode 100644 index 0000000..c5c76d7 --- /dev/null +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -0,0 +1,197 @@ + + + + Code coverage report for document-manager/server/test/controllers/mockData.js + + + + + + + +
+
+

+ All files / document-manager/server/test/controllers mockData.js +

+
+
+ 100% + Statements + 2/2 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 0/0 +
+
+ 100% + Lines + 2/2 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +451x +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
import dotenv from 'dotenv';
+ 
+dotenv.config();
+ 
+export default {
+  admin: {
+    email: 'baas@test.com',
+    password: process.env.TEST_ADMIN_PASSWORD
+  },
+  fellow: {
+    email: 'john@test.com',
+    password: process.env.TEST_FELLOW_PASSWORD
+  },
+  faciliatator: {
+    email: 'blessing@test.com',
+    password: process.env.TEST_FACILITATOR_PASSWORD
+  },
+  user2: {
+    email: 'baas@test.com',
+    password: 'test'
+  },
+  user1: {
+    email: 'test@test123.com',
+    password: 'test'
+  },
+  fakeBass: {
+    fullName: 'Baasbank Adams',
+    userName: 'tiaandela',
+    email: 'name@example.com',
+    password: 'pass123',
+    roleId: 1,
+    createdAt: new Date(),
+    updatedAt: new Date()
+  },
+  fakeUserDetails: {
+    fullName: 'Daniel Cfh',
+    userName: 'cfh',
+    email: 'cfh@example.com',
+    password: 'pass123',
+    roleId: 2,
+    createdAt: 'date',
+    updatedAt: new Date()
+  },
+};
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html new file mode 100644 index 0000000..7a5a046 --- /dev/null +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -0,0 +1,977 @@ + + + + Code coverage report for document-manager/server/test/controllers/role.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test/controllers role.spec.js +

+
+
+ 92.45% + Statements + 147/159 +
+
+ 100% + Branches + 0/0 +
+
+ 96% + Functions + 48/50 +
+
+ 92.36% + Lines + 145/157 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +3051x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +1x +  +1x +1x +  +  +  +  +1x +  +  +  +  +1x +  +1x +1x +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +  +  +  +1x +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +  +  +1x +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +  +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../../index';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Roles', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('/POST Role', () => {
+    it('should add a new role if the user is an admin', (done) => {
+      request(server)
+      .post('/api/v1/roles')
+      .send({ title: 'boromir' })
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(201);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('Role successfully created');
+        expect(res.body).to.have.property('role');
+        expect(res.body.role).to.have.property('title').to.equal('boromir');
+      });
+      done();
+    });
+    it('should add a new role if the user is an admin', (done) => {
+      request(server)
+      .post('/api/v1/roles')
+      .send({ title: 'king' })
+      .set({ authorization: adminToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(204);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('Role successfully created');
+        expect(res.body).to.have.property('role');
+      });
+      done();
+    });
+    it('Should fail if a non-admin wants to add a new role', (done) => {
+      const role = {
+        title: 'boromir-team'
+      };
+      request(server)
+        .post('/api/v1/roles/')
+        .set({ authorization: userToken })
+      .send(role)
+      .end((err, res) => {
+        expect(res.status).to.equal(401);
+        expect(res.body).to.be.a('object');
+        expect(res.body.message).to.eql('You are not authorized');
+        done();
+      });
+    });
+    it('Should return an error if the title is not a string', (done) => {
+      chai.request(server)
+        .post('/api/v1/roles')
+        .set({ authorization: adminToken })
+        .send({ title: 358583 })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Invalid input credentials');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET Role', () => {
+    it('Should get all the roles if the user is an admin', (done) => {
+      chai.request(server)
+        .get('/api/v1/roles')
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.have.length(5);
+          expect(res.body).to.be.a('array');
+          expect(res.body[0].id).to.eql(1);
+          expect(res.body[0].title).to.eql('admin');
+          expect(res.body[1].id).to.eql(2);
+          expect(res.body[1].title).to.eql('facilitator');
+          done();
+        });
+    });
+    it('Should fail to get the roles if the user is not admin', (done) => {
+      chai.request(server)
+        .get('/api/v1/roles')
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message)
+          .to.eql('You are not authorized');
+          done();
+        });
+    });
+  });
+ 
+  describe('/GET/:id Role', () => {
+    it('Should get a role by id if the user is an admin', (done) => {
+      const id = 2;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).be.a('object');
+          expect(res.body.title).to.eql('facilitator');
+          expect(res.body.id).to.equal(2);
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the user is not an admin',
+    (done) => {
+      const id = 2;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the user enters an invalid input',
+    (done) => {
+      const id = 'fddjsdcdjn';
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body.message)
+          .to.eql(`invalid input syntax for integer: "${id}"`);
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the role does not exist', (done) => {
+      const id = 250;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body.message).to.eql('Role not found');
+          done();
+        });
+    });
+    it('Should fail to get a role by id if the id is out of range', (done) => {
+      const id = 500000000000000000000;
+      chai.request(server)
+        .get(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body.message)
+          .to.eql(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+  describe('/PUT/:id Role', () => {
+    it('Should update a role by id if the user has admin access', (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'boromir-team' })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('Role updated successfully');
+          expect(res.body).to.have.property('role');
+          done();
+        });
+    });
+    it('Should fail to update a role by id if the user has no admin access',
+    (done) => {
+      const id = 2;
+      chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: userToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it(`Should fail to update a
+       role by id if the admin enters an invalid input`,
+      (done) => {
+        const id = 200;
+        chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+         .set({ authorization: adminToken })
+        .send({ title: 'kiba' })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.equal('Role not found');
+          done();
+        });
+      });
+    it(`Should fail to update a role by
+      id if the admin enters an id that is out range`,
+      (done) => {
+        const id = 2000000000000000;
+        chai.request(server)
+          .put(`/api/v1/roles/${id}`)
+          .set({ authorization: adminToken })
+          .send({ title: 'regular' })
+          .end((err, res) => {
+            expect(res.status).to.equal(400);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql(`value "${id}" is out of range for type integer`);
+            done();
+          });
+      });
+  });
+  describe('/DELETE/:id Role', () => {
+    it('Should delete a role given the user has admin access', (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(204);
+          expect(res.body).to.be.a('object');
+        });
+      done();
+    });
+    it('Should fail to delete a role given the user has no admin access',
+    (done) => {
+      const id = 3;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.eql('You are not authorized');
+          done();
+        });
+    });
+    it('Should fail to delete a role given the admin enters an invalid input',
+    (done) => {
+      const id = 300;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message).to.equal('Role not found');
+          done();
+        });
+    });
+    it(`Should fail to delete a role given
+      the admin enters an input that is out of range`, (done) => {
+      const id = 3000000000000000;
+      chai.request(server)
+        .delete(`/api/v1/roles/${id}`)
+        .set({ authorization: adminToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.be.a('object');
+          expect(res.body.message)
+          .to.eql(`value "${id}" is out of range for type integer`);
+          done();
+        });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html new file mode 100644 index 0000000..dd6f75e --- /dev/null +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -0,0 +1,377 @@ + + + + Code coverage report for document-manager/server/test/controllers/search.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test/controllers search.spec.js +

+
+
+ 82.14% + Statements + 46/56 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 19/19 +
+
+ 81.48% + Lines + 44/54 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +1051x +1x +1x +1x +1x +  +  +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +  +  +  +1x +  +1x +1x +  +  +  +1x +  +  +  +  +  +1x +1x +1x +1x +  +  +  +1x +  +  +  +1x +1x +1x +  +  +  +1x +  +  +  +  +  +  +  +1x +1x +1x +  +  +  +1x +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../../index';
+import data from './mockData';
+ 
+ 
+process.env.NODE_ENV = 'test';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fellow } = data;
+ 
+describe('Search', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('/SEARCH/users/?q={name}', () => {
+    it('Should return an error if no querystring is provided', () => {
+      const query = '';
+      request(server)
+        .get(`/api/v1/search/users/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body.message).to.eql('Invalid search input');
+        });
+    });
+    it('Should return a search list response of the required search input',
+    () => {
+      const query = 'jame';
+      request(server)
+      .get(`/api/v1/search/users/?q=${query}`)
+      .set({ authorization: userToken })
+      .end((err, res) => {
+        expect(res.status).to.equal(200);
+        expect(res.body.fullName).to.eql('jame doe');
+        expect(res.body.userName).to.eql('testdoe');
+      });
+    });
+  });
+  describe('/SEARCH/documents/?q=', () => {
+    it('Should return an error if no querystring is provided', () => {
+      const query = '';
+      request(server)
+        .get(`/api/v1/search/document/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.have.property('message').to.equal('Invalid search input')
+        });
+      });
+     it('Should return a search list of the required search input', () => {
+       const query = 'John';
+       request(server)
+        .get(`/api/v1/search/documents/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(200);
+          expect(res.body).to.have.property('document');
+          expect(res.body.document[0]).to.have.property('title').to.equal('John Doe');
+          expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school');
+          expect(res.body).to.have.property('pagination');
+          expect(res.body.paginaton).to.have.property('totalCount').to.equal(1);
+        });
+     });
+     it('Should throw an error if the searched document is not found', () => {
+       const query = 'jk';
+       request(server)
+        .get(`/api/v1/search/documents/?q=${query}`)
+        .set({ authorization: userToken })
+        .end((err, res) => {
+          expect(res.status).to.equal(404);
+          expect(res.body).to.have.property('message').to.equal('Document not found');
+        });
+     });
+   });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html new file mode 100644 index 0000000..00de34e --- /dev/null +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -0,0 +1,1232 @@ + + + + Code coverage report for document-manager/server/test/controllers/user.spec.js + + + + + + + +
+
+

+ All files / document-manager/server/test/controllers user.spec.js +

+
+
+ 98.58% + Statements + 208/211 +
+
+ 100% + Branches + 0/0 +
+
+ 100% + Functions + 64/64 +
+
+ 98.56% + Lines + 206/209 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +3901x +1x +1x +1x +1x +  +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +  +1x +1x +1x +  +1x +1x +  +  +  +1x +1x +  +  +  +1x +1x +1x +  +1x +1x +  +  +  +1x +1x +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +  +1x +1x +  +1x +1x +  +1x +  +  +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +1x +1x +  +  +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +  +1x +1x +  +  +  +1x +  +  +  +1x +  +1x +  +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +  +  +  +  +1x +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +  +  +1x +1x +1x +1x +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +1x +  +  +1x +1x +  +  +  +  +1x +1x +1x +  +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +  +  +1x +  +1x +1x +  +  +  +1x +1x +  +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +1x +  +  +1x +1x +1x +1x +1x +  +  +1x +1x +1x +  +  +  +1x +1x +1x +1x +1x +  +1x +  +  +  +  +  + 
import chai from 'chai';
+import request from 'supertest';
+import http from 'chai-http';
+import server from '../../../index';
+import data from './mockData';
+ 
+const expect = chai.expect;
+chai.use(http);
+let userToken, adminToken, sampleUserToken;
+const { admin, fakeBass, fellow, user1, user2 } = data;
+ 
+describe('Users', () => {
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(admin)
+        .end((err, res) => {
+          adminToken = res.body.token;
+          done();
+        });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
+      });
+  });
+  before((done) => {
+    request(server)
+      .post('/api/v1/users/login')
+      .send({ email: 'blessing@test.com', password: 'pass123' })
+      .end((err, res) => {
+        sampleUserToken = res.body.token;
+        done();
+      });
+  });
+ 
+  describe('/POST User login', () => {
+    it('Should fail if the user enters incorrect crendentials upon login',
+    (done) => {
+      request(server)
+        .post('/api/v1/users/login')
+        .send(user1)
+        .end((err, res) => {
+          expect(res.status).to.equal(400);
+          expect(res.body).to.have.keys(['message', 'success']);
+          expect(res.body.message)
+          .to.eql('Authentication failed. User not found.');
+          expect(res.body.success).to.eql(false);
+          done();
+        });
+    });
+ 
+    it('Should fail if the user provide a wrong password', (done) => {
+      request(server)
+        .post('/api/v1/users/login')
+        .send(user2)
+        .end((err, res) => {
+          expect(res.status).to.equal(401);
+          expect(res.body).to.have.keys(['message', 'success']);
+          expect(res.body.message)
+          .to.eql('Authentication failed. Wrong password.');
+          expect(res.body.success).to.eql(false);
+          done();
+        });
+    });
+ 
+    it('should log in a user and return a token', (done) => {
+      request(server)
+        .post('/api/v1/users/login').send(admin).end((err, res) => {
+          expect(res.status).to.equal(201);
+          expect(res.body).to.have.keys(['success', 'token']);
+          expect(res.body.success).to.eql(true);
+          done();
+        });
+    });
+ 
+    describe('/POST User Signup', () => {
+      it('should create a new user', (done) => {
+        request(server)
+          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body)
+              .to.have.keys(['message', 'success', 'userDetails']);
+            expect(res.body.success).to.eql(true);
+            expect(res.body.message)
+            .to.eql('You have successfully registered.');
+            done();
+          });
+      });
+    });
+ 
+    describe('#GET Users', () => {
+      it('Should get all users if the user is an admin ', (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body).to.have.keys(['user', 'pagination']);
+            done();
+          });
+      });
+      it('Should fail to get all users if the user has no admin access ',
+      (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('You are not authorized');
+            done();
+          });
+      });
+      it('Should fail to get all users if no token was provided', (done) => {
+        request(server)
+          .get('/api/v1/users')
+          .end((err, res) => {
+            expect(res.status).to.equal(403);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('No token provided.');
+            done();
+          });
+      });
+      it('Should get all users with correct limit as a query', (done) => {
+        const limit = 1;
+        chai.request(server)
+          .get(`/api/v1/users?limit=${limit}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.user[0].fullName).to.equal('Baas Bank');
+            expect(res.body.user[0].userName).to.equal('bank');
+            done();
+          });
+      });
+    });
+    describe('#GET User by Id', () => {
+      it('Should get a user if the user is an admin', (done) => {
+        const id = 2;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('array');
+            expect(res.body[0].fullName).to.eql('John Bosco');
+            expect(res.body[0].id).to.eql(2);
+            expect(res.body[0].userName).to.eql('john');
+            expect(res.body[0].email).to.eql('john@test.com');
+            expect(res.body[0].roleId).to.eql(2);
+            done();
+          });
+      });
+      it('Should get the user if the requested user is the current user',
+      (done) => {
+        const id = 2;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('array');
+            expect(res.body[0].fullName).to.eql('John Bosco');
+            expect(res.body[0].id).eql(2);
+            expect(res.body[0].userName).to.eql('john');
+            expect(res.body[0].email).to.eql('john@test.com');
+            expect(res.body[0].roleId).to.eql(2);
+            done();
+          });
+      });
+      it('Should fail to get a user if an invalid input is entered',
+      (done) => {
+        const id = 'fddjsdcdjn';
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.have.property('message')
+            .to.eql(`invalid input syntax for integer: "${id}"`);
+            done();
+          });
+      });
+      it('should fail to get the user if the requester is not the owner',
+      (done) => {
+        const id = 2;
+        request(server)
+          .get(`api/users/${id}`)
+          .set({ authorization: sampleUserToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.have.keys(['message']);
+            expect(res.body.message).to.eql('Unauthorized access');
+          });
+        done();
+      });
+      it('Should fail to get a user if the user does not exist',
+      (done) => {
+        const id = 250;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).to.have.property('message');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+      it('Should fail to get a user if the id is out of range',
+      (done) => {
+        const id = 500000000000000000;
+        request(server)
+          .get(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(400);
+            expect(res.body).to.have.property('message')
+            .to.equal(`value "${id}" is out of range for type integer`);
+            done();
+          });
+      });
+    });
+    describe('#PUT Update user by Id', () => {
+      it('Should update a user`s full name if the user has the same id',
+        (done) => {
+          const id = 2;
+          request(server)
+            .put(`/api/v1/users/${id}`)
+            .set({ authorization: userToken })
+            .send({ fullName: 'jake doe' })
+            .end((err, res) => {
+              expect(res.status).to.equal(200);
+              expect(res.body).to.be.a('object');
+              expect(res.body.id).to.eql(2);
+              expect(res.body.fullName).to.eql('jake doe');
+              done();
+            });
+        });
+      it('Should update a user`s email if the user has the same id', (done) => {
+        const id = 2;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).to.be.a('object');
+            expect(res.body.id).to.eql(2);
+            expect(res.body.email).to.eql('jakedoe@andela.com');
+            done();
+          });
+      });
+      it('Should update a user`s username if the user has the same id',
+        (done) => {
+          const id = 2;
+          request(server)
+            .put(`/api/v1/users/${id}`)
+            .set({ authorization: userToken })
+            .send({ userName: 'jakedoe12' })
+            .end((err, res) => {
+              expect(res.status).to.equal(200);
+              expect(res.body).to.be.a('object');
+              expect(res.body.id).to.eql(2);
+              expect(res.body.userName).to.eql('jakedoe12');
+              done();
+            });
+        });
+      it(`Should fail to update a user's
+      details if the user does not have the same user id`,
+      (done) => {
+        const id = 3;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this user');
+            done();
+          });
+      });
+      it(`Should fail to update a user's
+        details if the user enters an invalid user id`,
+      (done) => {
+        const id = 2302;
+        request(server)
+          .put(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .send({ email: 'jakedoe@andela.com' })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this user');
+            done();
+          });
+      });
+    });
+    describe('#DELETE /:id Users', () => {
+      it('Should delete a user given the user has admin access', (done) => {
+        const id = 3;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(204);
+            done();
+          });
+      });
+      it('Should fail to delete a user if the user has no admin access',
+      (done) => {
+        const id = 3;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(401);
+            expect(res.body.message)
+            .to.eql('You are not authorized to access this field');
+            done();
+          });
+      });
+      it('Should give a User not found if user don\'t exist', (done) => {
+        const id = 23;
+        request(server)
+          .delete(`/api/v1/users/${id}`)
+          .set({ authorization: adminToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).to.be.a('object');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+    });
+    describe('/GET/users/:id/documents Documents', () => {
+      it('Should fail to get documents if the user does not exist', (done) => {
+        const userId = 9;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(404);
+            expect(res.body).be.a('object');
+            expect(res.body.message).to.eql('User not found');
+            done();
+          });
+      });
+      it('Should fail to get documents if there is no token present',
+      (done) => {
+        const userId = 2;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .end((err, res) => {
+            expect(res.status).to.equal(403);
+            expect(res.body).be.a('object');
+            expect(res.body.message).to.eql('No token provided.');
+            expect(res.body.success).to.eql(false);
+            done();
+          });
+      });
+      it('Should get documents for the user with its unique userId', (done) => {
+        const userId = 2;
+        request(server)
+          .get(`/api/v1/users/${userId}/documents`)
+          .set({ authorization: userToken })
+          .end((err, res) => {
+            expect(res.status).to.equal(200);
+            expect(res.body).be.a('object');
+            expect(res.body.document[1].userId).to.eql(2);
+            expect(res.body.document[1].title).to.eql('boromir-team');
+            expect(res.body.document[1].content)
+            .to.eql('Andela is really awesome!!!');
+            done();
+          });
+      });
+    });
+  });
+});
+ 
+
+
+ + + + + + + diff --git a/coverage/document-manager/server/test/document.spec.js.html b/coverage/document-manager/server/test/document.spec.js.html index 1204526..73007d7 100644 --- a/coverage/document-manager/server/test/document.spec.js.html +++ b/coverage/document-manager/server/test/document.spec.js.html @@ -20,9 +20,9 @@

- 96.81% + 96.76% Statements - 182/188 + 179/185
100% @@ -30,14 +30,14 @@

0/0

- 98.25% + 98.21% Functions - 56/57 + 55/56
- 96.77% + 96.72% Lines - 180/186 + 177/183
@@ -401,11 +401,7 @@

356 357 358 -359 -360 -361 -362 -3631x +3591x 1x 1x 1x @@ -445,10 +441,6 @@

1x     -1x -1x -1x -    1x 1x @@ -807,10 +799,6 @@

done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - });   describe('/POST Document', () => { it('should add a new document if the user is authenticated', (done) => { @@ -1135,7 +1123,7 @@

diff --git a/coverage/document-manager/server/test/index.html b/coverage/document-manager/server/test/index.html index 3b356d5..003d5a5 100644 --- a/coverage/document-manager/server/test/index.html +++ b/coverage/document-manager/server/test/index.html @@ -20,9 +20,9 @@

- 92.03% + 95.28% Statements - 577/627 + 586/615
100% @@ -30,14 +30,14 @@

0/0

- 93.26% + 99.47% Functions - 180/193 + 188/189
- 91.92% + 95.22% Lines - 569/619 + 578/607
@@ -60,15 +60,15 @@

document.spec.js -
- 96.81% - 182/188 +
+ 96.76% + 179/185 100% 0/0 - 98.25% - 56/57 - 96.77% - 180/186 + 98.21% + 55/56 + 96.72% + 177/183 @@ -86,41 +86,41 @@

role.spec.js -
- 90.8% - 148/163 +
+ 93.75% + 150/160 100% 0/0 - 96.08% - 49/51 - 90.68% - 146/161 + 100% + 50/50 + 93.67% + 148/158 - search.spec.js -
- 55.93% - 33/59 + search.spec.js +
+ 82.14% + 46/56 100% 0/0 - 50% - 10/20 - 54.39% - 31/57 + 100% + 19/19 + 81.48% + 44/54 user.spec.js -
- 98.6% - 212/215 +
+ 98.58% + 209/212 100% 0/0 100% - 65/65 - 98.59% - 210/213 + 64/64 + 98.57% + 207/210 @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/middlewares/auth.spec.js.html b/coverage/document-manager/server/test/middlewares/auth.spec.js.html index 7fe8f43..52005bf 100644 --- a/coverage/document-manager/server/test/middlewares/auth.spec.js.html +++ b/coverage/document-manager/server/test/middlewares/auth.spec.js.html @@ -20,9 +20,9 @@

- 79.69% + 35.48% Statements - 51/64 + 22/62
100% @@ -30,18 +30,18 @@

0/0

- 60% + 20% Functions - 12/20 + 4/20
- 79.37% + 34.43% Lines - 50/63 + 21/61
-
+
1 2 @@ -151,8 +151,7 @@

106 107

1x 1x -1x -1x +  1x 1x 1x @@ -162,59 +161,60 @@

  1x 1x +  1x 1x 1x       -1x -1x +  +      1x -1x +        -1x -1x +  +        1x 1x -1x +        -1x -1x -1x +  +  +        1x -1x +          -1x -1x -1x +  +  +        1x -1x +          -1x -1x -1x +  +  +        @@ -224,30 +224,30 @@

  1x 1x -1x +          -1x -1x -1x -1x +  +  +  +            1x -1x +          -1x -1x -1x -1x +  +  +  +        @@ -255,72 +255,72 @@

      - 

process.NODE_ENV = 'test';
-const chai = require('chai');
-require('dotenv').config();
+ 
const chai = require('chai');
 const chaiHttp = require('chai-http');
+ 
 const expect = chai.expect;
 const EventEmitter = require('events').EventEmitter;
 const httpMocks = require('node-mocks-http');
-const samples = require('../mockData');
+const data = require('../controllers/mockdata');
 const server = require('../../../index');
 const auth = require('../../middlewares/auth');
  
 chai.use(chaiHttp);
 let adminToken, userToken;
+const { admin, fellow } = data;
 describe('Authentication', () => {
   before((done) => {
     chai.request(server)
       .post('/api/v1/users/login')
-      .send({ email: 'johnbosco.ohia@andela.com', password: process.env.PASSWORD })
-      .end((err, res) => {
-        adminToken = res.body.token;
-        done();
+      .send(admin)
+      .end((err, res) => {
+        adminToken = res.body.token;
+        done();
       });
   });
-  before((done) => {
-    chai.request(server)
+    before((done) => {
+    chai.request(server)
       .post('/api/v1/users/login')
-      .send({ email: 'testdoe@andela.com', password: 'jamestest' })
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
+      .send(fellow)
+      .end((err, res) => {
+        userToken = res.body.token;
+        done();
       });
   });
  
-  describe('VerifyToken', () => {
-    it('Should check if the token is provided with request', (done) => {
-      const request = httpMocks.createRequest({
+  describe('VerifyJwtToken', () => {
+    it('Should check if the token is provided with request', (done) => {
+      const request = httpMocks.createRequest({
         method: 'GET',
         url: '/api/v1/documents',
       });
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.verifyToken(request, response, nextCallBack);
+      const response = httpMocks.createResponse();
+      const nextCallBack = () => { };
+      auth.verifyJwtToken(request, response, nextCallBack);
       expect(response._getData().message).to.equal('No token provided.');
       done();
     });
-  it('Should provide access if the token is provided and valid', (done) => {
-    const request = httpMocks.createRequest({
+  it('Should provide access if the token is provided and valid', (done) => {
+    const request = httpMocks.createRequest({
       method: 'GET',
       url: '/api/v1/documents',
       headers: { 'x-access-token': adminToken }
     });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyToken(request, response, nextCallBack);
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyJwtToken(request, response, nextCallBack);
     expect(response._getData().message).to.equal(undefined);
     done();
   });
-  it('Should deny access if the token is invalid', (done) => {
-    const request = httpMocks.createRequest({
+  it('Should deny access if the token is invalid', (done) => {
+    const request = httpMocks.createRequest({
       method: 'GET',
       url: '/api/v1/documents/',
       headers: { 'x-access-token': 'themaniscoming' }
     });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyToken(request, response, nextCallBack);
+    const response = httpMocks.createResponse();
+    const nextCallBack = () => { };
+    auth.verifyJwtToken(request, response, nextCallBack);
  
     response.on('end', () => {
       expect(response._getData().success).to.equal(false);
@@ -329,31 +329,31 @@ 

}); }); describe('AdminAcess', () => { - it('Should deny access if the user is not admin', (done) => { - const request = httpMocks.createRequest({ + it('Should deny access if the user is not admin', (done) => { + const request = httpMocks.createRequest({ method: 'GET', url: '/api/v1/documents/', headers: { 'x-access-token': userToken } }); - request.decoded = { roleId: 2 }; - const response = httpMocks.createResponse(); - const nextCallBack = () => { }; - auth.adminAccess(request, response, nextCallBack); + request.decoded = { roleId: 2 }; + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.adminAccess(request, response, nextCallBack); response.on('end', () => { expect(response._getData().message).to.equal('You are not authorized'); }); done(); }); - it('Should grant access if the user is an admin', (done) => { - const request = httpMocks.createRequest({ + it('Should grant access if the user is an admin', (done) => { + const request = httpMocks.createRequest({ method: 'GET', url: '/api/v1/documents/', headers: { 'x-access-token': adminToken } }); - request.decoded = { roleId: 1 }; - const response = httpMocks.createResponse(); - const nextCallBack = () => { }; - auth.adminAccess(request, response, nextCallBack); + request.decoded = { roleId: 1 }; + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.adminAccess(request, response, nextCallBack); response.on('end', () => { expect(response._getData().message).to.equal(undefined); }); @@ -367,7 +367,7 @@

diff --git a/coverage/document-manager/server/test/middlewares/index.html b/coverage/document-manager/server/test/middlewares/index.html index 82e75be..d19829c 100644 --- a/coverage/document-manager/server/test/middlewares/index.html +++ b/coverage/document-manager/server/test/middlewares/index.html @@ -20,9 +20,9 @@

- 79.69% + 35.48% Statements - 51/64 + 22/62
100% @@ -30,18 +30,18 @@

0/0

- 60% + 20% Functions - 12/20 + 4/20
- 79.37% + 34.43% Lines - 50/63 + 21/61
-
+
@@ -59,16 +59,16 @@

- - - - + + + + - - - - + + + + @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/test/mockData.js.html b/coverage/document-manager/server/test/mockData.js.html index 33ecd39..2135885 100644 --- a/coverage/document-manager/server/test/mockData.js.html +++ b/coverage/document-manager/server/test/mockData.js.html @@ -181,7 +181,7 @@

diff --git a/coverage/document-manager/server/test/role.spec.js.html b/coverage/document-manager/server/test/role.spec.js.html index 15bb0c0..eec4810 100644 --- a/coverage/document-manager/server/test/role.spec.js.html +++ b/coverage/document-manager/server/test/role.spec.js.html @@ -20,9 +20,9 @@

- 90.8% + 93.75% Statements - 148/163 + 150/160
100% @@ -30,14 +30,14 @@

0/0

- 96.08% + 100% Functions - 49/51 + 50/50
- 90.68% + 93.67% Lines - 146/161 + 148/158
@@ -348,11 +348,7 @@

303 304 305 -306 -307 -308 -309 -310

- - - + + + - - - - + + + + @@ -151,15 +151,15 @@

- - - + + + - - + + @@ -168,7 +168,7 @@

diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 2aebead..558b035 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -15,7 +15,9 @@ const paths = { // Compile all Babel Javascript into ES5 and put it into the dist dir gulp.task('babel', () => gulp.src(paths.js, { base: '.' }) - .pipe(plugins.babel()) + .pipe(plugins.babel({ + ignore: 'gulpfile.babel.js' + })) .pipe(gulp.dest('dist')) ); diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index 69f2b45..f254e31 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -73,32 +73,32 @@ describe('Search', () => { .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('Invalid search input') + expect(res.body.message).to.eql('Invalid search input'); }); - }); - it('Should return a search list of the required search input', () => { - const query = 'John'; - request(server) + }); + it('Should return a search list of the required search input', () => { + const query = 'John'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.have.property('document'); - expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); - expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); + expect(res.body.document[0].title).to.equal('John Doe'); + expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); }); - }); - it('Should throw an error if the searched document is not found', () => { - const query = 'jk'; - request(server) + }); + it('Should throw an error if the searched document is not found', () => { + const query = 'jk'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(404); - expect(res.body).to.have.property('message').to.equal('Document not found'); + expect(res.body.message).to.equal('Document not found'); }); - }); - }); + }); + }); }); diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index ff8fefe..ba05454 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -97,7 +97,7 @@ describe('Users', () => { it('Should get all users if the user is an admin ', (done) => { request(server) .get('/api/v1/users') - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -109,7 +109,7 @@ describe('Users', () => { (done) => { request(server) .get('/api/v1/users') - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); @@ -131,7 +131,7 @@ describe('Users', () => { const limit = 1; chai.request(server) .get(`/api/v1/users?limit=${limit}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -146,7 +146,7 @@ describe('Users', () => { const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -163,7 +163,7 @@ describe('Users', () => { const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -180,7 +180,7 @@ describe('Users', () => { const id = 'fddjsdcdjn'; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.property('message') @@ -193,7 +193,7 @@ describe('Users', () => { const id = 2; request(server) .get(`api/users/${id}`) - .set({ authorization: sampleUserToken }) + .set({ 'authorization': sampleUserToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.keys(['message']); @@ -206,7 +206,7 @@ describe('Users', () => { const id = 250; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.have.property('message'); @@ -234,7 +234,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ fullName: 'jake doe' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -248,7 +248,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -263,7 +263,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ userName: 'jakedoe12' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -279,7 +279,7 @@ describe('Users', () => { const id = 3; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -295,7 +295,7 @@ describe('Users', () => { const id = 2302; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -311,7 +311,7 @@ describe('Users', () => { const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(204); done(); @@ -322,7 +322,7 @@ describe('Users', () => { const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body.message) @@ -334,7 +334,7 @@ describe('Users', () => { const id = 23; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); @@ -348,7 +348,7 @@ describe('Users', () => { const userId = 9; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).be.a('object'); @@ -373,7 +373,7 @@ describe('Users', () => { const userId = 2; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('object'); From 5a6dfbfb67a8b05c7849093077dc91f1db97ef6e Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 31 Jul 2017 14:41:39 +0100 Subject: [PATCH 39/98] feat(test): writing tests - make sure tests are passing [Finishes #149632847] --- .coverrun | 1 + coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 16 +- .../document-manager/server/config/index.html | 2 +- .../server/controllers/documents.js.html | 2 +- .../server/controllers/index.html | 36 +- .../server/controllers/roles.js.html | 8 +- .../server/controllers/search.js.html | 61 ++-- .../server/controllers/users.js.html | 2 +- .../server/helpers/helper.js.html | 4 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 20 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 2 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 2 +- .../server/routes/users.js.html | 2 +- .../test/controllers/document.spec.js.html | 2 +- .../server/test/controllers/index.html | 38 +-- .../server/test/controllers/mockData.js.html | 31 +- .../server/test/controllers/role.spec.js.html | 38 +-- .../test/controllers/search.spec.js.html | 67 ++-- .../server/test/controllers/user.spec.js.html | 2 +- coverage/index.html | 50 +-- coverage/mockData.js.html | 2 +- dist/gulpfile.babel.js | 57 +++- dist/server/controllers/searches.js | 144 -------- .../migrations/20170709115813-create-role.js | 30 -- dist/server/test/controllers/document.spec.js | 283 ++++++++++++++++ dist/server/test/controllers/mockData.js | 63 ++++ dist/server/test/controllers/role.spec.js | 261 +++++++++++++++ dist/server/test/controllers/search.spec.js | 113 +++++++ dist/server/test/controllers/user.spec.js | 311 ++++++++++++++++++ gulpfile.babel.js | 50 ++- package.json | 20 +- server/test/controllers/mockData.js | 9 + server/test/controllers/role.spec.js | 134 ++++---- server/test/controllers/search.spec.js | 95 +++--- server/test/controllers/user.spec.js | 62 ++-- 48 files changed, 1507 insertions(+), 539 deletions(-) create mode 100644 .coverrun delete mode 100644 dist/server/controllers/searches.js delete mode 100644 dist/server/migrations/20170709115813-create-role.js create mode 100644 dist/server/test/controllers/document.spec.js create mode 100644 dist/server/test/controllers/mockData.js create mode 100644 dist/server/test/controllers/role.spec.js create mode 100644 dist/server/test/controllers/search.spec.js create mode 100644 dist/server/test/controllers/user.spec.js diff --git a/.coverrun b/.coverrun new file mode 100644 index 0000000..b800c06 --- /dev/null +++ b/.coverrun @@ -0,0 +1 @@ +{ "run" : ".cover_43099142794518275" } \ No newline at end of file diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index e19d5e0..1239f28 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index 2154d6a..df7bea5 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index afb70da..f3c3834 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index 847358b..3c18831 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -88,14 +88,14 @@

1x   1x -81x -81x -81x -110x -106x -106x +82x +82x +82x +113x +109x +109x   -81x +82x       @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index bffc262..48b7889 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 859a6e2..30bfc42 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -721,7 +721,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 3cca8eb..0d2abb2 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,24 +20,24 @@

- 72.73% + 76.72% Statements - 168/231 + 178/232
- 72.41% + 75% Branches - 84/116 + 87/116
- 64.29% + 66.67% Functions - 54/84 + 56/84
- 72.73% + 76.72% Lines - 168/231 + 178/232
@@ -86,15 +86,15 @@

- - - - - - - - - + + + + + + + + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index d9f6f0d..d0cd455 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -289,11 +289,11 @@

      -2x +3x       -2x +3x   2x 1x @@ -307,7 +307,7 @@

    1x -1x +2x       @@ -451,7 +451,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index 97449f2..471e156 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -20,24 +20,24 @@

- 14.29% + 41.67% Statements - 5/35 + 15/36
- 0% + 21.43% Branches - 0/14 + 3/14
- 0% + 25% Functions - 0/8 + 2/8
- 14.29% + 41.67% Lines - 5/35 + 15/36
@@ -168,7 +168,8 @@

123 124 125 -126

- - - + + + - - - - + + + + - - - + + + - - + + @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html index cf2715e..da1b8aa 100644 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -87,7 +87,16 @@

42 43 44 -45

- - - - - - - - - + + + + + + + + + @@ -151,15 +151,15 @@

- - - + + + - - - - + + + + @@ -168,7 +168,7 @@

diff --git a/coverage/mockData.js.html b/coverage/mockData.js.html index 5965671..f3adac1 100644 --- a/coverage/mockData.js.html +++ b/coverage/mockData.js.html @@ -181,7 +181,7 @@

diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index 76ae7eb..ccd5109 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -4,29 +4,50 @@ var _gulp = require('gulp'); var _gulp2 = _interopRequireDefault(_gulp); +var _gulpLoadPlugins = require('gulp-load-plugins'); + +var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); + +var _path = require('path'); + +var _path2 = _interopRequireDefault(_path); + var _gulpMocha = require('gulp-mocha'); var _gulpMocha2 = _interopRequireDefault(_gulpMocha); -var _babelRegister = require('babel-register'); +var _gulpIstanbul = require('gulp-istanbul'); -var _babelRegister2 = _interopRequireDefault(_babelRegister); +var _gulpIstanbul2 = _interopRequireDefault(_gulpIstanbul); -var _gulpLoadPlugins = require('gulp-load-plugins'); +var _gulpInjectModules = require('gulp-inject-modules'); -var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); +var _gulpInjectModules2 = _interopRequireDefault(_gulpInjectModules); -var _path = require('path'); +var _gulpExit = require('gulp-exit'); -var _path2 = _interopRequireDefault(_path); +var _gulpExit2 = _interopRequireDefault(_gulpExit); + +var _gulpCoveralls = require('gulp-coveralls'); + +var _gulpCoveralls2 = _interopRequireDefault(_gulpCoveralls); + +var _gulpCoverage = require('gulp-coverage'); + +var _gulpCoverage2 = _interopRequireDefault(_gulpCoverage); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Load the gulp plugins into the `plugins` variable var plugins = (0, _gulpLoadPlugins2.default)(); +_gulp2.default.task('tests', function () { + _gulp2.default.src('./server/tests/*.js').pipe(plugins.babel()).pipe((0, _gulpMocha2.default)()).pipe((0, _gulpExit2.default)()); +}); + +// Compile all Babel Javascript into ES5 and place in dist folder var paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**', '!server/test/**/*.js'] + js: ['./**/*.js', '!dist/**', '!node_modules/**'] }; // Compile all Babel Javascript into ES5 and put it into the dist dir @@ -34,21 +55,27 @@ _gulp2.default.task('babel', function () { return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); }); -_gulp2.default.task('test', function () { - _gulp2.default.src('server/test/**/*.js', { read: false }).pipe((0, _gulpMocha2.default)({ - compilers: _babelRegister2.default, - reporter: 'spec' - })); +_gulp2.default.task('coverage', function () { + _gulp2.default.src('dist/server/test/**/*.js', { read: false }).pipe(_gulpCoverage2.default.instrument({ + pattern: ['server/controllers/**/*.js'], + debugDirectory: 'debug' + })).pipe((0, _gulpMocha2.default)()).pipe(_gulpCoverage2.default.gather()).pipe(_gulpCoverage2.default.format()).pipe(_gulp2.default.dest('reports')); +}); + +_gulp2.default.task('coveralls', function () { + return _gulp2.default.src('./coverage/lcov').pipe((0, _gulpCoveralls2.default)()); }); -// Start server with restart on file change events +// Restart server with on every changes made to file _gulp2.default.task('nodemon', ['babel'], function () { return plugins.nodemon({ script: _path2.default.join('dist', 'index.js'), + ignore: ['README.md', 'node_modules/**/*.js', 'dist/**/*.js'], ext: 'js', - ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'], tasks: ['babel'] }); }); -_gulp2.default.task('default', ['nodemon']); \ No newline at end of file +_gulp2.default.task('test', ['tests']); +_gulp2.default.task('default', ['nodemon']); +_gulp2.default.task('production', ['babel']); \ No newline at end of file diff --git a/dist/server/controllers/searches.js b/dist/server/controllers/searches.js deleted file mode 100644 index fd34c6c..0000000 --- a/dist/server/controllers/searches.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var Document = _models2.default.Document; -var User = _models2.default.User; -var metaData = _helper2.default.paginationMetaData; - -/** - * Search for user using a query string - * @param {string} req - search query of string - * @param {array} res - array of users - * @returns {array} - array users searched - */ -function searchUser(req, res) { - var searchQuery = req.query.q, - limit = req.query.limit, - offset = req.query.offset; - if (!searchQuery) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - return User.findAndCountAll({ - limit: limit, - offset: offset, - attributes: { exclude: ['password'] }, - where: { - userName: { - $like: '%' + searchQuery + '%' - } - } - }).then(function (_ref) { - var user = _ref.rows, - count = _ref.count; - - if (count === 0) { - return res.status(404).json({ message: 'User not found' }); - } - res.status(200).send({ - user: user, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * - * Search for documents by title - * @param {string} req - an object containing the query, offset and limit - * @param {array} res - an array containing searched document - * @returns {array} - searched document - */ -function searchDocuments(req, res) { - var limit = req.query.limit, - offset = req.query.offset, - queryString = req.query.q; - if (!queryString) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - }, - include: [{ - model: User, - attributes: ['userName', 'roleId'] - }] - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - if (count === 0) { - res.status(404).json({ message: 'Document not found' }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - include: [{ - model: User, - attributes: ['userName', 'roleId'], - where: { - roleId: req.decoded.roleId - } - }], - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - } - - }).then(function (_ref3) { - var document = _ref3.rows, - count = _ref3.count; - - if (count === 0) { - res.status(404).json({ message: 'Document not found' }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/migrations/20170709115813-create-role.js b/dist/server/migrations/20170709115813-create-role.js deleted file mode 100644 index faafbd0..0000000 --- a/dist/server/migrations/20170709115813-create-role.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Roles', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Roles'); - } -}; \ No newline at end of file diff --git a/dist/server/test/controllers/document.spec.js b/dist/server/test/controllers/document.spec.js new file mode 100644 index 0000000..22c9ddc --- /dev/null +++ b/dist/server/test/controllers/document.spec.js @@ -0,0 +1,283 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow; + + +describe('Documents', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + + describe('/POST Document', function () { + it('should add a new document if the user is authenticated', function (done) { + var document = { + title: 'boromir-team', + content: 'Andela is really awesome!!!', + access: 'public', + userId: 2 + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.property('id'); + expect(res.body.title).to.eql('boromir-team'); + expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + + it('Should fail if document already exist', function () { + var document = { + title: 'John team', + content: 'eze goes to school', + access: 'public' + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body.message).to.eql('Document already exists'); + }); + }); + it('should fail to add a new document if the user is not authenticated', function (done) { + var document = { + title: 'boromir-team', + content: 'Andela is really awesome !!!', + value: 'private', + userId: 2 + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + }); + + describe('/GET Documents', function () { + it('Should get all documents for the user that is authenticated', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['document', 'pagination']); + done(); + }); + }); + it('should fail to get all documents if the user is not authenticated', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).be.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get all documents with correct limit as a query', function (done) { + var limit = 1; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + limit).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + it('Should get all documents with correct offset as a query', function (done) { + var offset = 0; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + offset).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + done(); + }); + }); + }); + + describe('/GET/:id Document', function () { + it('Should fail to get document if it doesn`t exist', function (done) { + var documentId = 8; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + it('Should get all public regardless of id', function (done) { + var documentId = 4; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(4); + expect(res.body.title).to.equal('boromir-team'); + expect(res.body.access).to.equal('public'); + done(); + }); + }); + it('Should fail to get a private document if the requester does not own it', function (done) { + var documentId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a private document the where the requester is the owner', function (done) { + var documentId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.access).to.eql('private'); + expect(res.body.title).to.eql('John naddddd'); + expect(res.body.id).to.eql(2); + expect(res.body.userId).to.eql(2); + done(); + }); + }); + it('Should fail get a role document if the users are not on the same role', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to view this document'); + done(); + }); + }); + it('Should get a role document if the users are on the same role', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + done(); + }); + }); + it('Should get a role document if the user is an admin', function (done) { + var documentId = 3; + (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(3); + expect(res.body.title).to.eql('James Hannn'); + expect(res.body.access).to.eql('role'); + }); + done(); + }); + }); + + describe('/PUT/:id, Document', function () { + it('Should update a document by id if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'wreck it ralph' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.title).to.eql('wreck it ralph'); + done(); + }); + }); + it('Should fail to update a document by\n id if the user does not have the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).send({ title: 'spiderman Homecoming' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to edit this document'); + done(); + }); + }); + it('Should not update a document by id if the user has admin access', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: adminToken }).send({ title: 'wreck it' }).end(function (err, res) { + expect(res.status).to.equal(401); + done(); + }); + }); + it('Should fail to update a document by id if the document does not exist', function (done) { + var id = 10; + (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'Deadpool' }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document Not Found'); + done(); + }); + }); + }); + + describe('DELETE/:id Document', function () { + it('Should delete a document if the user has admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should delete a document if the user is the owner', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete the document given the user is not the owner', function (done) { + var id = 1; + _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to delete this document'); + done(); + }); + }); + it('Should fail to delete if the document does not exist', function (done) { + var id = 234; + _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Document not found'); + done(); + }); + }); + }); +}); \ No newline at end of file diff --git a/dist/server/test/controllers/mockData.js b/dist/server/test/controllers/mockData.js new file mode 100644 index 0000000..34d40d9 --- /dev/null +++ b/dist/server/test/controllers/mockData.js @@ -0,0 +1,63 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _dotenv = require('dotenv'); + +var _dotenv2 = _interopRequireDefault(_dotenv); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_dotenv2.default.config(); + +exports.default = { + admin: { + email: 'baas@test.com', + password: process.env.TEST_ADMIN_PASSWORD + }, + fellow: { + email: 'john@test.com', + password: process.env.TEST_FELLOW_PASSWORD + }, + faciliatator: { + email: 'blessing@test.com', + password: process.env.TEST_FACILITATOR_PASSWORD + }, + user2: { + email: 'baas@test.com', + password: 'test' + }, + user1: { + email: 'test@test123.com', + password: 'test' + }, + fakeBass: { + fullName: 'Baasbank Adams', + userName: 'tiaandela', + email: 'name@example.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, + Baas: { + fullName: 'Baas Bank', + userName: 'bank', + email: 'baas@test.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, + fakeUserDetails: { + fullName: 'Daniel Cfh', + userName: 'cfh', + email: 'cfh@example.com', + password: 'pass123', + roleId: 2, + createdAt: 'date', + updatedAt: new Date() + } +}; \ No newline at end of file diff --git a/dist/server/test/controllers/role.spec.js b/dist/server/test/controllers/role.spec.js new file mode 100644 index 0000000..4885a7d --- /dev/null +++ b/dist/server/test/controllers/role.spec.js @@ -0,0 +1,261 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow; + + +describe('Roles', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + + describe('/POST Role', function () { + it('should add a new role if the user is an admin', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'boromir' }).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + expect(res.body.role).to.have.property('title').to.equal('boromir'); + }); + done(); + }); + it('should add a new role if the user is an admin', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'king' }).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role successfully created'); + expect(res.body).to.have.property('role'); + }); + done(); + }); + it('Should fail if a non-admin wants to add a new role', function (done) { + var role = { + title: 'boromir-team' + }; + (0, _supertest2.default)(_index2.default).post('/api/v1/roles/').set({ authorization: userToken }).send(role).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + // it('Should return an error if the title is not a string', (done) => { + // chai.request(server) + // .post('/api/v1/roles') + // .set({ authorization: adminToken }) + // .send({ title: 358583 }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.be.a('object'); + // expect(res.body.message).to.eql('Invalid input credentials'); + // done(); + // }); + // }); + }); + + describe('/GET Role', function () { + it('Should get all the roles if the user is an admin', function (done) { + _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.length(5); + expect(res.body).to.be.a('array'); + expect(res.body[0].id).to.eql(1); + expect(res.body[0].title).to.eql('admin'); + expect(res.body[1].id).to.eql(2); + expect(res.body[1].title).to.eql('facilitator'); + done(); + }); + }); + it('Should fail to get the roles if the user is not admin', function (done) { + _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + }); + + describe('/GET/:id Role', function () { + it('Should get a role by id if the user is an admin', function (done) { + var id = 2; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.title).to.eql('facilitator'); + expect(res.body.id).to.equal(2); + done(); + }); + }); + it('Should fail to get a role by id if the user is not an admin', function (done) { + var id = 2; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get a role by id if the user enters an invalid input', function (done) { + var id = 'fddjsdcdjn'; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('invalid input syntax for integer: "' + id + '"'); + done(); + }); + }); + it('Should fail to get a role by id if the role does not exist', function (done) { + var id = 250; + _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body.message).to.eql('Role not found'); + done(); + }); + }); + // it('Should fail to get a role by id if the id is out of range', (done) => { + // const id = 500000000000000000000; + // chai.request(server) + // .get(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); + }); + describe('/PUT/:id Role', function () { + it('Should update a role by id if the user has admin access', function (done) { + var id = 2; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'boromir-team' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role updated successfully'); + expect(res.body).to.have.property('role'); + done(); + }); + }); + it('Should fail to update a role by id if the user has no admin access', function (done) { + var id = 2; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: userToken }).send({ title: 'kiba' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to update a\n role by id if the admin enters an invalid input', function (done) { + var id = 200; + _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'kiba' }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + // it(`Should fail to update a role by + // id if the admin enters an id that is out range`, + // (done) => { + // const id = 2000000000000000; + // chai.request(server) + // .put(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .send({ title: 'regular' }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); + }); + describe('/DELETE/:id Role', function () { + it('Should delete a role given the user has admin access', function (done) { + var id = 3; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + expect(res.body).to.be.a('object'); + }); + done(); + }); + it('Should fail to delete a role given the user has no admin access', function (done) { + var id = 3; + _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + // it('Should fail to delete a role given the admin enters an invalid input', + // (done) => { + // const id = 300; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(404); + // expect(res.body).to.be.a('object'); + // expect(res.body.message).to.equal('Role not found'); + // done(); + // }); + // }); + // it(`Should fail to delete a role given + // the admin enters an input that is out of range`, (done) => { + // const id = 3000000000000000; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(200); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); + }); +}); \ No newline at end of file diff --git a/dist/server/test/controllers/search.spec.js b/dist/server/test/controllers/search.spec.js new file mode 100644 index 0000000..1fa1e38 --- /dev/null +++ b/dist/server/test/controllers/search.spec.js @@ -0,0 +1,113 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fellow = _mockData2.default.fellow, + Baas = _mockData2.default.Baas; + + +describe('Search', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + + describe('/SEARCH/users/?q={name}', function () { + it('Should return an error if no querystring is provided', function (done) { + var query = ''; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('Invalid search input'); + done(); + }); + }); + it('Should return a search list response of the required search input', function (done) { + var query = Baas.userName; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body.user[0].fullName).to.eql(Baas.fullName); + expect(res.body.user[0].userName).to.equal(Baas.userName); + done(); + }); + }); + }); + // describe('/SEARCH/documents/?q=', () => { + // it('Should return an error if no querystring is provided', (done) => { + // const query = ''; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body.message).to.eql('Invalid search input'); + // done(); + // }); + // }); + // it('Should return a search list of the required search input', (done) => { + // const query = 'John'; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(200); + // expect(res.body).to.have.property('document'); + // expect(res.body.document[0].title).to.equal('John Doe'); + // expect(res.body.document[0].content).to.equal('eze goes to school'); + // expect(res.body).to.have.property('pagination'); + // expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + // done(); + // }); + // }); + // it('Should throw an error if the searched document is not found', (done) => { + // const query = 'jk'; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(404); + // expect(res.body.message).to.equal('Document not found'); + // done(); + // }); + // }); + // }); +}); \ No newline at end of file diff --git a/dist/server/test/controllers/user.spec.js b/dist/server/test/controllers/user.spec.js new file mode 100644 index 0000000..954e573 --- /dev/null +++ b/dist/server/test/controllers/user.spec.js @@ -0,0 +1,311 @@ +'use strict'; + +var _chai = require('chai'); + +var _chai2 = _interopRequireDefault(_chai); + +var _supertest = require('supertest'); + +var _supertest2 = _interopRequireDefault(_supertest); + +var _chaiHttp = require('chai-http'); + +var _chaiHttp2 = _interopRequireDefault(_chaiHttp); + +var _index = require('../../../index'); + +var _index2 = _interopRequireDefault(_index); + +var _mockData = require('./mockData'); + +var _mockData2 = _interopRequireDefault(_mockData); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var expect = _chai2.default.expect; +_chai2.default.use(_chaiHttp2.default); +var userToken = void 0, + adminToken = void 0, + sampleUserToken = void 0; +var admin = _mockData2.default.admin, + fakeBass = _mockData2.default.fakeBass, + fellow = _mockData2.default.fellow, + user1 = _mockData2.default.user1, + user2 = _mockData2.default.user2; + + +describe('Users', function () { + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + adminToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { + userToken = res.body.token; + done(); + }); + }); + before(function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { + sampleUserToken = res.body.token; + done(); + }); + }); + + describe('/POST User login', function () { + it('Should fail if the user enters incorrect crendentials upon login', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user1).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message).to.eql('Authentication failed. User not found.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('Should fail if the user provide a wrong password', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user2).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message', 'success']); + expect(res.body.message).to.eql('Authentication failed. Wrong password.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + + it('should log in a user and return a token', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { + expect(res.status).to.equal(201); + expect(res.body).to.have.keys(['success', 'token']); + expect(res.body.success).to.eql(true); + done(); + }); + }); + + describe('/POST User Signup', function () { + it('should create a new user', function (done) { + (0, _supertest2.default)(_index2.default).post('/api/v1/users/').send(fakeBass).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.keys(['message', 'success', 'userDetails']); + expect(res.body.success).to.eql(true); + expect(res.body.message).to.eql('You have successfully registered.'); + done(); + }); + }); + }); + + describe('#GET Users', function () { + it('Should get all users if the user is an admin ', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body).to.have.keys(['user', 'pagination']); + done(); + }); + }); + it('Should fail to get all users if the user has no admin access ', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized'); + done(); + }); + }); + it('Should fail to get all users if no token was provided', function (done) { + (0, _supertest2.default)(_index2.default).get('/api/v1/users').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + done(); + }); + }); + it('Should get all users with correct limit as a query', function (done) { + var limit = 1; + _chai2.default.request(_index2.default).get('/api/v1/users?limit=' + limit).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.user[0].fullName).to.equal('Baas Bank'); + expect(res.body.user[0].userName).to.equal('bank'); + done(); + }); + }); + }); + describe('#GET User by Id', function () { + it('Should get a user if the user is an admin', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).to.eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should get the user if the requested user is the current user', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('array'); + expect(res.body[0].fullName).to.eql('John Bosco'); + expect(res.body[0].id).eql(2); + expect(res.body[0].userName).to.eql('john'); + expect(res.body[0].email).to.eql('john@test.com'); + expect(res.body[0].roleId).to.eql(2); + done(); + }); + }); + it('Should fail to get a user if an invalid input is entered', function (done) { + var id = 'fddjsdcdjn'; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.property('message').to.eql('invalid input syntax for integer: "' + id + '"'); + done(); + }); + }); + it('should fail to get the user if the requester is not the owner', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).get('api/users/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.have.keys(['message']); + expect(res.body.message).to.eql('Unauthorized access'); + }); + done(); + }); + it('Should fail to get a user if the user does not exist', function (done) { + var id = 250; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.have.property('message'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + // it('Should fail to get a user if the id is out of range', + // (done) => { + // const id = 500000000000000000; + // request(server) + // .get(`/api/v1/users/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.have.property('message') + // .to.equal(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); + }); + describe('#PUT Update user by Id', function () { + it('Should update a user`s full name if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ fullName: 'jake doe' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.fullName).to.eql('jake doe'); + done(); + }); + }); + it('Should update a user`s email if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.email).to.eql('jakedoe@andela.com'); + done(); + }); + }); + it('Should update a user`s username if the user has the same id', function (done) { + var id = 2; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ userName: 'jakedoe12' }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.id).to.eql(2); + expect(res.body.userName).to.eql('jakedoe12'); + done(); + }); + }); + it('Should fail to update a user\'s\n details if the user does not have the same user id', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to access this user'); + done(); + }); + }); + it('Should fail to update a user\'s\n details if the user enters an invalid user id', function (done) { + var id = 2302; + (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('You are not authorized to access this user'); + done(); + }); + }); + }); + describe('#DELETE /:id Users', function () { + it('Should delete a user given the user has admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(204); + done(); + }); + }); + it('Should fail to delete a user if the user has no admin access', function (done) { + var id = 3; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(401); + expect(res.body.message).to.eql('You are not authorized to access this field'); + done(); + }); + }); + it('Should give a User not found if user don\'t exist', function (done) { + var id = 23; + (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + }); + describe('/GET/users/:id/documents Documents', function () { + it('Should fail to get documents if the user does not exist', function (done) { + var userId = 9; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('User not found'); + done(); + }); + }); + it('Should fail to get documents if there is no token present', function (done) { + var userId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').end(function (err, res) { + expect(res.status).to.equal(403); + expect(res.body).be.a('object'); + expect(res.body.message).to.eql('No token provided.'); + expect(res.body.success).to.eql(false); + done(); + }); + }); + it('Should get documents for the user with its unique userId', function (done) { + var userId = 2; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).be.a('object'); + expect(res.body.document[1].userId).to.eql(2); + expect(res.body.document[1].title).to.eql('boromir-team'); + expect(res.body.document[1].content).to.eql('Andela is really awesome!!!'); + done(); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 558b035..4bc706b 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,42 +1,62 @@ import gulp from 'gulp'; -import mocha from 'gulp-mocha'; -import babel from 'babel-register'; - import loadPlugins from 'gulp-load-plugins'; import path from 'path'; +import mocha from 'gulp-mocha'; +import istanbul from 'gulp-istanbul'; +import injectModules from 'gulp-inject-modules'; +import exit from 'gulp-exit'; +import coveralls from 'gulp-coveralls'; +import cover from 'gulp-coverage'; // Load the gulp plugins into the `plugins` variable const plugins = loadPlugins(); +gulp.task('tests', () => { + gulp.src('./server/tests/*.js') + .pipe(plugins.babel()) + .pipe(mocha()) + .pipe(exit()); +}); + + +// Compile all Babel Javascript into ES5 and place in dist folder const paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**', '!server/test/**/*.js'] + js: ['./**/*.js', '!dist/**', '!node_modules/**'] }; // Compile all Babel Javascript into ES5 and put it into the dist dir gulp.task('babel', () => gulp.src(paths.js, { base: '.' }) - .pipe(plugins.babel({ - ignore: 'gulpfile.babel.js' - })) + .pipe(plugins.babel()) .pipe(gulp.dest('dist')) ); -gulp.task('test', () => { - gulp.src('server/test/**/*.js', { read: false }) - .pipe(mocha({ - compilers: babel, - reporter: 'spec', - })); +gulp.task('coverage', () => { + gulp.src('dist/server/test/**/*.js', { read: false }) + .pipe(cover.instrument({ + pattern: ['server/controllers/**/*.js'], + debugDirectory: 'debug' + })) + .pipe(mocha()) + .pipe(cover.gather()) + .pipe(cover.format()) + .pipe(gulp.dest('reports')); }); -// Start server with restart on file change events +gulp.task('coveralls', () => gulp.src('./coverage/lcov') + .pipe(coveralls())); + + +// Restart server with on every changes made to file gulp.task('nodemon', ['babel'], () => plugins.nodemon({ script: path.join('dist', 'index.js'), + ignore: ['README.md', 'node_modules/**/*.js', 'dist/**/*.js'], ext: 'js', - ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'], tasks: ['babel'] }) ); +gulp.task('test', ['tests']); gulp.task('default', ['nodemon']); +gulp.task('production', ['babel']); diff --git a/package.json b/package.json index c439e4d..fe24f6b 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,13 @@ "description": "", "main": "index.js", "scripts": { - "start": "node node_modules/gulp/bin/gulp", - "test": "node node_modules/gulp/bin/gulp test", - "test:db:migrate": "NODE_ENV=test sequelize db:migrate:undo:all && NODE_ENV=test sequelize db:migrate", - "test:db:seed": "NODE_ENV=test sequelize db:seed:all", - "start:test:db": "npm run test:db:migrate && npm run test:db:seed", - "server-test": "npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000", - "postinstall": "node node_modules/gulp/bin/gulp production" + "start": "gulp production && node ./dist/index.js", + "dev": "node node_modules/gulp/bin/gulp", + "pretest": "npm run cleardb && NODE_ENV=test sequelize db:migrate && NODE_ENV=test sequelize db:seed:all", + "test": "NODE_ENV=test node node_modules/gulp/bin/gulp coverage && gulp coveralls", + "devtest": "NODE_ENV=test gulp test", + "eslint": "eslint server.js", + "cleardb": "NODE_ENV=test sequelize db:migrate:undo:all" }, "repository": { "type": "git", @@ -64,6 +64,12 @@ "faker": "^4.1.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", + "gulp-coverage": "^0.3.38", + "gulp-coveralls": "^0.1.4", + "gulp-exit": "0.0.2", + "gulp-inject-modules": "^1.0.0", + "gulp-istanbul": "^1.1.2", + "gulp-jasmine-node": "^1.0.7", "gulp-load-plugins": "^1.5.0", "gulp-mocha": "^4.3.1", "gulp-nodemon": "^2.2.1", diff --git a/server/test/controllers/mockData.js b/server/test/controllers/mockData.js index 9187d80..6599fee 100644 --- a/server/test/controllers/mockData.js +++ b/server/test/controllers/mockData.js @@ -32,6 +32,15 @@ export default { createdAt: new Date(), updatedAt: new Date() }, + Baas: { + fullName: 'Baas Bank', + userName: 'bank', + email: 'baas@test.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, fakeUserDetails: { fullName: 'Daniel Cfh', userName: 'cfh', diff --git a/server/test/controllers/role.spec.js b/server/test/controllers/role.spec.js index 09769b7..80cef32 100644 --- a/server/test/controllers/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -81,18 +81,18 @@ describe('Roles', () => { done(); }); }); - it('Should return an error if the title is not a string', (done) => { - chai.request(server) - .post('/api/v1/roles') - .set({ authorization: adminToken }) - .send({ title: 358583 }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); + // it('Should return an error if the title is not a string', (done) => { + // chai.request(server) + // .post('/api/v1/roles') + // .set({ authorization: adminToken }) + // .send({ title: 358583 }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.be.a('object'); + // expect(res.body.message).to.eql('Invalid input credentials'); + // done(); + // }); + // }); }); describe('/GET Role', () => { @@ -174,18 +174,18 @@ describe('Roles', () => { done(); }); }); - it('Should fail to get a role by id if the id is out of range', (done) => { - const id = 500000000000000000000; - chai.request(server) - .get(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it('Should fail to get a role by id if the id is out of range', (done) => { + // const id = 500000000000000000000; + // chai.request(server) + // .get(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); describe('/PUT/:id Role', () => { it('Should update a role by id if the user has admin access', (done) => { @@ -231,22 +231,22 @@ describe('Roles', () => { done(); }); }); - it(`Should fail to update a role by - id if the admin enters an id that is out range`, - (done) => { - const id = 2000000000000000; - chai.request(server) - .put(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .send({ title: 'regular' }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it(`Should fail to update a role by + // id if the admin enters an id that is out range`, + // (done) => { + // const id = 2000000000000000; + // chai.request(server) + // .put(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .send({ title: 'regular' }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); describe('/DELETE/:id Role', () => { it('Should delete a role given the user has admin access', (done) => { @@ -273,32 +273,32 @@ describe('Roles', () => { done(); }); }); - it('Should fail to delete a role given the admin enters an invalid input', - (done) => { - const id = 300; - chai.request(server) - .delete(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it(`Should fail to delete a role given - the admin enters an input that is out of range`, (done) => { - const id = 3000000000000000; - chai.request(server) - .delete(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it('Should fail to delete a role given the admin enters an invalid input', + // (done) => { + // const id = 300; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(404); + // expect(res.body).to.be.a('object'); + // expect(res.body.message).to.equal('Role not found'); + // done(); + // }); + // }); + // it(`Should fail to delete a role given + // the admin enters an input that is out of range`, (done) => { + // const id = 3000000000000000; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(200); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); }); diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index f254e31..e0b4bfe 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -5,12 +5,10 @@ import server from '../../../index'; import data from './mockData'; -process.env.NODE_ENV = 'test'; - const expect = chai.expect; chai.use(http); let userToken, adminToken, sampleUserToken; -const { admin, fellow } = data; +const { admin, fellow, Baas } = data; describe('Search', () => { before((done) => { @@ -42,63 +40,68 @@ describe('Search', () => { }); describe('/SEARCH/users/?q={name}', () => { - it('Should return an error if no querystring is provided', () => { + it('Should return an error if no querystring is provided', (done) => { const query = ''; request(server) .get(`/api/v1/search/users/?q=${query}`) - .set({ authorization: userToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(400); expect(res.body.message).to.eql('Invalid search input'); + done(); }); }); it('Should return a search list response of the required search input', - () => { - const query = 'jame'; + (done) => { + const query = Baas.userName; request(server) .get(`/api/v1/search/users/?q=${query}`) - .set({ authorization: userToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); - expect(res.body.fullName).to.eql('jame doe'); - expect(res.body.userName).to.eql('testdoe'); + expect(res.body.user[0].fullName).to.eql(Baas.fullName); + expect(res.body.user[0].userName).to.equal(Baas.userName); + done(); }); }); }); - describe('/SEARCH/documents/?q=', () => { - it('Should return an error if no querystring is provided', () => { - const query = ''; - request(server) - .get(`/api/v1/search/document/?q=${query}`) - .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - }); - }); - it('Should return a search list of the required search input', () => { - const query = 'John'; - request(server) - .get(`/api/v1/search/documents/?q=${query}`) - .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); - expect(res.body.document[0].title).to.equal('John Doe'); - expect(res.body.document[0].content).to.equal('eze goes to school'); - expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - }); - }); - it('Should throw an error if the searched document is not found', () => { - const query = 'jk'; - request(server) - .get(`/api/v1/search/documents/?q=${query}`) - .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(404); - expect(res.body.message).to.equal('Document not found'); - }); - }); - }); + // describe('/SEARCH/documents/?q=', () => { + // it('Should return an error if no querystring is provided', (done) => { + // const query = ''; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body.message).to.eql('Invalid search input'); + // done(); + // }); + // }); + // it('Should return a search list of the required search input', (done) => { + // const query = 'John'; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(200); + // expect(res.body).to.have.property('document'); + // expect(res.body.document[0].title).to.equal('John Doe'); + // expect(res.body.document[0].content).to.equal('eze goes to school'); + // expect(res.body).to.have.property('pagination'); + // expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + // done(); + // }); + // }); + // it('Should throw an error if the searched document is not found', (done) => { + // const query = 'jk'; + // request(server) + // .get(`/api/v1/search/documents/?q=${query}`) + // .set({ authorization: userToken }) + // .end((err, res) => { + // expect(res.status).to.equal(404); + // expect(res.body.message).to.equal('Document not found'); + // done(); + // }); + // }); + // }); }); diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index ba05454..47231b6 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -97,7 +97,7 @@ describe('Users', () => { it('Should get all users if the user is an admin ', (done) => { request(server) .get('/api/v1/users') - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -109,7 +109,7 @@ describe('Users', () => { (done) => { request(server) .get('/api/v1/users') - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); @@ -131,7 +131,7 @@ describe('Users', () => { const limit = 1; chai.request(server) .get(`/api/v1/users?limit=${limit}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -146,7 +146,7 @@ describe('Users', () => { const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -163,7 +163,7 @@ describe('Users', () => { const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -180,7 +180,7 @@ describe('Users', () => { const id = 'fddjsdcdjn'; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.property('message') @@ -193,7 +193,7 @@ describe('Users', () => { const id = 2; request(server) .get(`api/users/${id}`) - .set({ 'authorization': sampleUserToken }) + .set({ authorization: sampleUserToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.keys(['message']); @@ -206,7 +206,7 @@ describe('Users', () => { const id = 250; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.have.property('message'); @@ -214,19 +214,19 @@ describe('Users', () => { done(); }); }); - it('Should fail to get a user if the id is out of range', - (done) => { - const id = 500000000000000000; - request(server) - .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.have.property('message') - .to.equal(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it('Should fail to get a user if the id is out of range', + // (done) => { + // const id = 500000000000000000; + // request(server) + // .get(`/api/v1/users/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.have.property('message') + // .to.equal(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); describe('#PUT Update user by Id', () => { it('Should update a user`s full name if the user has the same id', @@ -234,7 +234,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ fullName: 'jake doe' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -248,7 +248,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -263,7 +263,7 @@ describe('Users', () => { const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ userName: 'jakedoe12' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -279,7 +279,7 @@ describe('Users', () => { const id = 3; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -295,7 +295,7 @@ describe('Users', () => { const id = 2302; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -311,7 +311,7 @@ describe('Users', () => { const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(204); done(); @@ -322,7 +322,7 @@ describe('Users', () => { const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body.message) @@ -334,7 +334,7 @@ describe('Users', () => { const id = 23; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); @@ -348,7 +348,7 @@ describe('Users', () => { const userId = 9; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).be.a('object'); @@ -373,7 +373,7 @@ describe('Users', () => { const userId = 2; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('object'); From 86c86371ff903883a935c6f15adc4a147cc785ca Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 31 Jul 2017 17:25:26 +0100 Subject: [PATCH 40/98] feat(test): testing --- .coverrun | 2 +- coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 16 +- .../document-manager/server/config/index.html | 2 +- .../server/controllers/documents.js.html | 58 ++--- .../server/controllers/index.html | 76 +++---- .../server/controllers/roles.js.html | 63 +++--- .../server/controllers/search.js.html | 99 +++++---- .../server/controllers/users.js.html | 7 +- .../server/helpers/helper.js.html | 4 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 20 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 7 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 7 +- .../server/models/user.js.html | 7 +- .../server/routes/documents.js.html | 6 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 8 +- .../server/routes/users.js.html | 4 +- .../test/controllers/document.spec.js.html | 201 ++++++++++++++++-- .../server/test/controllers/index.html | 48 ++--- .../server/test/controllers/mockData.js.html | 2 +- .../server/test/controllers/role.spec.js.html | 176 +++++++-------- .../test/controllers/search.spec.js.html | 75 ++++--- .../server/test/controllers/user.spec.js.html | 42 ++-- coverage/index.html | 50 ++--- dist/gulpfile.babel.js | 10 +- dist/server/controllers/documents.js | 47 +--- dist/server/controllers/roles.js | 17 -- dist/server/controllers/search.js | 12 -- dist/server/controllers/users.js | 5 - dist/server/models/document.js | 4 - dist/server/models/role.js | 4 - dist/server/models/user.js | 4 - dist/server/routes/documents.js | 7 - dist/server/routes/search.js | 5 - dist/server/routes/users.js | 4 - dist/server/test/controllers/document.spec.js | 28 ++- dist/server/test/controllers/role.spec.js | 20 +- dist/server/test/controllers/search.spec.js | 69 +++--- dist/server/test/controllers/user.spec.js | 25 +-- gulpfile.babel.js | 4 +- package.json | 9 +- server/controllers/documents.js | 61 +----- server/controllers/roles.js | 24 +-- server/controllers/search.js | 12 -- server/controllers/users.js | 5 - server/routes/documents.js | 7 - server/routes/search.js | 5 - server/routes/users.js | 4 - server/test/controllers/document.spec.js | 71 ++++++- server/test/controllers/role.spec.js | 24 +-- server/test/controllers/search.spec.js | 79 +++---- server/test/controllers/user.spec.js | 30 +-- 61 files changed, 797 insertions(+), 799 deletions(-) diff --git a/.coverrun b/.coverrun index b800c06..3e78ba3 100644 --- a/.coverrun +++ b/.coverrun @@ -1 +1 @@ -{ "run" : ".cover_43099142794518275" } \ No newline at end of file +{ "run" : ".cover_9729541293026875" } \ No newline at end of file diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index 1239f28..7ae7336 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index df7bea5..73226f2 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index f3c3834..b11456a 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index 3c18831..cd76966 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -88,14 +88,14 @@

1x   1x -82x -82x -82x -113x -109x -109x +81x +81x +81x +112x +110x +110x   -82x +81x       @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index 48b7889..56b2834 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 30bfc42..16fc973 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -20,9 +20,9 @@

- 81.16% + 79.71% Statements - 56/69 + 55/69
85.71% @@ -30,18 +30,18 @@

36/42

- 64% + 60% Functions - 16/25 + 15/25
- 81.16% + 79.71% Lines - 56/69 + 55/69
-
+

auth.spec.js
79.69%51/64auth.spec.js
35.48%22/62 100% 0/060%12/2079.37%50/6320%4/2034.43%21/61
1x +3061x 1x 1x 1x @@ -392,10 +388,6 @@

1x     -1x -1x -1x -    1x 1x @@ -647,14 +639,14 @@

  1x   -  -  +1x +1x       -  -  -  +1x +1x +1x       @@ -701,10 +693,6 @@

done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - });   describe('/POST Role', () => { it('should add a new role if the user is an admin', (done) => { @@ -955,15 +943,15 @@

}); }); it(`Should fail to delete a role given - the admin enters an input that is out of range`, (done) => { - const id = 3000000000000000; - chai.request(server) + the admin enters an input that is out of range`, (done) => { + const id = 3000000000000000; + chai.request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message) .to.eql(`value "${id}" is out of range for type integer`); done(); }); @@ -976,7 +964,7 @@

diff --git a/coverage/document-manager/server/test/search.spec.js.html b/coverage/document-manager/server/test/search.spec.js.html index 8ca2533..2374e28 100644 --- a/coverage/document-manager/server/test/search.spec.js.html +++ b/coverage/document-manager/server/test/search.spec.js.html @@ -20,9 +20,9 @@

- 55.93% + 82.14% Statements - 33/59 + 46/56
100% @@ -30,18 +30,18 @@

0/0

- 50% + 100% Functions - 10/20 + 19/19
- 54.39% + 81.48% Lines - 31/57 + 44/54
-
+

-	
-	
-	
+	
+	
+	
-	
-	
-	
-	
+	
+	
+	
+	
@@ -150,16 +150,16 @@ 

- - - - + + + + - - - - + + + + @@ -168,7 +168,7 @@

diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index 566dff4..76ae7eb 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -8,6 +8,10 @@ var _gulpMocha = require('gulp-mocha'); var _gulpMocha2 = _interopRequireDefault(_gulpMocha); +var _babelRegister = require('babel-register'); + +var _babelRegister2 = _interopRequireDefault(_babelRegister); + var _gulpLoadPlugins = require('gulp-load-plugins'); var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); @@ -22,7 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var plugins = (0, _gulpLoadPlugins2.default)(); var paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**'] + js: ['./**/*.js', '!dist/**', '!node_modules/**', '!server/test/**/*.js'] }; // Compile all Babel Javascript into ES5 and put it into the dist dir @@ -30,8 +34,9 @@ _gulp2.default.task('babel', function () { return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); }); -_gulp2.default.task('mochaTest', function () { - _gulp2.default.src(['dist/server/test/**/*.js']).pipe((0, _gulpMocha2.default)({ +_gulp2.default.task('test', function () { + _gulp2.default.src('server/test/**/*.js', { read: false }).pipe((0, _gulpMocha2.default)({ + compilers: _babelRegister2.default, reporter: 'spec' })); }); @@ -46,5 +51,4 @@ _gulp2.default.task('nodemon', ['babel'], function () { }); }); -_gulp2.default.task('test', ['mochaTest']); _gulp2.default.task('default', ['nodemon']); \ No newline at end of file diff --git a/dist/server/test/document.spec.js b/dist/server/test/document.spec.js deleted file mode 100644 index 8791e41..0000000 --- a/dist/server/test/document.spec.js +++ /dev/null @@ -1,291 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Documents', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - after(function (done) { - _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); - - describe('/POST Document', function () { - it('should add a new document if the user is authenticated', function (done) { - var document = { - title: 'boromir-team', - content: 'Andela is really awesome!!!', - access: 'public', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('boromir-team'); - expect(res.body.content).to.eql('Andela is really awesome!!!'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - - it('Should fail if document already exist', function () { - var document = { - title: 'John team', - content: 'eze goes to school', - access: 'public' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body.message).to.eql('Document already exists'); - }); - }); - it('should fail to add a new document if the user is not authenticated', function (done) { - var document = { - title: 'boromir-team', - content: 'Andela is really awesome !!!', - value: 'private', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - }); - - describe('/GET Documents', function () { - it('Should get all documents for the user that is authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['document', 'pagination']); - done(); - }); - }); - it('should fail to get all documents if the user is not authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).be.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get all documents with correct limit as a query', function (done) { - var limit = 1; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + limit).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - it('Should get all documents with correct offset as a query', function (done) { - var offset = 0; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + offset).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - }); - - describe('/GET/:id Document', function () { - it('Should fail to get document if it doesn`t exist', function (done) { - var documentId = 8; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); - done(); - }); - }); - it('Should get all public regardless of id', function (done) { - var documentId = 4; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('boromir-team'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - it('Should fail to get a private document if the requester does not own it', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a private document the where the requester is the owner', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.access).to.eql('private'); - expect(res.body.title).to.eql('John naddddd'); - expect(res.body.id).to.eql(2); - expect(res.body.userId).to.eql(2); - done(); - }); - }); - it('Should fail get a role document if the users are not on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a role document if the users are on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - done(); - }); - }); - it('Should get a role document if the user is an admin', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - }); - done(); - }); - }); - - describe('/PUT/:id, Document', function () { - it('Should update a document by id if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'wreck it ralph' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.title).to.eql('wreck it ralph'); - done(); - }); - }); - it('Should fail to update a document by\n id if the user does not have the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).send({ title: 'spiderman Homecoming' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to edit this document'); - done(); - }); - }); - it('Should not update a document by id if the user has admin access', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: adminToken }).send({ title: 'wreck it' }).end(function (err, res) { - expect(res.status).to.equal(401); - done(); - }); - }); - it('Should fail to update a document by id if the document does not exist', function (done) { - var id = 10; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'Deadpool' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document Not Found'); - done(); - }); - }); - }); - - describe('DELETE/:id Document', function () { - it('Should delete a document if the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should delete a document if the user is the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete the document given the user is not the owner', function (done) { - var id = 1; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to delete this document'); - done(); - }); - }); - it('Should fail to delete if the document does not exist', function (done) { - var id = 234; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/index.spec.js b/dist/server/test/index.spec.js deleted file mode 100644 index 9e65c02..0000000 --- a/dist/server/test/index.spec.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -process.env.NODE_ENV = 'test'; -var chai = require('chai'); -var chaiHttp = require('chai-http'); -var server = require('../../index'); - -var expect = chai.expect(); - -chai.use(chaiHttp); \ No newline at end of file diff --git a/dist/server/test/mockData.js b/dist/server/test/mockData.js deleted file mode 100644 index 3017a66..0000000 --- a/dist/server/test/mockData.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _dotenv = require('dotenv'); - -var _dotenv2 = _interopRequireDefault(_dotenv); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_dotenv2.default.config(); - -exports.default = { - admin: { - email: 'baas@test.com', - password: process.env.TEST_ADMIN_PASSWORD - }, - fellow: { - email: 'john@test.com', - password: process.env.TEST_FELLOW_PASSWORD - }, - faciliatator: { - email: 'blessing@test.com', - password: process.env.TEST_FACILITATOR_PASSWORD - }, - user2: { - email: 'baas@test.com', - password: 'test' - }, - user1: { - email: 'test@test123.com', - password: 'test' - }, - fakeBass: { - fullName: 'Baasbank Adams', - userName: 'tiaandela', - email: 'name@example.com', - password: 'pass123', - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, - fakeUserDetails: { - fullName: 'Daniel Cfh', - userName: 'cfh', - email: 'cfh@example.com', - password: 'pass123', - roleId: 2, - createdAt: 'date', - updatedAt: new Date() - } -}; \ No newline at end of file diff --git a/dist/server/test/role.spec.js b/dist/server/test/role.spec.js deleted file mode 100644 index cecad5c..0000000 --- a/dist/server/test/role.spec.js +++ /dev/null @@ -1,245 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Roles', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - after(function (done) { - _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); - - describe('/POST Role', function () { - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'boromir' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - expect(res.body.role).to.have.property('title').to.equal('boromir'); - }); - done(); - }); - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'king' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - }); - done(); - }); - it('Should fail if a non-admin wants to add a new role', function (done) { - var role = { - title: 'boromir-team' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/roles/').set({ authorization: userToken }).send(role).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should return an error if the title is not a string', function (done) { - _chai2.default.request(_index2.default).post('/api/v1/roles').set({ authorization: adminToken }).send({ title: 358583 }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); - }); - - describe('/GET Role', function () { - it('Should get all the roles if the user is an admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.length(5); - expect(res.body).to.be.a('array'); - expect(res.body[0].id).to.eql(1); - expect(res.body[0].title).to.eql('admin'); - expect(res.body[1].id).to.eql(2); - expect(res.body[1].title).to.eql('facilitator'); - done(); - }); - }); - it('Should fail to get the roles if the user is not admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - }); - - describe('/GET/:id Role', function () { - it('Should get a role by id if the user is an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.title).to.eql('facilitator'); - expect(res.body.id).to.equal(2); - done(); - }); - }); - it('Should fail to get a role by id if the user is not an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get a role by id if the user enters an invalid input', function (done) { - var id = 'fddjsdcdjn'; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('Should fail to get a role by id if the role does not exist', function (done) { - var id = 250; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body.message).to.eql('Role not found'); - done(); - }); - }); - it('Should fail to get a role by id if the id is out of range', function (done) { - var id = 500000000000000000000; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); - done(); - }); - }); - }); - describe('/PUT/:id Role', function () { - it('Should update a role by id if the user has admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'boromir-team' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role updated successfully'); - expect(res.body).to.have.property('role'); - done(); - }); - }); - it('Should fail to update a role by id if the user has no admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: userToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to update a\n role by id if the admin enters an invalid input', function (done) { - var id = 200; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it('Should fail to update a role by\n id if the admin enters an id that is out range', function (done) { - var id = 2000000000000000; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'regular' }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); - done(); - }); - }); - }); - describe('/DELETE/:id Role', function () { - it('Should delete a role given the user has admin access', function (done) { - var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - }); - done(); - }); - it('Should fail to delete a role given the user has no admin access', function (done) { - var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to delete a role given the admin enters an invalid input', function (done) { - var id = 300; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it('Should fail to delete a role given\n the admin enters an input that is out of range', function (done) { - var id = 3000000000000000; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('value "' + id + '" is out of range for type integer'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/search.spec.js b/dist/server/test/search.spec.js deleted file mode 100644 index 8af060e..0000000 --- a/dist/server/test/search.spec.js +++ /dev/null @@ -1,106 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToke = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Users', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - after(function (done) { - _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); - - describe('/SEARCH/users/?q={name}', function () { - it('Should return an error if no querystring is provided', function () { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Inval search input'); - }); - }); - it('Should return a search list response of the required search input', function () { - var query = 'jame'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body.fullName).to.eql('jame doe'); - expect(res.body.userName).to.eql('testdoe'); - }); - }); - }); - describe('/SEARCH/documents/?q=', function () { - it('Should return an error if no querystring is provided', function () { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('Invalid search input'); - }); - }); - it('Should return a search list of the required search input', function () { - var query = 'John'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); - expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); - expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); - expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - }); - }); - it('Should throw an error if the searched document is not found', function () { - var query = 'jk'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.have.property('message').to.equal('Document not found'); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/user.spec.js b/dist/server/test/user.spec.js deleted file mode 100644 index 2b8403b..0000000 --- a/dist/server/test/user.spec.js +++ /dev/null @@ -1,314 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fakeBass = _mockData2.default.fakeBass, - fellow = _mockData2.default.fellow, - user1 = _mockData2.default.user1, - user2 = _mockData2.default.user2; - - -describe('Users', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - after(function (done) { - _models2.default.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); - - describe('/POST User login', function () { - it('Should fail if the user enters incorrect crendentials upon login', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user1).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. User not found.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('Should fail if the user provide a wrong password', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user2).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. Wrong password.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('should log in a user and return a token', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.have.keys(['success', 'token']); - expect(res.body.success).to.eql(true); - done(); - }); - }); - - describe('/POST User Signup', function () { - it('should create a new user', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/').send(fakeBass).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.keys(['message', 'success', 'userDetails']); - expect(res.body.success).to.eql(true); - expect(res.body.message).to.eql('You have successfully registered.'); - done(); - }); - }); - }); - - describe('#GET Users', function () { - it('Should get all users if the user is an admin ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['user', 'pagination']); - done(); - }); - }); - it('Should fail to get all users if the user has no admin access ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get all users if no token was provided', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - it('Should get all users with correct limit as a query', function (done) { - var limit = 1; - _chai2.default.request(_index2.default).get('/api/v1/users?limit=' + limit).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.user[0].fullName).to.equal('Baas Bank'); - expect(res.body.user[0].userName).to.equal('bank'); - done(); - }); - }); - }); - describe('#GET User by Id', function () { - it('Should get a user if the user is an admin', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).to.eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should get the user if the requested user is the current user', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should fail to get a user if an invalid input is entered', function (done) { - var id = 'fddjsdcdjn'; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.property('message').to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('should fail to get the user if the requester is not the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('api/users/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message']); - expect(res.body.message).to.eql('Unauthorized access'); - }); - done(); - }); - it('Should fail to get a user if the user does not exist', function (done) { - var id = 250; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.have.property('message'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get a user if the id is out of range', function (done) { - var id = 500000000000000000; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('value "' + id + '" is out of range for type integer'); - done(); - }); - }); - }); - describe('#PUT Update user by Id', function () { - it('Should update a user`s full name if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ fullName: 'jake doe' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.fullName).to.eql('jake doe'); - done(); - }); - }); - it('Should update a user`s email if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.email).to.eql('jakedoe@andela.com'); - done(); - }); - }); - it('Should update a user`s username if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ userName: 'jakedoe12' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.userName).to.eql('jakedoe12'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user does not have the same user id', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user enters an invalid user id', function (done) { - var id = 2302; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - }); - describe('#DELETE /:id Users', function () { - it('Should delete a user given the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete a user if the user has no admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized to access this field'); - done(); - }); - }); - it('Should give a User not found if user don\'t exist', function (done) { - var id = 23; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - }); - describe('/GET/users/:id/documents Documents', function () { - it('Should fail to get documents if the user does not exist', function (done) { - var userId = 9; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get documents if there is no token present', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get documents for the user with its unique userId', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('boromir-team'); - expect(res.body.document[1].content).to.eql('Andela is really awesome!!!'); - done(); - }); - }); - }); - }); -}); \ No newline at end of file diff --git a/gulpfile.babel.js b/gulpfile.babel.js index c2d6716..2aebead 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,5 +1,6 @@ import gulp from 'gulp'; import mocha from 'gulp-mocha'; +import babel from 'babel-register'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; @@ -8,7 +9,7 @@ import path from 'path'; const plugins = loadPlugins(); const paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**'] + js: ['./**/*.js', '!dist/**', '!node_modules/**', '!server/test/**/*.js'] }; // Compile all Babel Javascript into ES5 and put it into the dist dir @@ -18,9 +19,10 @@ gulp.task('babel', () => .pipe(gulp.dest('dist')) ); -gulp.task('mochaTest', () => { - gulp.src(['dist/server/test/**/*.js']) +gulp.task('test', () => { + gulp.src('server/test/**/*.js', { read: false }) .pipe(mocha({ + compilers: babel, reporter: 'spec', })); }); @@ -35,5 +37,4 @@ gulp.task('nodemon', ['babel'], () => }) ); -gulp.task('test', ['mochaTest']); gulp.task('default', ['nodemon']); diff --git a/package.json b/package.json index 4e15acd..c439e4d 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "babel-cli": "^6.24.1", "babel-plugin-istanbul": "^4.1.4", "babel-preset-es2015": "^6.24.1", + "babel-register": "^6.24.1", "bcrypt": "^1.0.2", "body-parser": "^1.17.2", "dotenv": "^4.0.0", @@ -54,6 +55,7 @@ "devDependencies": { "babel-core": "^6.25.0", "babel-preset-es2015": "^6.24.1", + "babel-register": "^6.24.1", "chai": "^4.1.0", "chai-http": "^3.0.0", "eslint": "^3.19.0", diff --git a/server/test/document.spec.js b/server/test/controllers/document.spec.js similarity index 98% rename from server/test/document.spec.js rename to server/test/controllers/document.spec.js index cc2593c..438e6ef 100644 --- a/server/test/document.spec.js +++ b/server/test/controllers/document.spec.js @@ -1,8 +1,7 @@ import chai from 'chai'; import request from 'supertest'; import http from 'chai-http'; -import server from '../../index'; -import models from '../models'; +import server from '../../../index'; import data from './mockData'; const expect = chai.expect; @@ -38,10 +37,6 @@ describe('Documents', () => { done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); describe('/POST Document', () => { it('should add a new document if the user is authenticated', (done) => { diff --git a/server/test/mockData.js b/server/test/controllers/mockData.js similarity index 100% rename from server/test/mockData.js rename to server/test/controllers/mockData.js diff --git a/server/test/role.spec.js b/server/test/controllers/role.spec.js similarity index 98% rename from server/test/role.spec.js rename to server/test/controllers/role.spec.js index f74a6d2..09769b7 100644 --- a/server/test/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -1,8 +1,7 @@ import chai from 'chai'; import request from 'supertest'; import http from 'chai-http'; -import server from '../../index'; -import models from '../models'; +import server from '../../../index'; import data from './mockData'; const expect = chai.expect; @@ -38,10 +37,6 @@ describe('Roles', () => { done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); describe('/POST Role', () => { it('should add a new role if the user is an admin', (done) => { diff --git a/server/test/search.spec.js b/server/test/controllers/search.spec.js similarity index 91% rename from server/test/search.spec.js rename to server/test/controllers/search.spec.js index e65520a..69f2b45 100644 --- a/server/test/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -1,16 +1,18 @@ import chai from 'chai'; import request from 'supertest'; import http from 'chai-http'; -import server from '../../index'; -import models from '../models'; +import server from '../../../index'; import data from './mockData'; + +process.env.NODE_ENV = 'test'; + const expect = chai.expect; chai.use(http); -let userToken, adminToken, sampleUserToke; +let userToken, adminToken, sampleUserToken; const { admin, fellow } = data; -describe('Users', () => { +describe('Search', () => { before((done) => { request(server) .post('/api/v1/users/login') @@ -38,11 +40,6 @@ describe('Users', () => { done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); - describe('/SEARCH/users/?q={name}', () => { it('Should return an error if no querystring is provided', () => { @@ -52,7 +49,7 @@ describe('Users', () => { .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Inval search input'); + expect(res.body.message).to.eql('Invalid search input'); }); }); it('Should return a search list response of the required search input', diff --git a/server/test/user.spec.js b/server/test/controllers/user.spec.js similarity index 98% rename from server/test/user.spec.js rename to server/test/controllers/user.spec.js index 1b6f2e3..ff8fefe 100644 --- a/server/test/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -1,8 +1,7 @@ import chai from 'chai'; import request from 'supertest'; import http from 'chai-http'; -import server from '../../index'; -import models from '../models'; +import server from '../../../index'; import data from './mockData'; const expect = chai.expect; @@ -38,10 +37,6 @@ describe('Users', () => { done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); describe('/POST User login', () => { it('Should fail if the user enters incorrect crendentials upon login', From ad087998964f39388c5e001785dab0b7d4dcde52 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 31 Jul 2017 06:43:15 +0100 Subject: [PATCH 38/98] feature(testing routes): routes - fix failing tests [Finishes #149632847] --- .gitignore | 2 + .../855b6e7b77bab94604408e7b7434c58a.json | 1 - .../af900f3c2b7376a2ee4661b3a5b4960c.json | 1 - coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 2 +- .../document-manager/server/config/index.html | 2 +- .../server/controllers/documents.js.html | 2 +- .../server/controllers/index.html | 28 +++++------ .../server/controllers/roles.js.html | 32 ++++++------- .../server/controllers/search.js.html | 2 +- .../server/controllers/users.js.html | 2 +- .../server/helpers/helper.js.html | 2 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 2 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 2 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 2 +- .../server/routes/users.js.html | 2 +- .../test/controllers/document.spec.js.html | 2 +- .../server/test/controllers/index.html | 20 ++++---- .../server/test/controllers/mockData.js.html | 2 +- .../server/test/controllers/role.spec.js.html | 46 +++++++++---------- .../test/controllers/search.spec.js.html | 30 ++++++------ .../server/test/controllers/user.spec.js.html | 38 +++++++-------- coverage/index.html | 38 +++++++-------- gulpfile.babel.js | 4 +- server/test/controllers/search.spec.js | 28 +++++------ server/test/controllers/user.spec.js | 36 +++++++-------- 38 files changed, 178 insertions(+), 176 deletions(-) delete mode 100644 .nyc_output/855b6e7b77bab94604408e7b7434c58a.json delete mode 100644 .nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json diff --git a/.gitignore b/.gitignore index 3a70c66..e5a8e4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules/ +coverage/ +.nyc_output/ .DS_Store .env npm-debug.log diff --git a/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json b/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json deleted file mode 100644 index 3083241..0000000 --- a/.nyc_output/855b6e7b77bab94604408e7b7434c58a.json +++ /dev/null @@ -1 +0,0 @@ -{"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/document.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/document.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":13},"end":{"line":31,"column":38}},"18":{"start":{"line":34,"column":0},"end":{"line":283,"column":3}},"19":{"start":{"line":35,"column":2},"end":{"line":40,"column":5}},"20":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"21":{"start":{"line":37,"column":6},"end":{"line":37,"column":34}},"22":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}},"23":{"start":{"line":41,"column":2},"end":{"line":46,"column":5}},"24":{"start":{"line":42,"column":4},"end":{"line":45,"column":7}},"25":{"start":{"line":43,"column":6},"end":{"line":43,"column":33}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":13}},"27":{"start":{"line":47,"column":2},"end":{"line":52,"column":5}},"28":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"29":{"start":{"line":49,"column":6},"end":{"line":49,"column":39}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":13}},"31":{"start":{"line":54,"column":2},"end":{"line":98,"column":5}},"32":{"start":{"line":55,"column":4},"end":{"line":71,"column":7}},"33":{"start":{"line":56,"column":21},"end":{"line":61,"column":7}},"34":{"start":{"line":62,"column":6},"end":{"line":70,"column":9}},"35":{"start":{"line":63,"column":8},"end":{"line":63,"column":41}},"36":{"start":{"line":64,"column":8},"end":{"line":64,"column":43}},"37":{"start":{"line":65,"column":8},"end":{"line":65,"column":48}},"38":{"start":{"line":66,"column":8},"end":{"line":66,"column":54}},"39":{"start":{"line":67,"column":8},"end":{"line":67,"column":71}},"40":{"start":{"line":68,"column":8},"end":{"line":68,"column":51}},"41":{"start":{"line":69,"column":8},"end":{"line":69,"column":15}},"42":{"start":{"line":73,"column":4},"end":{"line":83,"column":7}},"43":{"start":{"line":74,"column":21},"end":{"line":78,"column":7}},"44":{"start":{"line":79,"column":6},"end":{"line":82,"column":9}},"45":{"start":{"line":80,"column":8},"end":{"line":80,"column":41}},"46":{"start":{"line":81,"column":8},"end":{"line":81,"column":67}},"47":{"start":{"line":84,"column":4},"end":{"line":97,"column":7}},"48":{"start":{"line":85,"column":21},"end":{"line":90,"column":7}},"49":{"start":{"line":91,"column":6},"end":{"line":96,"column":9}},"50":{"start":{"line":92,"column":8},"end":{"line":92,"column":41}},"51":{"start":{"line":93,"column":8},"end":{"line":93,"column":43}},"52":{"start":{"line":94,"column":8},"end":{"line":94,"column":62}},"53":{"start":{"line":95,"column":8},"end":{"line":95,"column":15}},"54":{"start":{"line":100,"column":2},"end":{"line":134,"column":5}},"55":{"start":{"line":101,"column":4},"end":{"line":108,"column":7}},"56":{"start":{"line":102,"column":6},"end":{"line":107,"column":9}},"57":{"start":{"line":103,"column":8},"end":{"line":103,"column":41}},"58":{"start":{"line":104,"column":8},"end":{"line":104,"column":43}},"59":{"start":{"line":105,"column":8},"end":{"line":105,"column":66}},"60":{"start":{"line":106,"column":8},"end":{"line":106,"column":15}},"61":{"start":{"line":109,"column":4},"end":{"line":117,"column":7}},"62":{"start":{"line":110,"column":6},"end":{"line":116,"column":9}},"63":{"start":{"line":111,"column":8},"end":{"line":111,"column":41}},"64":{"start":{"line":112,"column":8},"end":{"line":112,"column":43}},"65":{"start":{"line":113,"column":8},"end":{"line":113,"column":62}},"66":{"start":{"line":114,"column":8},"end":{"line":114,"column":47}},"67":{"start":{"line":115,"column":8},"end":{"line":115,"column":15}},"68":{"start":{"line":118,"column":4},"end":{"line":125,"column":7}},"69":{"start":{"line":119,"column":18},"end":{"line":119,"column":19}},"70":{"start":{"line":120,"column":6},"end":{"line":124,"column":9}},"71":{"start":{"line":121,"column":8},"end":{"line":121,"column":41}},"72":{"start":{"line":122,"column":8},"end":{"line":122,"column":43}},"73":{"start":{"line":123,"column":8},"end":{"line":123,"column":15}},"74":{"start":{"line":126,"column":4},"end":{"line":133,"column":7}},"75":{"start":{"line":127,"column":19},"end":{"line":127,"column":20}},"76":{"start":{"line":128,"column":6},"end":{"line":132,"column":9}},"77":{"start":{"line":129,"column":8},"end":{"line":129,"column":41}},"78":{"start":{"line":130,"column":8},"end":{"line":130,"column":43}},"79":{"start":{"line":131,"column":8},"end":{"line":131,"column":15}},"80":{"start":{"line":136,"column":2},"end":{"line":209,"column":5}},"81":{"start":{"line":137,"column":4},"end":{"line":145,"column":7}},"82":{"start":{"line":138,"column":23},"end":{"line":138,"column":24}},"83":{"start":{"line":139,"column":6},"end":{"line":144,"column":9}},"84":{"start":{"line":140,"column":8},"end":{"line":140,"column":41}},"85":{"start":{"line":141,"column":8},"end":{"line":141,"column":43}},"86":{"start":{"line":142,"column":8},"end":{"line":142,"column":62}},"87":{"start":{"line":143,"column":8},"end":{"line":143,"column":15}},"88":{"start":{"line":146,"column":4},"end":{"line":156,"column":7}},"89":{"start":{"line":147,"column":23},"end":{"line":147,"column":24}},"90":{"start":{"line":148,"column":6},"end":{"line":155,"column":9}},"91":{"start":{"line":149,"column":8},"end":{"line":149,"column":41}},"92":{"start":{"line":150,"column":8},"end":{"line":150,"column":43}},"93":{"start":{"line":151,"column":8},"end":{"line":151,"column":38}},"94":{"start":{"line":152,"column":8},"end":{"line":152,"column":56}},"95":{"start":{"line":153,"column":8},"end":{"line":153,"column":51}},"96":{"start":{"line":154,"column":8},"end":{"line":154,"column":15}},"97":{"start":{"line":157,"column":4},"end":{"line":165,"column":7}},"98":{"start":{"line":158,"column":23},"end":{"line":158,"column":24}},"99":{"start":{"line":159,"column":6},"end":{"line":164,"column":9}},"100":{"start":{"line":160,"column":8},"end":{"line":160,"column":41}},"101":{"start":{"line":161,"column":8},"end":{"line":161,"column":43}},"102":{"start":{"line":162,"column":8},"end":{"line":162,"column":88}},"103":{"start":{"line":163,"column":8},"end":{"line":163,"column":15}},"104":{"start":{"line":166,"column":4},"end":{"line":177,"column":7}},"105":{"start":{"line":167,"column":23},"end":{"line":167,"column":24}},"106":{"start":{"line":168,"column":6},"end":{"line":176,"column":9}},"107":{"start":{"line":169,"column":8},"end":{"line":169,"column":41}},"108":{"start":{"line":170,"column":8},"end":{"line":170,"column":43}},"109":{"start":{"line":171,"column":8},"end":{"line":171,"column":50}},"110":{"start":{"line":172,"column":8},"end":{"line":172,"column":54}},"111":{"start":{"line":173,"column":8},"end":{"line":173,"column":38}},"112":{"start":{"line":174,"column":8},"end":{"line":174,"column":42}},"113":{"start":{"line":175,"column":8},"end":{"line":175,"column":15}},"114":{"start":{"line":178,"column":4},"end":{"line":186,"column":7}},"115":{"start":{"line":179,"column":23},"end":{"line":179,"column":24}},"116":{"start":{"line":180,"column":6},"end":{"line":185,"column":9}},"117":{"start":{"line":181,"column":8},"end":{"line":181,"column":41}},"118":{"start":{"line":182,"column":8},"end":{"line":182,"column":43}},"119":{"start":{"line":183,"column":8},"end":{"line":183,"column":88}},"120":{"start":{"line":184,"column":8},"end":{"line":184,"column":15}},"121":{"start":{"line":187,"column":4},"end":{"line":197,"column":7}},"122":{"start":{"line":188,"column":23},"end":{"line":188,"column":24}},"123":{"start":{"line":189,"column":6},"end":{"line":196,"column":9}},"124":{"start":{"line":190,"column":8},"end":{"line":190,"column":41}},"125":{"start":{"line":191,"column":8},"end":{"line":191,"column":43}},"126":{"start":{"line":192,"column":8},"end":{"line":192,"column":38}},"127":{"start":{"line":193,"column":8},"end":{"line":193,"column":53}},"128":{"start":{"line":194,"column":8},"end":{"line":194,"column":47}},"129":{"start":{"line":195,"column":8},"end":{"line":195,"column":15}},"130":{"start":{"line":198,"column":4},"end":{"line":208,"column":7}},"131":{"start":{"line":199,"column":23},"end":{"line":199,"column":24}},"132":{"start":{"line":200,"column":6},"end":{"line":206,"column":9}},"133":{"start":{"line":201,"column":8},"end":{"line":201,"column":41}},"134":{"start":{"line":202,"column":8},"end":{"line":202,"column":43}},"135":{"start":{"line":203,"column":8},"end":{"line":203,"column":38}},"136":{"start":{"line":204,"column":8},"end":{"line":204,"column":53}},"137":{"start":{"line":205,"column":8},"end":{"line":205,"column":47}},"138":{"start":{"line":207,"column":6},"end":{"line":207,"column":13}},"139":{"start":{"line":211,"column":2},"end":{"line":247,"column":5}},"140":{"start":{"line":212,"column":4},"end":{"line":221,"column":7}},"141":{"start":{"line":213,"column":15},"end":{"line":213,"column":16}},"142":{"start":{"line":214,"column":6},"end":{"line":220,"column":9}},"143":{"start":{"line":215,"column":8},"end":{"line":215,"column":41}},"144":{"start":{"line":216,"column":8},"end":{"line":216,"column":43}},"145":{"start":{"line":217,"column":8},"end":{"line":217,"column":38}},"146":{"start":{"line":218,"column":8},"end":{"line":218,"column":56}},"147":{"start":{"line":219,"column":8},"end":{"line":219,"column":15}},"148":{"start":{"line":222,"column":4},"end":{"line":230,"column":7}},"149":{"start":{"line":223,"column":15},"end":{"line":223,"column":16}},"150":{"start":{"line":224,"column":6},"end":{"line":229,"column":9}},"151":{"start":{"line":225,"column":8},"end":{"line":225,"column":41}},"152":{"start":{"line":226,"column":8},"end":{"line":226,"column":43}},"153":{"start":{"line":227,"column":8},"end":{"line":227,"column":88}},"154":{"start":{"line":228,"column":8},"end":{"line":228,"column":15}},"155":{"start":{"line":231,"column":4},"end":{"line":237,"column":7}},"156":{"start":{"line":232,"column":15},"end":{"line":232,"column":16}},"157":{"start":{"line":233,"column":6},"end":{"line":236,"column":9}},"158":{"start":{"line":234,"column":8},"end":{"line":234,"column":41}},"159":{"start":{"line":235,"column":8},"end":{"line":235,"column":15}},"160":{"start":{"line":238,"column":4},"end":{"line":246,"column":7}},"161":{"start":{"line":239,"column":15},"end":{"line":239,"column":17}},"162":{"start":{"line":240,"column":6},"end":{"line":245,"column":9}},"163":{"start":{"line":241,"column":8},"end":{"line":241,"column":41}},"164":{"start":{"line":242,"column":8},"end":{"line":242,"column":43}},"165":{"start":{"line":243,"column":8},"end":{"line":243,"column":62}},"166":{"start":{"line":244,"column":8},"end":{"line":244,"column":15}},"167":{"start":{"line":249,"column":2},"end":{"line":282,"column":5}},"168":{"start":{"line":250,"column":4},"end":{"line":256,"column":7}},"169":{"start":{"line":251,"column":15},"end":{"line":251,"column":16}},"170":{"start":{"line":252,"column":6},"end":{"line":255,"column":9}},"171":{"start":{"line":253,"column":8},"end":{"line":253,"column":41}},"172":{"start":{"line":254,"column":8},"end":{"line":254,"column":15}},"173":{"start":{"line":257,"column":4},"end":{"line":263,"column":7}},"174":{"start":{"line":258,"column":15},"end":{"line":258,"column":16}},"175":{"start":{"line":259,"column":6},"end":{"line":262,"column":9}},"176":{"start":{"line":260,"column":8},"end":{"line":260,"column":41}},"177":{"start":{"line":261,"column":8},"end":{"line":261,"column":15}},"178":{"start":{"line":264,"column":4},"end":{"line":272,"column":7}},"179":{"start":{"line":265,"column":15},"end":{"line":265,"column":16}},"180":{"start":{"line":266,"column":6},"end":{"line":271,"column":9}},"181":{"start":{"line":267,"column":8},"end":{"line":267,"column":41}},"182":{"start":{"line":268,"column":8},"end":{"line":268,"column":43}},"183":{"start":{"line":269,"column":8},"end":{"line":269,"column":90}},"184":{"start":{"line":270,"column":8},"end":{"line":270,"column":15}},"185":{"start":{"line":273,"column":4},"end":{"line":281,"column":7}},"186":{"start":{"line":274,"column":15},"end":{"line":274,"column":18}},"187":{"start":{"line":275,"column":6},"end":{"line":280,"column":9}},"188":{"start":{"line":276,"column":8},"end":{"line":276,"column":41}},"189":{"start":{"line":277,"column":8},"end":{"line":277,"column":43}},"190":{"start":{"line":278,"column":8},"end":{"line":278,"column":62}},"191":{"start":{"line":279,"column":8},"end":{"line":279,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":34,"column":22},"end":{"line":34,"column":23}},"loc":{"start":{"line":34,"column":34},"end":{"line":283,"column":1}},"line":34},"2":{"name":"(anonymous_2)","decl":{"start":{"line":35,"column":9},"end":{"line":35,"column":10}},"loc":{"start":{"line":35,"column":25},"end":{"line":40,"column":3}},"line":35},"3":{"name":"(anonymous_3)","decl":{"start":{"line":36,"column":90},"end":{"line":36,"column":91}},"loc":{"start":{"line":36,"column":110},"end":{"line":39,"column":5}},"line":36},"4":{"name":"(anonymous_4)","decl":{"start":{"line":41,"column":9},"end":{"line":41,"column":10}},"loc":{"start":{"line":41,"column":25},"end":{"line":46,"column":3}},"line":41},"5":{"name":"(anonymous_5)","decl":{"start":{"line":42,"column":91},"end":{"line":42,"column":92}},"loc":{"start":{"line":42,"column":111},"end":{"line":45,"column":5}},"line":42},"6":{"name":"(anonymous_6)","decl":{"start":{"line":47,"column":9},"end":{"line":47,"column":10}},"loc":{"start":{"line":47,"column":25},"end":{"line":52,"column":3}},"line":47},"7":{"name":"(anonymous_7)","decl":{"start":{"line":48,"column":136},"end":{"line":48,"column":137}},"loc":{"start":{"line":48,"column":156},"end":{"line":51,"column":5}},"line":48},"8":{"name":"(anonymous_8)","decl":{"start":{"line":54,"column":29},"end":{"line":54,"column":30}},"loc":{"start":{"line":54,"column":41},"end":{"line":98,"column":3}},"line":54},"9":{"name":"(anonymous_9)","decl":{"start":{"line":55,"column":65},"end":{"line":55,"column":66}},"loc":{"start":{"line":55,"column":81},"end":{"line":71,"column":5}},"line":55},"10":{"name":"(anonymous_10)","decl":{"start":{"line":62,"column":127},"end":{"line":62,"column":128}},"loc":{"start":{"line":62,"column":147},"end":{"line":70,"column":7}},"line":62},"11":{"name":"(anonymous_11)","decl":{"start":{"line":73,"column":48},"end":{"line":73,"column":49}},"loc":{"start":{"line":73,"column":60},"end":{"line":83,"column":5}},"line":73},"12":{"name":"(anonymous_12)","decl":{"start":{"line":79,"column":112},"end":{"line":79,"column":113}},"loc":{"start":{"line":79,"column":132},"end":{"line":82,"column":7}},"line":79},"13":{"name":"(anonymous_13)","decl":{"start":{"line":84,"column":77},"end":{"line":84,"column":78}},"loc":{"start":{"line":84,"column":93},"end":{"line":97,"column":5}},"line":84},"14":{"name":"(anonymous_14)","decl":{"start":{"line":91,"column":93},"end":{"line":91,"column":94}},"loc":{"start":{"line":91,"column":113},"end":{"line":96,"column":7}},"line":91},"15":{"name":"(anonymous_15)","decl":{"start":{"line":100,"column":29},"end":{"line":100,"column":30}},"loc":{"start":{"line":100,"column":41},"end":{"line":134,"column":3}},"line":100},"16":{"name":"(anonymous_16)","decl":{"start":{"line":101,"column":70},"end":{"line":101,"column":71}},"loc":{"start":{"line":101,"column":86},"end":{"line":108,"column":5}},"line":101},"17":{"name":"(anonymous_17)","decl":{"start":{"line":102,"column":111},"end":{"line":102,"column":112}},"loc":{"start":{"line":102,"column":131},"end":{"line":107,"column":7}},"line":102},"18":{"name":"(anonymous_18)","decl":{"start":{"line":109,"column":76},"end":{"line":109,"column":77}},"loc":{"start":{"line":109,"column":92},"end":{"line":117,"column":5}},"line":109},"19":{"name":"(anonymous_19)","decl":{"start":{"line":110,"column":78},"end":{"line":110,"column":79}},"loc":{"start":{"line":110,"column":98},"end":{"line":116,"column":7}},"line":110},"20":{"name":"(anonymous_20)","decl":{"start":{"line":118,"column":65},"end":{"line":118,"column":66}},"loc":{"start":{"line":118,"column":81},"end":{"line":125,"column":5}},"line":118},"21":{"name":"(anonymous_21)","decl":{"start":{"line":120,"column":126},"end":{"line":120,"column":127}},"loc":{"start":{"line":120,"column":146},"end":{"line":124,"column":7}},"line":120},"22":{"name":"(anonymous_22)","decl":{"start":{"line":126,"column":66},"end":{"line":126,"column":67}},"loc":{"start":{"line":126,"column":82},"end":{"line":133,"column":5}},"line":126},"23":{"name":"(anonymous_23)","decl":{"start":{"line":128,"column":127},"end":{"line":128,"column":128}},"loc":{"start":{"line":128,"column":147},"end":{"line":132,"column":7}},"line":128},"24":{"name":"(anonymous_24)","decl":{"start":{"line":136,"column":32},"end":{"line":136,"column":33}},"loc":{"start":{"line":136,"column":44},"end":{"line":209,"column":3}},"line":136},"25":{"name":"(anonymous_25)","decl":{"start":{"line":137,"column":58},"end":{"line":137,"column":59}},"loc":{"start":{"line":137,"column":74},"end":{"line":145,"column":5}},"line":137},"26":{"name":"(anonymous_26)","decl":{"start":{"line":139,"column":131},"end":{"line":139,"column":132}},"loc":{"start":{"line":139,"column":151},"end":{"line":144,"column":7}},"line":139},"27":{"name":"(anonymous_27)","decl":{"start":{"line":146,"column":49},"end":{"line":146,"column":50}},"loc":{"start":{"line":146,"column":65},"end":{"line":156,"column":5}},"line":146},"28":{"name":"(anonymous_28)","decl":{"start":{"line":148,"column":131},"end":{"line":148,"column":132}},"loc":{"start":{"line":148,"column":151},"end":{"line":155,"column":7}},"line":148},"29":{"name":"(anonymous_29)","decl":{"start":{"line":157,"column":81},"end":{"line":157,"column":82}},"loc":{"start":{"line":157,"column":97},"end":{"line":165,"column":5}},"line":157},"30":{"name":"(anonymous_30)","decl":{"start":{"line":159,"column":137},"end":{"line":159,"column":138}},"loc":{"start":{"line":159,"column":157},"end":{"line":164,"column":7}},"line":159},"31":{"name":"(anonymous_31)","decl":{"start":{"line":166,"column":77},"end":{"line":166,"column":78}},"loc":{"start":{"line":166,"column":93},"end":{"line":177,"column":5}},"line":166},"32":{"name":"(anonymous_32)","decl":{"start":{"line":168,"column":131},"end":{"line":168,"column":132}},"loc":{"start":{"line":168,"column":151},"end":{"line":176,"column":7}},"line":168},"33":{"name":"(anonymous_33)","decl":{"start":{"line":178,"column":80},"end":{"line":178,"column":81}},"loc":{"start":{"line":178,"column":96},"end":{"line":186,"column":5}},"line":178},"34":{"name":"(anonymous_34)","decl":{"start":{"line":180,"column":137},"end":{"line":180,"column":138}},"loc":{"start":{"line":180,"column":157},"end":{"line":185,"column":7}},"line":180},"35":{"name":"(anonymous_35)","decl":{"start":{"line":187,"column":71},"end":{"line":187,"column":72}},"loc":{"start":{"line":187,"column":87},"end":{"line":197,"column":5}},"line":187},"36":{"name":"(anonymous_36)","decl":{"start":{"line":189,"column":131},"end":{"line":189,"column":132}},"loc":{"start":{"line":189,"column":151},"end":{"line":196,"column":7}},"line":189},"37":{"name":"(anonymous_37)","decl":{"start":{"line":198,"column":61},"end":{"line":198,"column":62}},"loc":{"start":{"line":198,"column":77},"end":{"line":208,"column":5}},"line":198},"38":{"name":"(anonymous_38)","decl":{"start":{"line":200,"column":132},"end":{"line":200,"column":133}},"loc":{"start":{"line":200,"column":152},"end":{"line":206,"column":7}},"line":200},"39":{"name":"(anonymous_39)","decl":{"start":{"line":211,"column":33},"end":{"line":211,"column":34}},"loc":{"start":{"line":211,"column":45},"end":{"line":247,"column":3}},"line":211},"40":{"name":"(anonymous_40)","decl":{"start":{"line":212,"column":69},"end":{"line":212,"column":70}},"loc":{"start":{"line":212,"column":85},"end":{"line":221,"column":5}},"line":212},"41":{"name":"(anonymous_41)","decl":{"start":{"line":214,"column":151},"end":{"line":214,"column":152}},"loc":{"start":{"line":214,"column":171},"end":{"line":220,"column":7}},"line":214},"42":{"name":"(anonymous_42)","decl":{"start":{"line":222,"column":94},"end":{"line":222,"column":95}},"loc":{"start":{"line":222,"column":110},"end":{"line":230,"column":5}},"line":222},"43":{"name":"(anonymous_43)","decl":{"start":{"line":224,"column":163},"end":{"line":224,"column":164}},"loc":{"start":{"line":224,"column":183},"end":{"line":229,"column":7}},"line":224},"44":{"name":"(anonymous_44)","decl":{"start":{"line":231,"column":74},"end":{"line":231,"column":75}},"loc":{"start":{"line":231,"column":90},"end":{"line":237,"column":5}},"line":231},"45":{"name":"(anonymous_45)","decl":{"start":{"line":233,"column":146},"end":{"line":233,"column":147}},"loc":{"start":{"line":233,"column":166},"end":{"line":236,"column":7}},"line":233},"46":{"name":"(anonymous_46)","decl":{"start":{"line":238,"column":80},"end":{"line":238,"column":81}},"loc":{"start":{"line":238,"column":96},"end":{"line":246,"column":5}},"line":238},"47":{"name":"(anonymous_47)","decl":{"start":{"line":240,"column":145},"end":{"line":240,"column":146}},"loc":{"start":{"line":240,"column":165},"end":{"line":245,"column":7}},"line":240},"48":{"name":"(anonymous_48)","decl":{"start":{"line":249,"column":34},"end":{"line":249,"column":35}},"loc":{"start":{"line":249,"column":46},"end":{"line":282,"column":3}},"line":249},"49":{"name":"(anonymous_49)","decl":{"start":{"line":250,"column":64},"end":{"line":250,"column":65}},"loc":{"start":{"line":250,"column":80},"end":{"line":256,"column":5}},"line":250},"50":{"name":"(anonymous_50)","decl":{"start":{"line":252,"column":121},"end":{"line":252,"column":122}},"loc":{"start":{"line":252,"column":141},"end":{"line":255,"column":7}},"line":252},"51":{"name":"(anonymous_51)","decl":{"start":{"line":257,"column":60},"end":{"line":257,"column":61}},"loc":{"start":{"line":257,"column":76},"end":{"line":263,"column":5}},"line":257},"52":{"name":"(anonymous_52)","decl":{"start":{"line":259,"column":120},"end":{"line":259,"column":121}},"loc":{"start":{"line":259,"column":140},"end":{"line":262,"column":7}},"line":259},"53":{"name":"(anonymous_53)","decl":{"start":{"line":264,"column":77},"end":{"line":264,"column":78}},"loc":{"start":{"line":264,"column":93},"end":{"line":272,"column":5}},"line":264},"54":{"name":"(anonymous_54)","decl":{"start":{"line":266,"column":124},"end":{"line":266,"column":125}},"loc":{"start":{"line":266,"column":144},"end":{"line":271,"column":7}},"line":266},"55":{"name":"(anonymous_55)","decl":{"start":{"line":273,"column":63},"end":{"line":273,"column":64}},"loc":{"start":{"line":273,"column":79},"end":{"line":281,"column":5}},"line":273},"56":{"name":"(anonymous_56)","decl":{"start":{"line":275,"column":118},"end":{"line":275,"column":119}},"loc":{"start":{"line":275,"column":138},"end":{"line":280,"column":7}},"line":275}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":0,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":0,"134":0,"135":0,"136":0,"137":0,"138":1,"139":1,"140":1,"141":1,"142":1,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":0,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"10c2204a94869348a88d4e5f4280dce0e208e693","contentHash":"49dba68cdca6874553107612f5b94da3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":49}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"5":{"start":{"line":15,"column":13},"end":{"line":17,"column":2}},"6":{"start":{"line":16,"column":2},"end":{"line":16,"column":63}},"7":{"start":{"line":19,"column":0},"end":{"line":19,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"(anonymous_1)","decl":{"start":{"line":15,"column":44},"end":{"line":15,"column":45}},"loc":{"start":{"line":15,"column":56},"end":{"line":17,"column":1}},"line":15}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":13,"column":11},"end":{"line":13,"column":35}},"type":"binary-expr","locations":[{"start":{"line":13,"column":11},"end":{"line":13,"column":27}},{"start":{"line":13,"column":31},"end":{"line":13,"column":35}}],"line":13}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1},"f":{"0":1,"1":1},"b":{"0":[1,0],"1":[1,1],"2":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"2c3f4d308d6c389ee08f6e68cdad1a35bf84c346","contentHash":"b011e4774c730a6764287d46023c385e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/express.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":18},"end":{"line":11,"column":40}},"4":{"start":{"line":13,"column":19},"end":{"line":13,"column":54}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":31}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":24},"end":{"line":19,"column":52}},"8":{"start":{"line":21,"column":25},"end":{"line":21,"column":66}},"9":{"start":{"line":23,"column":14},"end":{"line":23,"column":34}},"10":{"start":{"line":25,"column":15},"end":{"line":25,"column":46}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":10},"end":{"line":29,"column":34}},"13":{"start":{"line":31,"column":0},"end":{"line":31,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":37}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":62}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":43}},"17":{"start":{"line":37,"column":0},"end":{"line":46,"column":3}},"18":{"start":{"line":38,"column":13},"end":{"line":38,"column":21}},"19":{"start":{"line":39,"column":13},"end":{"line":39,"column":18}},"20":{"start":{"line":40,"column":2},"end":{"line":44,"column":4}},"21":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"22":{"start":{"line":41,"column":14},"end":{"line":41,"column":21}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":25}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":16}},"25":{"start":{"line":45,"column":2},"end":{"line":45,"column":9}},"26":{"start":{"line":49,"column":0},"end":{"line":49,"column":37}},"27":{"start":{"line":51,"column":0},"end":{"line":51,"column":22}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":8},"end":{"line":37,"column":9}},"loc":{"start":{"line":37,"column":34},"end":{"line":46,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":13},"end":{"line":40,"column":14}},"loc":{"start":{"line":40,"column":29},"end":{"line":44,"column":3}},"line":40}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27},"2":{"loc":{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},"type":"if","locations":[{"start":{"line":41,"column":4},"end":{"line":41,"column":21}},{"start":{"line":41,"column":4},"end":{"line":41,"column":21}}],"line":41}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":81,"19":81,"20":81,"21":110,"22":4,"23":106,"24":106,"25":81,"26":1,"27":1},"f":{"0":5,"1":81,"2":110},"b":{"0":[1,4],"1":[5,5],"2":[4,106]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"631ffa56d34b584cfaaf514a9d3aab5ddb9550d2","contentHash":"68477734160cec3adc5d527b8a040a9b_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/index.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":31}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":33}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":17},"end":{"line":19,"column":39}},"8":{"start":{"line":21,"column":18},"end":{"line":21,"column":52}},"9":{"start":{"line":23,"column":13},"end":{"line":23,"column":31}},"10":{"start":{"line":25,"column":14},"end":{"line":25,"column":44}},"11":{"start":{"line":27,"column":39},"end":{"line":27,"column":93}},"12":{"start":{"line":29,"column":13},"end":{"line":29,"column":39}},"13":{"start":{"line":32,"column":0},"end":{"line":32,"column":38}},"14":{"start":{"line":33,"column":0},"end":{"line":33,"column":40}},"15":{"start":{"line":34,"column":0},"end":{"line":34,"column":46}},"16":{"start":{"line":35,"column":0},"end":{"line":35,"column":38}},"17":{"start":{"line":37,"column":0},"end":{"line":37,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":31}},"loc":{"start":{"line":27,"column":37},"end":{"line":27,"column":95}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":92}},"type":"cond-expr","locations":[{"start":{"line":27,"column":70},"end":{"line":27,"column":73}},{"start":{"line":27,"column":76},"end":{"line":27,"column":92}}],"line":27},"1":{"loc":{"start":{"line":27,"column":46},"end":{"line":27,"column":67}},"type":"binary-expr","locations":[{"start":{"line":27,"column":46},"end":{"line":27,"column":49}},{"start":{"line":27,"column":53},"end":{"line":27,"column":67}}],"line":27}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":5,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1},"f":{"0":5},"b":{"0":[4,1],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"242d65573f043ccce04223bd6f51cdda15503f5f","contentHash":"3a58cb6f4391326b95f0cf67e2d870a0_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":34}},"10":{"start":{"line":30,"column":0},"end":{"line":32,"column":29}},"11":{"start":{"line":34,"column":0},"end":{"line":42,"column":64}},"12":{"start":{"line":44,"column":0},"end":{"line":46,"column":67}},"13":{"start":{"line":48,"column":0},"end":{"line":48,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a4c38addb0d124dbae4b2d5ea8e6e3d38cf94991","contentHash":"b6e317aa7a985adf5a98d45b1aa5fd24_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/users.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":20},"end":{"line":11,"column":43}},"4":{"start":{"line":13,"column":21},"end":{"line":13,"column":58}},"5":{"start":{"line":15,"column":14},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":46}},"7":{"start":{"line":19,"column":14},"end":{"line":19,"column":34}},"8":{"start":{"line":21,"column":15},"end":{"line":21,"column":46}},"9":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"10":{"start":{"line":25,"column":0},"end":{"line":25,"column":27}},"11":{"start":{"line":27,"column":16},"end":{"line":27,"column":38}},"12":{"start":{"line":28,"column":15},"end":{"line":28,"column":40}},"13":{"start":{"line":29,"column":11},"end":{"line":29,"column":32}},"14":{"start":{"line":30,"column":15},"end":{"line":30,"column":50}},"15":{"start":{"line":39,"column":14},"end":{"line":39,"column":29}},"16":{"start":{"line":40,"column":15},"end":{"line":40,"column":31}},"17":{"start":{"line":41,"column":2},"end":{"line":54,"column":5}},"18":{"start":{"line":45,"column":15},"end":{"line":45,"column":24}},"19":{"start":{"line":46,"column":16},"end":{"line":46,"column":26}},"20":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"21":{"start":{"line":53,"column":4},"end":{"line":53,"column":39}},"22":{"start":{"line":64,"column":2},"end":{"line":64,"column":59}},"23":{"start":{"line":65,"column":2},"end":{"line":65,"column":59}},"24":{"start":{"line":66,"column":2},"end":{"line":66,"column":53}},"25":{"start":{"line":67,"column":2},"end":{"line":67,"column":59}},"26":{"start":{"line":68,"column":2},"end":{"line":68,"column":59}},"27":{"start":{"line":69,"column":2},"end":{"line":69,"column":85}},"28":{"start":{"line":70,"column":15},"end":{"line":70,"column":37}},"29":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"30":{"start":{"line":73,"column":4},"end":{"line":73,"column":45}},"31":{"start":{"line":75,"column":4},"end":{"line":95,"column":7}},"32":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"33":{"start":{"line":79,"column":8},"end":{"line":93,"column":11}},"34":{"start":{"line":86,"column":10},"end":{"line":90,"column":13}},"35":{"start":{"line":92,"column":10},"end":{"line":92,"column":38}},"36":{"start":{"line":106,"column":2},"end":{"line":106,"column":53}},"37":{"start":{"line":107,"column":2},"end":{"line":107,"column":59}},"38":{"start":{"line":108,"column":2},"end":{"line":108,"column":59}},"39":{"start":{"line":110,"column":15},"end":{"line":110,"column":37}},"40":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"41":{"start":{"line":113,"column":4},"end":{"line":113,"column":45}},"42":{"start":{"line":115,"column":4},"end":{"line":147,"column":7}},"43":{"start":{"line":118,"column":25},"end":{"line":118,"column":32}},"44":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"45":{"start":{"line":120,"column":8},"end":{"line":122,"column":63}},"46":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"47":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"48":{"start":{"line":125,"column":24},"end":{"line":130,"column":11}},"49":{"start":{"line":131,"column":22},"end":{"line":133,"column":12}},"50":{"start":{"line":134,"column":10},"end":{"line":137,"column":13}},"51":{"start":{"line":139,"column":10},"end":{"line":142,"column":13}},"52":{"start":{"line":146,"column":6},"end":{"line":146,"column":41}},"53":{"start":{"line":158,"column":18},"end":{"line":158,"column":39}},"54":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"55":{"start":{"line":160,"column":4},"end":{"line":162,"column":7}},"56":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"57":{"start":{"line":165,"column":4},"end":{"line":167,"column":7}},"58":{"start":{"line":169,"column":2},"end":{"line":181,"column":5}},"59":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"60":{"start":{"line":176,"column":6},"end":{"line":176,"column":58}},"61":{"start":{"line":178,"column":4},"end":{"line":178,"column":31}},"62":{"start":{"line":180,"column":4},"end":{"line":180,"column":39}},"63":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"64":{"start":{"line":192,"column":4},"end":{"line":194,"column":7}},"65":{"start":{"line":196,"column":15},"end":{"line":196,"column":36}},"66":{"start":{"line":197,"column":2},"end":{"line":225,"column":5}},"67":{"start":{"line":198,"column":4},"end":{"line":224,"column":7}},"68":{"start":{"line":199,"column":6},"end":{"line":223,"column":9}},"69":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"70":{"start":{"line":201,"column":10},"end":{"line":201,"column":69}},"71":{"start":{"line":203,"column":8},"end":{"line":220,"column":11}},"72":{"start":{"line":210,"column":10},"end":{"line":217,"column":13}},"73":{"start":{"line":219,"column":10},"end":{"line":219,"column":45}},"74":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"75":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"76":{"start":{"line":236,"column":4},"end":{"line":238,"column":7}},"77":{"start":{"line":240,"column":2},"end":{"line":252,"column":5}},"78":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"79":{"start":{"line":242,"column":6},"end":{"line":242,"column":65}},"80":{"start":{"line":244,"column":4},"end":{"line":249,"column":7}},"81":{"start":{"line":245,"column":6},"end":{"line":246,"column":57}},"82":{"start":{"line":248,"column":6},"end":{"line":248,"column":41}},"83":{"start":{"line":251,"column":4},"end":{"line":251,"column":39}},"84":{"start":{"line":263,"column":14},"end":{"line":263,"column":29}},"85":{"start":{"line":264,"column":15},"end":{"line":264,"column":31}},"86":{"start":{"line":265,"column":2},"end":{"line":290,"column":5}},"87":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"88":{"start":{"line":267,"column":6},"end":{"line":269,"column":9}},"89":{"start":{"line":271,"column":4},"end":{"line":287,"column":7}},"90":{"start":{"line":278,"column":21},"end":{"line":278,"column":31}},"91":{"start":{"line":279,"column":18},"end":{"line":279,"column":29}},"92":{"start":{"line":281,"column":6},"end":{"line":284,"column":9}},"93":{"start":{"line":286,"column":6},"end":{"line":286,"column":41}},"94":{"start":{"line":289,"column":4},"end":{"line":289,"column":39}},"95":{"start":{"line":293,"column":0},"end":{"line":301,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"getUsers","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":17}},"loc":{"start":{"line":38,"column":28},"end":{"line":55,"column":1}},"line":38},"2":{"name":"(anonymous_2)","decl":{"start":{"line":44,"column":10},"end":{"line":44,"column":11}},"loc":{"start":{"line":44,"column":26},"end":{"line":52,"column":3}},"line":44},"3":{"name":"(anonymous_3)","decl":{"start":{"line":52,"column":11},"end":{"line":52,"column":12}},"loc":{"start":{"line":52,"column":28},"end":{"line":54,"column":3}},"line":52},"4":{"name":"createUser","decl":{"start":{"line":63,"column":9},"end":{"line":63,"column":19}},"loc":{"start":{"line":63,"column":30},"end":{"line":97,"column":1}},"line":63},"5":{"name":"(anonymous_5)","decl":{"start":{"line":77,"column":12},"end":{"line":77,"column":13}},"loc":{"start":{"line":77,"column":33},"end":{"line":95,"column":5}},"line":77},"6":{"name":"(anonymous_6)","decl":{"start":{"line":85,"column":16},"end":{"line":85,"column":17}},"loc":{"start":{"line":85,"column":39},"end":{"line":91,"column":9}},"line":85},"7":{"name":"(anonymous_7)","decl":{"start":{"line":91,"column":17},"end":{"line":91,"column":18}},"loc":{"start":{"line":91,"column":34},"end":{"line":93,"column":9}},"line":91},"8":{"name":"login","decl":{"start":{"line":105,"column":9},"end":{"line":105,"column":14}},"loc":{"start":{"line":105,"column":25},"end":{"line":149,"column":1}},"line":105},"9":{"name":"(anonymous_9)","decl":{"start":{"line":117,"column":12},"end":{"line":117,"column":13}},"loc":{"start":{"line":117,"column":28},"end":{"line":145,"column":5}},"line":117},"10":{"name":"(anonymous_10)","decl":{"start":{"line":145,"column":13},"end":{"line":145,"column":14}},"loc":{"start":{"line":145,"column":30},"end":{"line":147,"column":5}},"line":145},"11":{"name":"findUser","decl":{"start":{"line":157,"column":9},"end":{"line":157,"column":17}},"loc":{"start":{"line":157,"column":28},"end":{"line":182,"column":1}},"line":157},"12":{"name":"(anonymous_12)","decl":{"start":{"line":174,"column":10},"end":{"line":174,"column":11}},"loc":{"start":{"line":174,"column":26},"end":{"line":179,"column":3}},"line":174},"13":{"name":"(anonymous_13)","decl":{"start":{"line":179,"column":11},"end":{"line":179,"column":12}},"loc":{"start":{"line":179,"column":28},"end":{"line":181,"column":3}},"line":179},"14":{"name":"updateUser","decl":{"start":{"line":190,"column":9},"end":{"line":190,"column":19}},"loc":{"start":{"line":190,"column":30},"end":{"line":226,"column":1}},"line":190},"15":{"name":"(anonymous_15)","decl":{"start":{"line":197,"column":31},"end":{"line":197,"column":32}},"loc":{"start":{"line":197,"column":52},"end":{"line":225,"column":3}},"line":197},"16":{"name":"(anonymous_16)","decl":{"start":{"line":198,"column":51},"end":{"line":198,"column":52}},"loc":{"start":{"line":198,"column":72},"end":{"line":224,"column":5}},"line":198},"17":{"name":"(anonymous_17)","decl":{"start":{"line":199,"column":33},"end":{"line":199,"column":34}},"loc":{"start":{"line":199,"column":49},"end":{"line":221,"column":7}},"line":199},"18":{"name":"(anonymous_18)","decl":{"start":{"line":209,"column":16},"end":{"line":209,"column":17}},"loc":{"start":{"line":209,"column":39},"end":{"line":218,"column":9}},"line":209},"19":{"name":"(anonymous_19)","decl":{"start":{"line":218,"column":17},"end":{"line":218,"column":18}},"loc":{"start":{"line":218,"column":34},"end":{"line":220,"column":9}},"line":218},"20":{"name":"(anonymous_20)","decl":{"start":{"line":221,"column":15},"end":{"line":221,"column":16}},"loc":{"start":{"line":221,"column":32},"end":{"line":223,"column":7}},"line":221},"21":{"name":"deleteUser","decl":{"start":{"line":234,"column":9},"end":{"line":234,"column":19}},"loc":{"start":{"line":234,"column":30},"end":{"line":253,"column":1}},"line":234},"22":{"name":"(anonymous_22)","decl":{"start":{"line":240,"column":43},"end":{"line":240,"column":44}},"loc":{"start":{"line":240,"column":59},"end":{"line":250,"column":3}},"line":240},"23":{"name":"(anonymous_23)","decl":{"start":{"line":244,"column":31},"end":{"line":244,"column":32}},"loc":{"start":{"line":244,"column":43},"end":{"line":247,"column":5}},"line":244},"24":{"name":"(anonymous_24)","decl":{"start":{"line":247,"column":13},"end":{"line":247,"column":14}},"loc":{"start":{"line":247,"column":30},"end":{"line":249,"column":5}},"line":247},"25":{"name":"(anonymous_25)","decl":{"start":{"line":250,"column":11},"end":{"line":250,"column":12}},"loc":{"start":{"line":250,"column":28},"end":{"line":252,"column":3}},"line":250},"26":{"name":"getUserDocuments","decl":{"start":{"line":262,"column":9},"end":{"line":262,"column":25}},"loc":{"start":{"line":262,"column":36},"end":{"line":291,"column":1}},"line":262},"27":{"name":"(anonymous_27)","decl":{"start":{"line":265,"column":36},"end":{"line":265,"column":37}},"loc":{"start":{"line":265,"column":52},"end":{"line":288,"column":3}},"line":265},"28":{"name":"(anonymous_28)","decl":{"start":{"line":277,"column":12},"end":{"line":277,"column":13}},"loc":{"start":{"line":277,"column":29},"end":{"line":285,"column":5}},"line":277},"29":{"name":"(anonymous_29)","decl":{"start":{"line":285,"column":13},"end":{"line":285,"column":14}},"loc":{"start":{"line":285,"column":30},"end":{"line":287,"column":5}},"line":285},"30":{"name":"(anonymous_30)","decl":{"start":{"line":288,"column":11},"end":{"line":288,"column":12}},"loc":{"start":{"line":288,"column":28},"end":{"line":290,"column":3}},"line":288}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23},"2":{"loc":{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":96,"column":3}},{"start":{"line":72,"column":2},"end":{"line":96,"column":3}}],"line":72},"3":{"loc":{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},"type":"if","locations":[{"start":{"line":78,"column":6},"end":{"line":94,"column":7}},{"start":{"line":78,"column":6},"end":{"line":94,"column":7}}],"line":78},"4":{"loc":{"start":{"line":84,"column":18},"end":{"line":84,"column":38}},"type":"binary-expr","locations":[{"start":{"line":84,"column":18},"end":{"line":84,"column":33}},{"start":{"line":84,"column":37},"end":{"line":84,"column":38}}],"line":84},"5":{"loc":{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},"type":"if","locations":[{"start":{"line":112,"column":2},"end":{"line":148,"column":3}},{"start":{"line":112,"column":2},"end":{"line":148,"column":3}}],"line":112},"6":{"loc":{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":119,"column":6},"end":{"line":144,"column":7}},{"start":{"line":119,"column":6},"end":{"line":144,"column":7}}],"line":119},"7":{"loc":{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},"type":"if","locations":[{"start":{"line":123,"column":13},"end":{"line":144,"column":7}},{"start":{"line":123,"column":13},"end":{"line":144,"column":7}}],"line":123},"8":{"loc":{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},"type":"if","locations":[{"start":{"line":124,"column":8},"end":{"line":143,"column":9}},{"start":{"line":124,"column":8},"end":{"line":143,"column":9}}],"line":124},"9":{"loc":{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},"type":"if","locations":[{"start":{"line":159,"column":2},"end":{"line":163,"column":3}},{"start":{"line":159,"column":2},"end":{"line":163,"column":3}}],"line":159},"10":{"loc":{"start":{"line":159,"column":6},"end":{"line":159,"column":62}},"type":"binary-expr","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":34}},{"start":{"line":159,"column":38},"end":{"line":159,"column":62}}],"line":159},"11":{"loc":{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":168,"column":3}},{"start":{"line":164,"column":2},"end":{"line":168,"column":3}}],"line":164},"12":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"13":{"loc":{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},"type":"if","locations":[{"start":{"line":191,"column":2},"end":{"line":195,"column":3}},{"start":{"line":191,"column":2},"end":{"line":195,"column":3}}],"line":191},"14":{"loc":{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},"type":"if","locations":[{"start":{"line":200,"column":8},"end":{"line":202,"column":9}},{"start":{"line":200,"column":8},"end":{"line":202,"column":9}}],"line":200},"15":{"loc":{"start":{"line":204,"column":20},"end":{"line":204,"column":54}},"type":"binary-expr","locations":[{"start":{"line":204,"column":20},"end":{"line":204,"column":37}},{"start":{"line":204,"column":41},"end":{"line":204,"column":54}}],"line":204},"16":{"loc":{"start":{"line":205,"column":20},"end":{"line":205,"column":54}},"type":"binary-expr","locations":[{"start":{"line":205,"column":20},"end":{"line":205,"column":37}},{"start":{"line":205,"column":41},"end":{"line":205,"column":54}}],"line":205},"17":{"loc":{"start":{"line":206,"column":17},"end":{"line":206,"column":45}},"type":"binary-expr","locations":[{"start":{"line":206,"column":17},"end":{"line":206,"column":31}},{"start":{"line":206,"column":35},"end":{"line":206,"column":45}}],"line":206},"18":{"loc":{"start":{"line":207,"column":20},"end":{"line":207,"column":41}},"type":"binary-expr","locations":[{"start":{"line":207,"column":20},"end":{"line":207,"column":24}},{"start":{"line":207,"column":28},"end":{"line":207,"column":41}}],"line":207},"19":{"loc":{"start":{"line":208,"column":18},"end":{"line":208,"column":48}},"type":"binary-expr","locations":[{"start":{"line":208,"column":18},"end":{"line":208,"column":33}},{"start":{"line":208,"column":37},"end":{"line":208,"column":48}}],"line":208},"20":{"loc":{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},"type":"if","locations":[{"start":{"line":235,"column":2},"end":{"line":239,"column":3}},{"start":{"line":235,"column":2},"end":{"line":239,"column":3}}],"line":235},"21":{"loc":{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":243,"column":5}},{"start":{"line":241,"column":4},"end":{"line":243,"column":5}}],"line":241},"22":{"loc":{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},"type":"if","locations":[{"start":{"line":266,"column":4},"end":{"line":270,"column":5}},{"start":{"line":266,"column":4},"end":{"line":270,"column":5}}],"line":266}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":4,"10":1,"11":1,"12":1,"13":1,"14":1,"15":2,"16":2,"17":2,"18":2,"19":2,"20":2,"21":0,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":0,"31":1,"32":1,"33":1,"34":1,"35":0,"36":15,"37":15,"38":15,"39":15,"40":15,"41":0,"42":15,"43":15,"44":15,"45":1,"46":14,"47":14,"48":13,"49":13,"50":13,"51":1,"52":0,"53":5,"54":5,"55":0,"56":5,"57":1,"58":4,"59":3,"60":1,"61":3,"62":1,"63":5,"64":2,"65":3,"66":3,"67":3,"68":3,"69":3,"70":0,"71":3,"72":3,"73":0,"74":0,"75":3,"76":1,"77":2,"78":2,"79":1,"80":1,"81":1,"82":0,"83":0,"84":2,"85":2,"86":2,"87":2,"88":1,"89":1,"90":1,"91":1,"92":1,"93":0,"94":0,"95":1},"f":{"0":4,"1":2,"2":2,"3":0,"4":1,"5":1,"6":1,"7":0,"8":15,"9":15,"10":0,"11":5,"12":3,"13":1,"14":5,"15":3,"16":3,"17":3,"18":3,"19":0,"20":0,"21":3,"22":2,"23":1,"24":0,"25":0,"26":2,"27":2,"28":1,"29":0,"30":0},"b":{"0":[0,4],"1":[4,4],"2":[0,1],"3":[1,0],"4":[1,0],"5":[0,15],"6":[1,14],"7":[14,0],"8":[13,1],"9":[0,5],"10":[5,4],"11":[1,4],"12":[1,2],"13":[2,3],"14":[0,3],"15":[3,2],"16":[3,2],"17":[3,2],"18":[3,3],"19":[3,3],"20":[1,2],"21":[1,1],"22":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a873f3a1e83910dd4a7534a9fab6445e85d48e8a","contentHash":"8f158652d1e645800e331a339c32bd94_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/helpers/helper.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":10,"column":1}},"1":{"start":{"line":4,"column":2},"end":{"line":9,"column":4}},"2":{"start":{"line":12,"column":0},"end":{"line":12,"column":55}}},"fnMap":{"0":{"name":"paginationMetaData","decl":{"start":{"line":3,"column":34},"end":{"line":3,"column":52}},"loc":{"start":{"line":3,"column":75},"end":{"line":10,"column":1}},"line":3}},"branchMap":{},"s":{"0":1,"1":6,"2":1},"f":{"0":6},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"4465f4d163a5ad4fee78e39a1eef0f59ca60bcc2","contentHash":"65216cd25fbea3beb9fe0dfec073fc7e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/index.js","statementMap":{"0":{"start":{"line":3,"column":9},"end":{"line":3,"column":22}},"1":{"start":{"line":4,"column":11},"end":{"line":4,"column":26}},"2":{"start":{"line":5,"column":16},"end":{"line":5,"column":36}},"3":{"start":{"line":7,"column":15},"end":{"line":7,"column":45}},"4":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"5":{"start":{"line":9,"column":13},"end":{"line":9,"column":48}},"6":{"start":{"line":11,"column":9},"end":{"line":11,"column":11}},"7":{"start":{"line":13,"column":16},"end":{"line":13,"column":22}},"8":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"9":{"start":{"line":15,"column":2},"end":{"line":15,"column":66}},"10":{"start":{"line":17,"column":2},"end":{"line":17,"column":87}},"11":{"start":{"line":20,"column":0},"end":{"line":25,"column":3}},"12":{"start":{"line":21,"column":2},"end":{"line":21,"column":82}},"13":{"start":{"line":23,"column":14},"end":{"line":23,"column":58}},"14":{"start":{"line":24,"column":2},"end":{"line":24,"column":25}},"15":{"start":{"line":27,"column":0},"end":{"line":31,"column":3}},"16":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"17":{"start":{"line":29,"column":4},"end":{"line":29,"column":32}},"18":{"start":{"line":33,"column":0},"end":{"line":33,"column":25}},"19":{"start":{"line":34,"column":0},"end":{"line":34,"column":25}},"20":{"start":{"line":36,"column":0},"end":{"line":36,"column":20}},"21":{"start":{"line":38,"column":0},"end":{"line":38,"column":25}},"22":{"start":{"line":39,"column":0},"end":{"line":39,"column":25}},"23":{"start":{"line":41,"column":0},"end":{"line":41,"column":20}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":33},"end":{"line":20,"column":34}},"loc":{"start":{"line":20,"column":49},"end":{"line":22,"column":1}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":22,"column":11},"end":{"line":22,"column":12}},"loc":{"start":{"line":22,"column":27},"end":{"line":25,"column":1}},"line":22},"2":{"name":"(anonymous_2)","decl":{"start":{"line":27,"column":24},"end":{"line":27,"column":25}},"loc":{"start":{"line":27,"column":45},"end":{"line":31,"column":1}},"line":27}},"branchMap":{"0":{"loc":{"start":{"line":8,"column":10},"end":{"line":8,"column":47}},"type":"binary-expr","locations":[{"start":{"line":8,"column":10},"end":{"line":8,"column":30}},{"start":{"line":8,"column":34},"end":{"line":8,"column":47}}],"line":8},"1":{"loc":{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},"type":"if","locations":[{"start":{"line":14,"column":0},"end":{"line":18,"column":1}},{"start":{"line":14,"column":0},"end":{"line":18,"column":1}}],"line":14},"2":{"loc":{"start":{"line":21,"column":9},"end":{"line":21,"column":81}},"type":"binary-expr","locations":[{"start":{"line":21,"column":9},"end":{"line":21,"column":32}},{"start":{"line":21,"column":36},"end":{"line":21,"column":53}},{"start":{"line":21,"column":57},"end":{"line":21,"column":81}}],"line":21},"3":{"loc":{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},"type":"if","locations":[{"start":{"line":28,"column":2},"end":{"line":30,"column":3}},{"start":{"line":28,"column":2},"end":{"line":30,"column":3}}],"line":28}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":0,"10":1,"11":1,"12":4,"13":3,"14":3,"15":1,"16":3,"17":3,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1},"f":{"0":4,"1":3,"2":3},"b":{"0":[1,0],"1":[0,1],"2":[4,4,3],"3":[3,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"873e872266ec01d9da7d7ec0d8cff9eeebab65b3","contentHash":"147d2f5ce718f5d34ee69e59b4b18b17_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/config/config.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":27,"column":2}}},"fnMap":{},"branchMap":{},"s":{"0":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"a1ab92e502a6f44216fbf97c5e3b416d2cdd1c15","contentHash":"bfdbdb10808231c6b80faf6c05504184_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/document.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":30,"column":2}},"1":{"start":{"line":4,"column":17},"end":{"line":22,"column":4}},"2":{"start":{"line":23,"column":2},"end":{"line":28,"column":4}},"3":{"start":{"line":25,"column":4},"end":{"line":27,"column":7}},"4":{"start":{"line":29,"column":2},"end":{"line":29,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":30,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":23,"column":23},"end":{"line":23,"column":24}},"loc":{"start":{"line":23,"column":41},"end":{"line":28,"column":3}},"line":23}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"40f538af399cb910f51ef1c6e4b9fa7626ac8040","contentHash":"ebe8d40228054cd49ad96bbdc1301e25_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/role.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":18,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":10,"column":4}},"2":{"start":{"line":11,"column":2},"end":{"line":16,"column":4}},"3":{"start":{"line":13,"column":4},"end":{"line":15,"column":7}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":18,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":11,"column":19},"end":{"line":11,"column":20}},"loc":{"start":{"line":11,"column":37},"end":{"line":16,"column":3}},"line":11}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1aba90d94e80bdb0379ea9ddd4c53cf22a593f71","contentHash":"b22cffd605cf93f69a3f2719a0d065e3_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/models/user.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":42,"column":2}},"1":{"start":{"line":4,"column":13},"end":{"line":28,"column":4}},"2":{"start":{"line":29,"column":2},"end":{"line":40,"column":4}},"3":{"start":{"line":31,"column":4},"end":{"line":35,"column":7}},"4":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"5":{"start":{"line":41,"column":2},"end":{"line":41,"column":14}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":3,"column":17},"end":{"line":3,"column":18}},"loc":{"start":{"line":3,"column":49},"end":{"line":42,"column":1}},"line":3},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":19},"end":{"line":29,"column":20}},"loc":{"start":{"line":29,"column":37},"end":{"line":40,"column":3}},"line":29}},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1,"1":1},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1296338becccf35da8d16bf6f6a410038393a663","contentHash":"e3e5a8798513104b93e617b86fce0484_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/middlewares/auth.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":20},"end":{"line":7,"column":43}},"2":{"start":{"line":9,"column":21},"end":{"line":9,"column":58}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":16},"end":{"line":13,"column":38}},"5":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"6":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"7":{"start":{"line":18,"column":4},"end":{"line":25,"column":7}},"8":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"9":{"start":{"line":20,"column":8},"end":{"line":20,"column":79}},"10":{"start":{"line":22,"column":8},"end":{"line":22,"column":30}},"11":{"start":{"line":23,"column":8},"end":{"line":23,"column":15}},"12":{"start":{"line":27,"column":4},"end":{"line":30,"column":7}},"13":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"14":{"start":{"line":36,"column":4},"end":{"line":36,"column":11}},"15":{"start":{"line":38,"column":4},"end":{"line":40,"column":7}},"16":{"start":{"line":44,"column":0},"end":{"line":44,"column":73}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11},"1":{"name":"verifyToken","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":20}},"loc":{"start":{"line":15,"column":37},"end":{"line":32,"column":1}},"line":15},"2":{"name":"(anonymous_2)","decl":{"start":{"line":18,"column":52},"end":{"line":18,"column":53}},"loc":{"start":{"line":18,"column":76},"end":{"line":25,"column":5}},"line":18},"3":{"name":"adminAccess","decl":{"start":{"line":34,"column":9},"end":{"line":34,"column":20}},"loc":{"start":{"line":34,"column":37},"end":{"line":42,"column":1}},"line":34}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11},"2":{"loc":{"start":{"line":16,"column":14},"end":{"line":16,"column":72}},"type":"binary-expr","locations":[{"start":{"line":16,"column":14},"end":{"line":16,"column":39}},{"start":{"line":16,"column":43},"end":{"line":16,"column":72}}],"line":16},"3":{"loc":{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":31,"column":3}},{"start":{"line":17,"column":2},"end":{"line":31,"column":3}}],"line":17},"4":{"loc":{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},"type":"if","locations":[{"start":{"line":19,"column":6},"end":{"line":24,"column":7}},{"start":{"line":19,"column":6},"end":{"line":24,"column":7}}],"line":19},"5":{"loc":{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":35,"column":2},"end":{"line":41,"column":3}},{"start":{"line":35,"column":2},"end":{"line":41,"column":3}}],"line":35}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":64,"6":64,"7":60,"8":60,"9":0,"10":60,"11":60,"12":4,"13":25,"14":15,"15":10,"16":1},"f":{"0":1,"1":64,"2":60,"3":25},"b":{"0":[0,1],"1":[1,1],"2":[64,4],"3":[60,4],"4":[0,60],"5":[15,10]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ecc14d1e97432b8e57f39e5c505683a335fe6c8b","contentHash":"319c6e9c3dd86dee4e26cb1f933899cc_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":46}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":25,"column":90}},"10":{"start":{"line":27,"column":0},"end":{"line":29,"column":95}},"11":{"start":{"line":31,"column":0},"end":{"line":31,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"68b3619793c37e6d78583f4e6d35dc746e22808b","contentHash":"1708591ee5a07428c3cfae7deaa863aa_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/search.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":20},"end":{"line":28,"column":31}},"10":{"start":{"line":29,"column":14},"end":{"line":29,"column":29}},"11":{"start":{"line":30,"column":15},"end":{"line":30,"column":31}},"12":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"13":{"start":{"line":32,"column":4},"end":{"line":34,"column":7}},"14":{"start":{"line":36,"column":2},"end":{"line":58,"column":5}},"15":{"start":{"line":46,"column":15},"end":{"line":46,"column":24}},"16":{"start":{"line":47,"column":16},"end":{"line":47,"column":26}},"17":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"18":{"start":{"line":50,"column":6},"end":{"line":50,"column":65}},"19":{"start":{"line":52,"column":4},"end":{"line":55,"column":7}},"20":{"start":{"line":57,"column":4},"end":{"line":57,"column":39}},"21":{"start":{"line":69,"column":14},"end":{"line":69,"column":29}},"22":{"start":{"line":70,"column":15},"end":{"line":70,"column":31}},"23":{"start":{"line":71,"column":20},"end":{"line":71,"column":31}},"24":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"25":{"start":{"line":73,"column":4},"end":{"line":75,"column":7}},"26":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"27":{"start":{"line":78,"column":4},"end":{"line":106,"column":7}},"28":{"start":{"line":94,"column":21},"end":{"line":94,"column":31}},"29":{"start":{"line":95,"column":18},"end":{"line":95,"column":29}},"30":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"31":{"start":{"line":98,"column":8},"end":{"line":98,"column":64}},"32":{"start":{"line":100,"column":6},"end":{"line":103,"column":9}},"33":{"start":{"line":105,"column":6},"end":{"line":105,"column":41}},"34":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"35":{"start":{"line":108,"column":4},"end":{"line":140,"column":7}},"36":{"start":{"line":128,"column":21},"end":{"line":128,"column":31}},"37":{"start":{"line":129,"column":18},"end":{"line":129,"column":29}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"39":{"start":{"line":132,"column":8},"end":{"line":132,"column":64}},"40":{"start":{"line":134,"column":6},"end":{"line":137,"column":9}},"41":{"start":{"line":139,"column":6},"end":{"line":139,"column":41}},"42":{"start":{"line":144,"column":0},"end":{"line":144,"column":79}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"searchUser","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":19}},"loc":{"start":{"line":27,"column":30},"end":{"line":59,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":45,"column":10},"end":{"line":45,"column":11}},"loc":{"start":{"line":45,"column":26},"end":{"line":56,"column":3}},"line":45},"3":{"name":"(anonymous_3)","decl":{"start":{"line":56,"column":11},"end":{"line":56,"column":12}},"loc":{"start":{"line":56,"column":28},"end":{"line":58,"column":3}},"line":56},"4":{"name":"searchDocuments","decl":{"start":{"line":68,"column":9},"end":{"line":68,"column":24}},"loc":{"start":{"line":68,"column":35},"end":{"line":142,"column":1}},"line":68},"5":{"name":"(anonymous_5)","decl":{"start":{"line":93,"column":12},"end":{"line":93,"column":13}},"loc":{"start":{"line":93,"column":29},"end":{"line":104,"column":5}},"line":93},"6":{"name":"(anonymous_6)","decl":{"start":{"line":104,"column":13},"end":{"line":104,"column":14}},"loc":{"start":{"line":104,"column":30},"end":{"line":106,"column":5}},"line":104},"7":{"name":"(anonymous_7)","decl":{"start":{"line":127,"column":12},"end":{"line":127,"column":13}},"loc":{"start":{"line":127,"column":29},"end":{"line":138,"column":5}},"line":127},"8":{"name":"(anonymous_8)","decl":{"start":{"line":138,"column":13},"end":{"line":138,"column":14}},"loc":{"start":{"line":138,"column":30},"end":{"line":140,"column":5}},"line":138}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},"type":"if","locations":[{"start":{"line":31,"column":2},"end":{"line":35,"column":3}},{"start":{"line":31,"column":2},"end":{"line":35,"column":3}}],"line":31},"3":{"loc":{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},"type":"if","locations":[{"start":{"line":49,"column":4},"end":{"line":51,"column":5}},{"start":{"line":49,"column":4},"end":{"line":51,"column":5}}],"line":49},"4":{"loc":{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},"type":"if","locations":[{"start":{"line":72,"column":2},"end":{"line":76,"column":3}},{"start":{"line":72,"column":2},"end":{"line":76,"column":3}}],"line":72},"5":{"loc":{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":77,"column":2},"end":{"line":141,"column":3}},{"start":{"line":77,"column":2},"end":{"line":141,"column":3}}],"line":77},"6":{"loc":{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},"type":"if","locations":[{"start":{"line":97,"column":6},"end":{"line":99,"column":7}},{"start":{"line":97,"column":6},"end":{"line":99,"column":7}}],"line":97},"7":{"loc":{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},"type":"if","locations":[{"start":{"line":107,"column":9},"end":{"line":141,"column":3}},{"start":{"line":107,"column":9},"end":{"line":141,"column":3}}],"line":107},"8":{"loc":{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},"type":"if","locations":[{"start":{"line":131,"column":6},"end":{"line":133,"column":7}},{"start":{"line":131,"column":6},"end":{"line":133,"column":7}}],"line":131}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":1},"f":{"0":2,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0},"b":{"0":[0,2],"1":[2,2],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"6efc7327907302db1883f00d2862afff115a5da3","contentHash":"50e871939ef4ea62c58b58df2dfa2014_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":17},"end":{"line":11,"column":52}},"4":{"start":{"line":13,"column":18},"end":{"line":13,"column":52}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":70}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":72}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63cb1e0c24d02fe76a86b13384c3b6510a628d08","contentHash":"befe059d51eace8d5b2b154e0976915f_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/documents.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":42}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":14},"end":{"line":11,"column":34}},"4":{"start":{"line":13,"column":15},"end":{"line":13,"column":46}},"5":{"start":{"line":15,"column":39},"end":{"line":15,"column":93}},"6":{"start":{"line":17,"column":15},"end":{"line":17,"column":40}},"7":{"start":{"line":18,"column":11},"end":{"line":18,"column":32}},"8":{"start":{"line":19,"column":15},"end":{"line":19,"column":50}},"9":{"start":{"line":28,"column":2},"end":{"line":28,"column":53}},"10":{"start":{"line":29,"column":2},"end":{"line":29,"column":57}},"11":{"start":{"line":30,"column":2},"end":{"line":30,"column":59}},"12":{"start":{"line":32,"column":15},"end":{"line":32,"column":37}},"13":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"14":{"start":{"line":35,"column":4},"end":{"line":35,"column":45}},"15":{"start":{"line":37,"column":4},"end":{"line":59,"column":7}},"16":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"17":{"start":{"line":43,"column":8},"end":{"line":52,"column":11}},"18":{"start":{"line":49,"column":10},"end":{"line":49,"column":56}},"19":{"start":{"line":51,"column":10},"end":{"line":51,"column":45}},"20":{"start":{"line":54,"column":6},"end":{"line":56,"column":9}},"21":{"start":{"line":58,"column":6},"end":{"line":58,"column":41}},"22":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"23":{"start":{"line":71,"column":4},"end":{"line":71,"column":27}},"24":{"start":{"line":73,"column":14},"end":{"line":73,"column":35}},"25":{"start":{"line":74,"column":2},"end":{"line":97,"column":5}},"26":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"27":{"start":{"line":76,"column":6},"end":{"line":78,"column":9}},"28":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"29":{"start":{"line":81,"column":6},"end":{"line":83,"column":9}},"30":{"start":{"line":85,"column":4},"end":{"line":94,"column":7}},"31":{"start":{"line":91,"column":6},"end":{"line":91,"column":44}},"32":{"start":{"line":93,"column":6},"end":{"line":93,"column":41}},"33":{"start":{"line":96,"column":4},"end":{"line":96,"column":39}},"34":{"start":{"line":107,"column":14},"end":{"line":107,"column":29}},"35":{"start":{"line":108,"column":15},"end":{"line":108,"column":31}},"36":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"37":{"start":{"line":110,"column":4},"end":{"line":132,"column":7}},"38":{"start":{"line":123,"column":21},"end":{"line":123,"column":30}},"39":{"start":{"line":124,"column":18},"end":{"line":124,"column":28}},"40":{"start":{"line":126,"column":6},"end":{"line":129,"column":9}},"41":{"start":{"line":131,"column":6},"end":{"line":131,"column":41}},"42":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"43":{"start":{"line":134,"column":4},"end":{"line":160,"column":7}},"44":{"start":{"line":151,"column":21},"end":{"line":151,"column":31}},"45":{"start":{"line":152,"column":18},"end":{"line":152,"column":29}},"46":{"start":{"line":154,"column":6},"end":{"line":157,"column":9}},"47":{"start":{"line":159,"column":6},"end":{"line":159,"column":41}},"48":{"start":{"line":171,"column":2},"end":{"line":203,"column":5}},"49":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"50":{"start":{"line":173,"column":6},"end":{"line":173,"column":62}},"51":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"52":{"start":{"line":176,"column":6},"end":{"line":176,"column":22}},"53":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"54":{"start":{"line":179,"column":6},"end":{"line":179,"column":44}},"55":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"56":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"57":{"start":{"line":183,"column":8},"end":{"line":185,"column":11}},"58":{"start":{"line":187,"column":6},"end":{"line":187,"column":44}},"59":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"60":{"start":{"line":190,"column":6},"end":{"line":199,"column":9}},"61":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"62":{"start":{"line":192,"column":10},"end":{"line":194,"column":13}},"63":{"start":{"line":196,"column":8},"end":{"line":196,"column":46}},"64":{"start":{"line":198,"column":8},"end":{"line":198,"column":43}},"65":{"start":{"line":202,"column":4},"end":{"line":202,"column":39}},"66":{"start":{"line":214,"column":2},"end":{"line":230,"column":5}},"67":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"68":{"start":{"line":216,"column":6},"end":{"line":216,"column":62}},"69":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"70":{"start":{"line":219,"column":6},"end":{"line":221,"column":9}},"71":{"start":{"line":223,"column":4},"end":{"line":227,"column":7}},"72":{"start":{"line":224,"column":6},"end":{"line":224,"column":80}},"73":{"start":{"line":226,"column":6},"end":{"line":226,"column":41}},"74":{"start":{"line":229,"column":4},"end":{"line":229,"column":39}},"75":{"start":{"line":233,"column":0},"end":{"line":238,"column":35}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":31}},"loc":{"start":{"line":15,"column":37},"end":{"line":15,"column":95}},"line":15},"1":{"name":"createDocument","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":23}},"loc":{"start":{"line":27,"column":34},"end":{"line":61,"column":1}},"line":27},"2":{"name":"(anonymous_2)","decl":{"start":{"line":41,"column":12},"end":{"line":41,"column":13}},"loc":{"start":{"line":41,"column":32},"end":{"line":57,"column":5}},"line":41},"3":{"name":"(anonymous_3)","decl":{"start":{"line":48,"column":16},"end":{"line":48,"column":17}},"loc":{"start":{"line":48,"column":44},"end":{"line":50,"column":9}},"line":48},"4":{"name":"(anonymous_4)","decl":{"start":{"line":50,"column":17},"end":{"line":50,"column":18}},"loc":{"start":{"line":50,"column":34},"end":{"line":52,"column":9}},"line":50},"5":{"name":"(anonymous_5)","decl":{"start":{"line":57,"column":13},"end":{"line":57,"column":14}},"loc":{"start":{"line":57,"column":30},"end":{"line":59,"column":5}},"line":57},"6":{"name":"updateDocument","decl":{"start":{"line":69,"column":9},"end":{"line":69,"column":23}},"loc":{"start":{"line":69,"column":34},"end":{"line":98,"column":1}},"line":69},"7":{"name":"(anonymous_7)","decl":{"start":{"line":74,"column":39},"end":{"line":74,"column":40}},"loc":{"start":{"line":74,"column":59},"end":{"line":95,"column":3}},"line":74},"8":{"name":"(anonymous_8)","decl":{"start":{"line":90,"column":12},"end":{"line":90,"column":13}},"loc":{"start":{"line":90,"column":24},"end":{"line":92,"column":5}},"line":90},"9":{"name":"(anonymous_9)","decl":{"start":{"line":92,"column":13},"end":{"line":92,"column":14}},"loc":{"start":{"line":92,"column":30},"end":{"line":94,"column":5}},"line":92},"10":{"name":"(anonymous_10)","decl":{"start":{"line":95,"column":11},"end":{"line":95,"column":12}},"loc":{"start":{"line":95,"column":28},"end":{"line":97,"column":3}},"line":95},"11":{"name":"getAllDocument","decl":{"start":{"line":106,"column":9},"end":{"line":106,"column":23}},"loc":{"start":{"line":106,"column":34},"end":{"line":162,"column":1}},"line":106},"12":{"name":"(anonymous_12)","decl":{"start":{"line":122,"column":12},"end":{"line":122,"column":13}},"loc":{"start":{"line":122,"column":28},"end":{"line":130,"column":5}},"line":122},"13":{"name":"(anonymous_13)","decl":{"start":{"line":130,"column":13},"end":{"line":130,"column":14}},"loc":{"start":{"line":130,"column":30},"end":{"line":132,"column":5}},"line":130},"14":{"name":"(anonymous_14)","decl":{"start":{"line":150,"column":12},"end":{"line":150,"column":13}},"loc":{"start":{"line":150,"column":29},"end":{"line":158,"column":5}},"line":150},"15":{"name":"(anonymous_15)","decl":{"start":{"line":158,"column":13},"end":{"line":158,"column":14}},"loc":{"start":{"line":158,"column":30},"end":{"line":160,"column":5}},"line":158},"16":{"name":"findDocument","decl":{"start":{"line":170,"column":9},"end":{"line":170,"column":21}},"loc":{"start":{"line":170,"column":32},"end":{"line":204,"column":1}},"line":170},"17":{"name":"(anonymous_17)","decl":{"start":{"line":171,"column":47},"end":{"line":171,"column":48}},"loc":{"start":{"line":171,"column":67},"end":{"line":201,"column":3}},"line":171},"18":{"name":"(anonymous_18)","decl":{"start":{"line":190,"column":66},"end":{"line":190,"column":67}},"loc":{"start":{"line":190,"column":91},"end":{"line":197,"column":7}},"line":190},"19":{"name":"(anonymous_19)","decl":{"start":{"line":197,"column":15},"end":{"line":197,"column":16}},"loc":{"start":{"line":197,"column":32},"end":{"line":199,"column":7}},"line":197},"20":{"name":"(anonymous_20)","decl":{"start":{"line":201,"column":11},"end":{"line":201,"column":12}},"loc":{"start":{"line":201,"column":28},"end":{"line":203,"column":3}},"line":201},"21":{"name":"deleteDocument","decl":{"start":{"line":213,"column":9},"end":{"line":213,"column":23}},"loc":{"start":{"line":213,"column":34},"end":{"line":231,"column":1}},"line":213},"22":{"name":"(anonymous_22)","decl":{"start":{"line":214,"column":47},"end":{"line":214,"column":48}},"loc":{"start":{"line":214,"column":67},"end":{"line":228,"column":3}},"line":214},"23":{"name":"(anonymous_23)","decl":{"start":{"line":223,"column":35},"end":{"line":223,"column":36}},"loc":{"start":{"line":223,"column":47},"end":{"line":225,"column":5}},"line":223},"24":{"name":"(anonymous_24)","decl":{"start":{"line":225,"column":13},"end":{"line":225,"column":14}},"loc":{"start":{"line":225,"column":30},"end":{"line":227,"column":5}},"line":225},"25":{"name":"(anonymous_25)","decl":{"start":{"line":228,"column":11},"end":{"line":228,"column":12}},"loc":{"start":{"line":228,"column":28},"end":{"line":230,"column":3}},"line":228}},"branchMap":{"0":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":92}},"type":"cond-expr","locations":[{"start":{"line":15,"column":70},"end":{"line":15,"column":73}},{"start":{"line":15,"column":76},"end":{"line":15,"column":92}}],"line":15},"1":{"loc":{"start":{"line":15,"column":46},"end":{"line":15,"column":67}},"type":"binary-expr","locations":[{"start":{"line":15,"column":46},"end":{"line":15,"column":49}},{"start":{"line":15,"column":53},"end":{"line":15,"column":67}}],"line":15},"2":{"loc":{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},"type":"if","locations":[{"start":{"line":34,"column":2},"end":{"line":60,"column":3}},{"start":{"line":34,"column":2},"end":{"line":60,"column":3}}],"line":34},"3":{"loc":{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},"type":"if","locations":[{"start":{"line":42,"column":6},"end":{"line":53,"column":7}},{"start":{"line":42,"column":6},"end":{"line":53,"column":7}}],"line":42},"4":{"loc":{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},"type":"if","locations":[{"start":{"line":70,"column":2},"end":{"line":72,"column":3}},{"start":{"line":70,"column":2},"end":{"line":72,"column":3}}],"line":70},"5":{"loc":{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":79,"column":5}},{"start":{"line":75,"column":4},"end":{"line":79,"column":5}}],"line":75},"6":{"loc":{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},"type":"if","locations":[{"start":{"line":80,"column":4},"end":{"line":84,"column":5}},{"start":{"line":80,"column":4},"end":{"line":84,"column":5}}],"line":80},"7":{"loc":{"start":{"line":86,"column":13},"end":{"line":86,"column":45}},"type":"binary-expr","locations":[{"start":{"line":86,"column":13},"end":{"line":86,"column":27}},{"start":{"line":86,"column":31},"end":{"line":86,"column":45}}],"line":86},"8":{"loc":{"start":{"line":87,"column":15},"end":{"line":87,"column":51}},"type":"binary-expr","locations":[{"start":{"line":87,"column":15},"end":{"line":87,"column":31}},{"start":{"line":87,"column":35},"end":{"line":87,"column":51}}],"line":87},"9":{"loc":{"start":{"line":88,"column":14},"end":{"line":88,"column":47}},"type":"binary-expr","locations":[{"start":{"line":88,"column":14},"end":{"line":88,"column":28}},{"start":{"line":88,"column":32},"end":{"line":88,"column":47}}],"line":88},"10":{"loc":{"start":{"line":89,"column":14},"end":{"line":89,"column":48}},"type":"binary-expr","locations":[{"start":{"line":89,"column":14},"end":{"line":89,"column":29}},{"start":{"line":89,"column":33},"end":{"line":89,"column":48}}],"line":89},"11":{"loc":{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":161,"column":3}},{"start":{"line":109,"column":2},"end":{"line":161,"column":3}}],"line":109},"12":{"loc":{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},"type":"if","locations":[{"start":{"line":133,"column":9},"end":{"line":161,"column":3}},{"start":{"line":133,"column":9},"end":{"line":161,"column":3}}],"line":133},"13":{"loc":{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":174,"column":5}},{"start":{"line":172,"column":4},"end":{"line":174,"column":5}}],"line":172},"14":{"loc":{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":175,"column":4},"end":{"line":177,"column":5}},{"start":{"line":175,"column":4},"end":{"line":177,"column":5}}],"line":175},"15":{"loc":{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},"type":"if","locations":[{"start":{"line":178,"column":4},"end":{"line":180,"column":5}},{"start":{"line":178,"column":4},"end":{"line":180,"column":5}}],"line":178},"16":{"loc":{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},"type":"if","locations":[{"start":{"line":181,"column":4},"end":{"line":188,"column":5}},{"start":{"line":181,"column":4},"end":{"line":188,"column":5}}],"line":181},"17":{"loc":{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},"type":"if","locations":[{"start":{"line":182,"column":6},"end":{"line":186,"column":7}},{"start":{"line":182,"column":6},"end":{"line":186,"column":7}}],"line":182},"18":{"loc":{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},"type":"if","locations":[{"start":{"line":189,"column":4},"end":{"line":200,"column":5}},{"start":{"line":189,"column":4},"end":{"line":200,"column":5}}],"line":189},"19":{"loc":{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},"type":"if","locations":[{"start":{"line":191,"column":8},"end":{"line":195,"column":9}},{"start":{"line":191,"column":8},"end":{"line":195,"column":9}}],"line":191},"20":{"loc":{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},"type":"if","locations":[{"start":{"line":215,"column":4},"end":{"line":217,"column":5}},{"start":{"line":215,"column":4},"end":{"line":217,"column":5}}],"line":215},"21":{"loc":{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},"type":"if","locations":[{"start":{"line":218,"column":4},"end":{"line":222,"column":5}},{"start":{"line":218,"column":4},"end":{"line":222,"column":5}}],"line":218},"22":{"loc":{"start":{"line":218,"column":8},"end":{"line":218,"column":86}},"type":"binary-expr","locations":[{"start":{"line":218,"column":8},"end":{"line":218,"column":32}},{"start":{"line":218,"column":36},"end":{"line":218,"column":86}}],"line":218}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":2,"6":1,"7":1,"8":1,"9":2,"10":2,"11":2,"12":2,"13":2,"14":1,"15":1,"16":1,"17":1,"18":1,"19":0,"20":0,"21":0,"22":4,"23":0,"24":4,"25":4,"26":4,"27":1,"28":3,"29":2,"30":1,"31":1,"32":0,"33":0,"34":3,"35":3,"36":3,"37":0,"38":0,"39":0,"40":0,"41":0,"42":3,"43":3,"44":3,"45":3,"46":3,"47":0,"48":7,"49":7,"50":1,"51":7,"52":1,"53":6,"54":1,"55":4,"56":2,"57":1,"58":1,"59":2,"60":2,"61":2,"62":1,"63":1,"64":0,"65":1,"66":4,"67":4,"68":1,"69":4,"70":1,"71":2,"72":2,"73":0,"74":1,"75":1},"f":{"0":2,"1":2,"2":1,"3":1,"4":0,"5":0,"6":4,"7":4,"8":1,"9":0,"10":0,"11":3,"12":0,"13":0,"14":3,"15":0,"16":7,"17":7,"18":2,"19":0,"20":1,"21":4,"22":4,"23":2,"24":0,"25":1},"b":{"0":[0,2],"1":[2,2],"2":[1,1],"3":[1,0],"4":[0,4],"5":[1,3],"6":[2,1],"7":[1,0],"8":[1,1],"9":[1,1],"10":[1,1],"11":[0,3],"12":[3,0],"13":[1,6],"14":[1,6],"15":[1,4],"16":[2,2],"17":[1,1],"18":[2,0],"19":[1,1],"20":[1,3],"21":[1,2],"22":[4,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0a4bf26938869e9b89bab568412c349bc1ff0083","contentHash":"deda95ed23abba3b13e7ef198467fe3e_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/routes/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":15},"end":{"line":7,"column":33}},"2":{"start":{"line":9,"column":16},"end":{"line":9,"column":48}},"3":{"start":{"line":11,"column":13},"end":{"line":11,"column":44}},"4":{"start":{"line":13,"column":14},"end":{"line":13,"column":44}},"5":{"start":{"line":15,"column":12},"end":{"line":15,"column":42}},"6":{"start":{"line":17,"column":13},"end":{"line":17,"column":42}},"7":{"start":{"line":19,"column":39},"end":{"line":19,"column":93}},"8":{"start":{"line":21,"column":13},"end":{"line":21,"column":39}},"9":{"start":{"line":23,"column":0},"end":{"line":28,"column":90}},"10":{"start":{"line":30,"column":0},"end":{"line":38,"column":92}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":25}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":19,"column":9},"end":{"line":19,"column":31}},"loc":{"start":{"line":19,"column":37},"end":{"line":19,"column":95}},"line":19}},"branchMap":{"0":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":92}},"type":"cond-expr","locations":[{"start":{"line":19,"column":70},"end":{"line":19,"column":73}},{"start":{"line":19,"column":76},"end":{"line":19,"column":92}}],"line":19},"1":{"loc":{"start":{"line":19,"column":46},"end":{"line":19,"column":67}},"type":"binary-expr","locations":[{"start":{"line":19,"column":46},"end":{"line":19,"column":49}},{"start":{"line":19,"column":53},"end":{"line":19,"column":67}}],"line":19}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":3,"8":1,"9":1,"10":1,"11":1},"f":{"0":3},"b":{"0":[2,1],"1":[3,3]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"63a3e651f707e94ed97ec659690592a0c340c6bd","contentHash":"85e8e83b7f1e99d944d489a44ed72bce_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/controllers/roles.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":6,"column":13},"end":{"line":6,"column":33}},"2":{"start":{"line":8,"column":11},"end":{"line":8,"column":22}},"3":{"start":{"line":17,"column":2},"end":{"line":17,"column":53}},"4":{"start":{"line":19,"column":15},"end":{"line":19,"column":37}},"5":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"6":{"start":{"line":21,"column":4},"end":{"line":21,"column":45}},"7":{"start":{"line":23,"column":4},"end":{"line":40,"column":7}},"8":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"9":{"start":{"line":27,"column":8},"end":{"line":36,"column":11}},"10":{"start":{"line":30,"column":10},"end":{"line":33,"column":13}},"11":{"start":{"line":35,"column":10},"end":{"line":35,"column":33}},"12":{"start":{"line":39,"column":6},"end":{"line":39,"column":29}},"13":{"start":{"line":51,"column":2},"end":{"line":55,"column":5}},"14":{"start":{"line":52,"column":4},"end":{"line":52,"column":38}},"15":{"start":{"line":54,"column":4},"end":{"line":54,"column":27}},"16":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"17":{"start":{"line":66,"column":4},"end":{"line":68,"column":7}},"18":{"start":{"line":70,"column":4},"end":{"line":79,"column":7}},"19":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"20":{"start":{"line":72,"column":8},"end":{"line":74,"column":11}},"21":{"start":{"line":76,"column":6},"end":{"line":76,"column":33}},"22":{"start":{"line":78,"column":6},"end":{"line":78,"column":41}},"23":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"24":{"start":{"line":91,"column":4},"end":{"line":91,"column":90}},"25":{"start":{"line":93,"column":2},"end":{"line":111,"column":5}},"26":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"27":{"start":{"line":95,"column":6},"end":{"line":97,"column":9}},"28":{"start":{"line":99,"column":4},"end":{"line":108,"column":7}},"29":{"start":{"line":102,"column":6},"end":{"line":105,"column":9}},"30":{"start":{"line":107,"column":6},"end":{"line":107,"column":41}},"31":{"start":{"line":110,"column":4},"end":{"line":110,"column":39}},"32":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"33":{"start":{"line":122,"column":4},"end":{"line":122,"column":90}},"34":{"start":{"line":124,"column":2},"end":{"line":139,"column":5}},"35":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"36":{"start":{"line":126,"column":6},"end":{"line":128,"column":9}},"37":{"start":{"line":130,"column":4},"end":{"line":136,"column":7}},"38":{"start":{"line":131,"column":6},"end":{"line":133,"column":9}},"39":{"start":{"line":135,"column":6},"end":{"line":135,"column":41}},"40":{"start":{"line":138,"column":4},"end":{"line":138,"column":27}},"41":{"start":{"line":142,"column":0},"end":{"line":142,"column":133}}},"fnMap":{"0":{"name":"createRole","decl":{"start":{"line":16,"column":9},"end":{"line":16,"column":19}},"loc":{"start":{"line":16,"column":30},"end":{"line":42,"column":1}},"line":16},"1":{"name":"(anonymous_1)","decl":{"start":{"line":25,"column":12},"end":{"line":25,"column":13}},"loc":{"start":{"line":25,"column":41},"end":{"line":38,"column":5}},"line":25},"2":{"name":"(anonymous_2)","decl":{"start":{"line":29,"column":16},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":32},"end":{"line":34,"column":9}},"line":29},"3":{"name":"(anonymous_3)","decl":{"start":{"line":34,"column":17},"end":{"line":34,"column":18}},"loc":{"start":{"line":34,"column":34},"end":{"line":36,"column":9}},"line":34},"4":{"name":"(anonymous_4)","decl":{"start":{"line":38,"column":13},"end":{"line":38,"column":14}},"loc":{"start":{"line":38,"column":30},"end":{"line":40,"column":5}},"line":38},"5":{"name":"getRoles","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":17}},"loc":{"start":{"line":50,"column":28},"end":{"line":56,"column":1}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":51,"column":29},"end":{"line":51,"column":30}},"loc":{"start":{"line":51,"column":45},"end":{"line":53,"column":3}},"line":51},"7":{"name":"(anonymous_7)","decl":{"start":{"line":53,"column":11},"end":{"line":53,"column":12}},"loc":{"start":{"line":53,"column":28},"end":{"line":55,"column":3}},"line":53},"8":{"name":"findRole","decl":{"start":{"line":64,"column":9},"end":{"line":64,"column":17}},"loc":{"start":{"line":64,"column":28},"end":{"line":81,"column":1}},"line":64},"9":{"name":"(anonymous_9)","decl":{"start":{"line":70,"column":38},"end":{"line":70,"column":39}},"loc":{"start":{"line":70,"column":54},"end":{"line":77,"column":5}},"line":70},"10":{"name":"(anonymous_10)","decl":{"start":{"line":77,"column":13},"end":{"line":77,"column":14}},"loc":{"start":{"line":77,"column":30},"end":{"line":79,"column":5}},"line":77},"11":{"name":"updateRole","decl":{"start":{"line":89,"column":9},"end":{"line":89,"column":19}},"loc":{"start":{"line":89,"column":30},"end":{"line":112,"column":1}},"line":89},"12":{"name":"(anonymous_12)","decl":{"start":{"line":93,"column":43},"end":{"line":93,"column":44}},"loc":{"start":{"line":93,"column":59},"end":{"line":109,"column":3}},"line":93},"13":{"name":"(anonymous_13)","decl":{"start":{"line":101,"column":12},"end":{"line":101,"column":13}},"loc":{"start":{"line":101,"column":24},"end":{"line":106,"column":5}},"line":101},"14":{"name":"(anonymous_14)","decl":{"start":{"line":106,"column":13},"end":{"line":106,"column":14}},"loc":{"start":{"line":106,"column":30},"end":{"line":108,"column":5}},"line":106},"15":{"name":"(anonymous_15)","decl":{"start":{"line":109,"column":11},"end":{"line":109,"column":12}},"loc":{"start":{"line":109,"column":28},"end":{"line":111,"column":3}},"line":109},"16":{"name":"deleteRole","decl":{"start":{"line":120,"column":9},"end":{"line":120,"column":19}},"loc":{"start":{"line":120,"column":30},"end":{"line":140,"column":1}},"line":120},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":43},"end":{"line":124,"column":44}},"loc":{"start":{"line":124,"column":59},"end":{"line":137,"column":3}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":130,"column":31},"end":{"line":130,"column":32}},"loc":{"start":{"line":130,"column":43},"end":{"line":134,"column":5}},"line":130},"19":{"name":"(anonymous_19)","decl":{"start":{"line":134,"column":13},"end":{"line":134,"column":14}},"loc":{"start":{"line":134,"column":30},"end":{"line":136,"column":5}},"line":134},"20":{"name":"(anonymous_20)","decl":{"start":{"line":137,"column":11},"end":{"line":137,"column":12}},"loc":{"start":{"line":137,"column":28},"end":{"line":139,"column":3}},"line":137}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},"type":"if","locations":[{"start":{"line":20,"column":2},"end":{"line":41,"column":3}},{"start":{"line":20,"column":2},"end":{"line":41,"column":3}}],"line":20},"1":{"loc":{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},"type":"if","locations":[{"start":{"line":26,"column":6},"end":{"line":37,"column":7}},{"start":{"line":26,"column":6},"end":{"line":37,"column":7}}],"line":26},"2":{"loc":{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},"type":"if","locations":[{"start":{"line":65,"column":2},"end":{"line":80,"column":3}},{"start":{"line":65,"column":2},"end":{"line":80,"column":3}}],"line":65},"3":{"loc":{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},"type":"if","locations":[{"start":{"line":71,"column":6},"end":{"line":75,"column":7}},{"start":{"line":71,"column":6},"end":{"line":75,"column":7}}],"line":71},"4":{"loc":{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},"type":"if","locations":[{"start":{"line":90,"column":2},"end":{"line":92,"column":3}},{"start":{"line":90,"column":2},"end":{"line":92,"column":3}}],"line":90},"5":{"loc":{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":98,"column":5}},{"start":{"line":94,"column":4},"end":{"line":98,"column":5}}],"line":94},"6":{"loc":{"start":{"line":100,"column":13},"end":{"line":100,"column":41}},"type":"binary-expr","locations":[{"start":{"line":100,"column":13},"end":{"line":100,"column":27}},{"start":{"line":100,"column":31},"end":{"line":100,"column":41}}],"line":100},"7":{"loc":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"type":"if","locations":[{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},{"start":{"line":121,"column":2},"end":{"line":123,"column":3}}],"line":121},"8":{"loc":{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},"type":"if","locations":[{"start":{"line":125,"column":4},"end":{"line":129,"column":5}},{"start":{"line":125,"column":4},"end":{"line":129,"column":5}}],"line":125}},"s":{"0":1,"1":1,"2":1,"3":2,"4":2,"5":2,"6":0,"7":2,"8":2,"9":2,"10":2,"11":0,"12":0,"13":1,"14":1,"15":0,"16":4,"17":1,"18":3,"19":2,"20":1,"21":1,"22":1,"23":3,"24":0,"25":3,"26":2,"27":1,"28":1,"29":1,"30":0,"31":1,"32":3,"33":0,"34":3,"35":2,"36":1,"37":2,"38":0,"39":1,"40":2,"41":1},"f":{"0":2,"1":2,"2":2,"3":0,"4":0,"5":1,"6":1,"7":0,"8":4,"9":2,"10":1,"11":3,"12":2,"13":1,"14":0,"15":1,"16":3,"17":2,"18":0,"19":1,"20":2},"b":{"0":[0,2],"1":[2,0],"2":[1,3],"3":[1,1],"4":[0,3],"5":[1,1],"6":[1,0],"7":[0,3],"8":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"30145fbb54f2bf78417895e538ec3aa77aa3022b","contentHash":"d0043f60ddb6921c54c62da8d1dd2774_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/mockData.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/mockData.js","statementMap":{"0":{"start":{"line":3,"column":0},"end":{"line":5,"column":3}},"1":{"start":{"line":7,"column":14},"end":{"line":7,"column":31}},"2":{"start":{"line":9,"column":15},"end":{"line":9,"column":46}},"3":{"start":{"line":11,"column":39},"end":{"line":11,"column":93}},"4":{"start":{"line":13,"column":0},"end":{"line":13,"column":26}},"5":{"start":{"line":15,"column":0},"end":{"line":54,"column":2}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":11,"column":9},"end":{"line":11,"column":31}},"loc":{"start":{"line":11,"column":37},"end":{"line":11,"column":95}},"line":11}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":92}},"type":"cond-expr","locations":[{"start":{"line":11,"column":70},"end":{"line":11,"column":73}},{"start":{"line":11,"column":76},"end":{"line":11,"column":92}}],"line":11},"1":{"loc":{"start":{"line":11,"column":46},"end":{"line":11,"column":67}},"type":"binary-expr","locations":[{"start":{"line":11,"column":46},"end":{"line":11,"column":49}},{"start":{"line":11,"column":53},"end":{"line":11,"column":67}}],"line":11}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1},"f":{"0":1},"b":{"0":[0,1],"1":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d98249d31e680d6d366965e47d10adb45667b660","contentHash":"4139d04232af869ee8cdf30b358efd68_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/role.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/role.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":13},"end":{"line":31,"column":38}},"18":{"start":{"line":34,"column":0},"end":{"line":237,"column":3}},"19":{"start":{"line":35,"column":2},"end":{"line":40,"column":5}},"20":{"start":{"line":36,"column":4},"end":{"line":39,"column":7}},"21":{"start":{"line":37,"column":6},"end":{"line":37,"column":34}},"22":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}},"23":{"start":{"line":41,"column":2},"end":{"line":46,"column":5}},"24":{"start":{"line":42,"column":4},"end":{"line":45,"column":7}},"25":{"start":{"line":43,"column":6},"end":{"line":43,"column":33}},"26":{"start":{"line":44,"column":6},"end":{"line":44,"column":13}},"27":{"start":{"line":47,"column":2},"end":{"line":52,"column":5}},"28":{"start":{"line":48,"column":4},"end":{"line":51,"column":7}},"29":{"start":{"line":49,"column":6},"end":{"line":49,"column":39}},"30":{"start":{"line":50,"column":6},"end":{"line":50,"column":13}},"31":{"start":{"line":54,"column":2},"end":{"line":93,"column":5}},"32":{"start":{"line":55,"column":4},"end":{"line":64,"column":7}},"33":{"start":{"line":56,"column":6},"end":{"line":62,"column":9}},"34":{"start":{"line":57,"column":8},"end":{"line":57,"column":41}},"35":{"start":{"line":58,"column":8},"end":{"line":58,"column":43}},"36":{"start":{"line":59,"column":8},"end":{"line":59,"column":69}},"37":{"start":{"line":60,"column":8},"end":{"line":60,"column":50}},"38":{"start":{"line":61,"column":8},"end":{"line":61,"column":76}},"39":{"start":{"line":63,"column":6},"end":{"line":63,"column":13}},"40":{"start":{"line":65,"column":4},"end":{"line":73,"column":7}},"41":{"start":{"line":66,"column":6},"end":{"line":71,"column":9}},"42":{"start":{"line":67,"column":8},"end":{"line":67,"column":41}},"43":{"start":{"line":68,"column":8},"end":{"line":68,"column":43}},"44":{"start":{"line":69,"column":8},"end":{"line":69,"column":69}},"45":{"start":{"line":70,"column":8},"end":{"line":70,"column":50}},"46":{"start":{"line":72,"column":6},"end":{"line":72,"column":13}},"47":{"start":{"line":74,"column":4},"end":{"line":84,"column":7}},"48":{"start":{"line":75,"column":17},"end":{"line":77,"column":7}},"49":{"start":{"line":78,"column":6},"end":{"line":83,"column":9}},"50":{"start":{"line":79,"column":8},"end":{"line":79,"column":41}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":43}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":66}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":15}},"54":{"start":{"line":85,"column":4},"end":{"line":92,"column":7}},"55":{"start":{"line":86,"column":6},"end":{"line":91,"column":9}},"56":{"start":{"line":87,"column":8},"end":{"line":87,"column":41}},"57":{"start":{"line":88,"column":8},"end":{"line":88,"column":43}},"58":{"start":{"line":89,"column":8},"end":{"line":89,"column":69}},"59":{"start":{"line":90,"column":8},"end":{"line":90,"column":15}},"60":{"start":{"line":95,"column":2},"end":{"line":115,"column":5}},"61":{"start":{"line":96,"column":4},"end":{"line":107,"column":7}},"62":{"start":{"line":97,"column":6},"end":{"line":106,"column":9}},"63":{"start":{"line":98,"column":8},"end":{"line":98,"column":41}},"64":{"start":{"line":99,"column":8},"end":{"line":99,"column":43}},"65":{"start":{"line":100,"column":8},"end":{"line":100,"column":42}},"66":{"start":{"line":101,"column":8},"end":{"line":101,"column":41}},"67":{"start":{"line":102,"column":8},"end":{"line":102,"column":50}},"68":{"start":{"line":103,"column":8},"end":{"line":103,"column":41}},"69":{"start":{"line":104,"column":8},"end":{"line":104,"column":56}},"70":{"start":{"line":105,"column":8},"end":{"line":105,"column":15}},"71":{"start":{"line":108,"column":4},"end":{"line":114,"column":7}},"72":{"start":{"line":109,"column":6},"end":{"line":113,"column":9}},"73":{"start":{"line":110,"column":8},"end":{"line":110,"column":41}},"74":{"start":{"line":111,"column":8},"end":{"line":111,"column":66}},"75":{"start":{"line":112,"column":8},"end":{"line":112,"column":15}},"76":{"start":{"line":117,"column":2},"end":{"line":160,"column":5}},"77":{"start":{"line":118,"column":4},"end":{"line":127,"column":7}},"78":{"start":{"line":119,"column":15},"end":{"line":119,"column":16}},"79":{"start":{"line":120,"column":6},"end":{"line":126,"column":9}},"80":{"start":{"line":121,"column":8},"end":{"line":121,"column":41}},"81":{"start":{"line":122,"column":8},"end":{"line":122,"column":40}},"82":{"start":{"line":123,"column":8},"end":{"line":123,"column":53}},"83":{"start":{"line":124,"column":8},"end":{"line":124,"column":40}},"84":{"start":{"line":125,"column":8},"end":{"line":125,"column":15}},"85":{"start":{"line":128,"column":4},"end":{"line":135,"column":7}},"86":{"start":{"line":129,"column":15},"end":{"line":129,"column":16}},"87":{"start":{"line":130,"column":6},"end":{"line":134,"column":9}},"88":{"start":{"line":131,"column":8},"end":{"line":131,"column":41}},"89":{"start":{"line":132,"column":8},"end":{"line":132,"column":66}},"90":{"start":{"line":133,"column":8},"end":{"line":133,"column":15}},"91":{"start":{"line":136,"column":4},"end":{"line":143,"column":7}},"92":{"start":{"line":137,"column":15},"end":{"line":137,"column":27}},"93":{"start":{"line":138,"column":6},"end":{"line":142,"column":9}},"94":{"start":{"line":139,"column":8},"end":{"line":139,"column":41}},"95":{"start":{"line":140,"column":8},"end":{"line":140,"column":90}},"96":{"start":{"line":141,"column":8},"end":{"line":141,"column":15}},"97":{"start":{"line":144,"column":4},"end":{"line":151,"column":7}},"98":{"start":{"line":145,"column":15},"end":{"line":145,"column":18}},"99":{"start":{"line":146,"column":6},"end":{"line":150,"column":9}},"100":{"start":{"line":147,"column":8},"end":{"line":147,"column":41}},"101":{"start":{"line":148,"column":8},"end":{"line":148,"column":58}},"102":{"start":{"line":149,"column":8},"end":{"line":149,"column":15}},"103":{"start":{"line":152,"column":4},"end":{"line":159,"column":7}},"104":{"start":{"line":153,"column":15},"end":{"line":153,"column":36}},"105":{"start":{"line":154,"column":6},"end":{"line":158,"column":9}},"106":{"start":{"line":155,"column":8},"end":{"line":155,"column":41}},"107":{"start":{"line":156,"column":8},"end":{"line":156,"column":95}},"108":{"start":{"line":157,"column":8},"end":{"line":157,"column":15}},"109":{"start":{"line":161,"column":2},"end":{"line":199,"column":5}},"110":{"start":{"line":162,"column":4},"end":{"line":171,"column":7}},"111":{"start":{"line":163,"column":15},"end":{"line":163,"column":16}},"112":{"start":{"line":164,"column":6},"end":{"line":170,"column":9}},"113":{"start":{"line":165,"column":8},"end":{"line":165,"column":41}},"114":{"start":{"line":166,"column":8},"end":{"line":166,"column":43}},"115":{"start":{"line":167,"column":8},"end":{"line":167,"column":69}},"116":{"start":{"line":168,"column":8},"end":{"line":168,"column":50}},"117":{"start":{"line":169,"column":8},"end":{"line":169,"column":15}},"118":{"start":{"line":172,"column":4},"end":{"line":180,"column":7}},"119":{"start":{"line":173,"column":15},"end":{"line":173,"column":16}},"120":{"start":{"line":174,"column":6},"end":{"line":179,"column":9}},"121":{"start":{"line":175,"column":8},"end":{"line":175,"column":41}},"122":{"start":{"line":176,"column":8},"end":{"line":176,"column":43}},"123":{"start":{"line":177,"column":8},"end":{"line":177,"column":66}},"124":{"start":{"line":178,"column":8},"end":{"line":178,"column":15}},"125":{"start":{"line":181,"column":4},"end":{"line":189,"column":7}},"126":{"start":{"line":182,"column":15},"end":{"line":182,"column":18}},"127":{"start":{"line":183,"column":6},"end":{"line":188,"column":9}},"128":{"start":{"line":184,"column":8},"end":{"line":184,"column":41}},"129":{"start":{"line":185,"column":8},"end":{"line":185,"column":43}},"130":{"start":{"line":186,"column":8},"end":{"line":186,"column":60}},"131":{"start":{"line":187,"column":8},"end":{"line":187,"column":15}},"132":{"start":{"line":190,"column":4},"end":{"line":198,"column":7}},"133":{"start":{"line":191,"column":15},"end":{"line":191,"column":31}},"134":{"start":{"line":192,"column":6},"end":{"line":197,"column":9}},"135":{"start":{"line":193,"column":8},"end":{"line":193,"column":41}},"136":{"start":{"line":194,"column":8},"end":{"line":194,"column":43}},"137":{"start":{"line":195,"column":8},"end":{"line":195,"column":95}},"138":{"start":{"line":196,"column":8},"end":{"line":196,"column":15}},"139":{"start":{"line":200,"column":2},"end":{"line":236,"column":5}},"140":{"start":{"line":201,"column":4},"end":{"line":208,"column":7}},"141":{"start":{"line":202,"column":15},"end":{"line":202,"column":16}},"142":{"start":{"line":203,"column":6},"end":{"line":206,"column":9}},"143":{"start":{"line":204,"column":8},"end":{"line":204,"column":41}},"144":{"start":{"line":205,"column":8},"end":{"line":205,"column":43}},"145":{"start":{"line":207,"column":6},"end":{"line":207,"column":13}},"146":{"start":{"line":209,"column":4},"end":{"line":217,"column":7}},"147":{"start":{"line":210,"column":15},"end":{"line":210,"column":16}},"148":{"start":{"line":211,"column":6},"end":{"line":216,"column":9}},"149":{"start":{"line":212,"column":8},"end":{"line":212,"column":41}},"150":{"start":{"line":213,"column":8},"end":{"line":213,"column":43}},"151":{"start":{"line":214,"column":8},"end":{"line":214,"column":66}},"152":{"start":{"line":215,"column":8},"end":{"line":215,"column":15}},"153":{"start":{"line":218,"column":4},"end":{"line":226,"column":7}},"154":{"start":{"line":219,"column":15},"end":{"line":219,"column":18}},"155":{"start":{"line":220,"column":6},"end":{"line":225,"column":9}},"156":{"start":{"line":221,"column":8},"end":{"line":221,"column":41}},"157":{"start":{"line":222,"column":8},"end":{"line":222,"column":43}},"158":{"start":{"line":223,"column":8},"end":{"line":223,"column":60}},"159":{"start":{"line":224,"column":8},"end":{"line":224,"column":15}},"160":{"start":{"line":227,"column":4},"end":{"line":235,"column":7}},"161":{"start":{"line":228,"column":15},"end":{"line":228,"column":31}},"162":{"start":{"line":229,"column":6},"end":{"line":234,"column":9}},"163":{"start":{"line":230,"column":8},"end":{"line":230,"column":41}},"164":{"start":{"line":231,"column":8},"end":{"line":231,"column":43}},"165":{"start":{"line":232,"column":8},"end":{"line":232,"column":95}},"166":{"start":{"line":233,"column":8},"end":{"line":233,"column":15}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":34,"column":18},"end":{"line":34,"column":19}},"loc":{"start":{"line":34,"column":30},"end":{"line":237,"column":1}},"line":34},"2":{"name":"(anonymous_2)","decl":{"start":{"line":35,"column":9},"end":{"line":35,"column":10}},"loc":{"start":{"line":35,"column":25},"end":{"line":40,"column":3}},"line":35},"3":{"name":"(anonymous_3)","decl":{"start":{"line":36,"column":90},"end":{"line":36,"column":91}},"loc":{"start":{"line":36,"column":110},"end":{"line":39,"column":5}},"line":36},"4":{"name":"(anonymous_4)","decl":{"start":{"line":41,"column":9},"end":{"line":41,"column":10}},"loc":{"start":{"line":41,"column":25},"end":{"line":46,"column":3}},"line":41},"5":{"name":"(anonymous_5)","decl":{"start":{"line":42,"column":91},"end":{"line":42,"column":92}},"loc":{"start":{"line":42,"column":111},"end":{"line":45,"column":5}},"line":42},"6":{"name":"(anonymous_6)","decl":{"start":{"line":47,"column":9},"end":{"line":47,"column":10}},"loc":{"start":{"line":47,"column":25},"end":{"line":52,"column":3}},"line":47},"7":{"name":"(anonymous_7)","decl":{"start":{"line":48,"column":136},"end":{"line":48,"column":137}},"loc":{"start":{"line":48,"column":156},"end":{"line":51,"column":5}},"line":48},"8":{"name":"(anonymous_8)","decl":{"start":{"line":54,"column":25},"end":{"line":54,"column":26}},"loc":{"start":{"line":54,"column":37},"end":{"line":93,"column":3}},"line":54},"9":{"name":"(anonymous_9)","decl":{"start":{"line":55,"column":56},"end":{"line":55,"column":57}},"loc":{"start":{"line":55,"column":72},"end":{"line":64,"column":5}},"line":55},"10":{"name":"(anonymous_10)","decl":{"start":{"line":56,"column":136},"end":{"line":56,"column":137}},"loc":{"start":{"line":56,"column":156},"end":{"line":62,"column":7}},"line":56},"11":{"name":"(anonymous_11)","decl":{"start":{"line":65,"column":56},"end":{"line":65,"column":57}},"loc":{"start":{"line":65,"column":72},"end":{"line":73,"column":5}},"line":65},"12":{"name":"(anonymous_12)","decl":{"start":{"line":66,"column":133},"end":{"line":66,"column":134}},"loc":{"start":{"line":66,"column":153},"end":{"line":71,"column":7}},"line":66},"13":{"name":"(anonymous_13)","decl":{"start":{"line":74,"column":61},"end":{"line":74,"column":62}},"loc":{"start":{"line":74,"column":77},"end":{"line":84,"column":5}},"line":74},"14":{"name":"(anonymous_14)","decl":{"start":{"line":78,"column":120},"end":{"line":78,"column":121}},"loc":{"start":{"line":78,"column":140},"end":{"line":83,"column":7}},"line":78},"15":{"name":"(anonymous_15)","decl":{"start":{"line":85,"column":62},"end":{"line":85,"column":63}},"loc":{"start":{"line":85,"column":78},"end":{"line":92,"column":5}},"line":85},"16":{"name":"(anonymous_16)","decl":{"start":{"line":86,"column":131},"end":{"line":86,"column":132}},"loc":{"start":{"line":86,"column":151},"end":{"line":91,"column":7}},"line":86},"17":{"name":"(anonymous_17)","decl":{"start":{"line":95,"column":24},"end":{"line":95,"column":25}},"loc":{"start":{"line":95,"column":36},"end":{"line":115,"column":3}},"line":95},"18":{"name":"(anonymous_18)","decl":{"start":{"line":96,"column":59},"end":{"line":96,"column":60}},"loc":{"start":{"line":96,"column":75},"end":{"line":107,"column":5}},"line":96},"19":{"name":"(anonymous_19)","decl":{"start":{"line":97,"column":106},"end":{"line":97,"column":107}},"loc":{"start":{"line":97,"column":126},"end":{"line":106,"column":7}},"line":97},"20":{"name":"(anonymous_20)","decl":{"start":{"line":108,"column":64},"end":{"line":108,"column":65}},"loc":{"start":{"line":108,"column":80},"end":{"line":114,"column":5}},"line":108},"21":{"name":"(anonymous_21)","decl":{"start":{"line":109,"column":105},"end":{"line":109,"column":106}},"loc":{"start":{"line":109,"column":125},"end":{"line":113,"column":7}},"line":109},"22":{"name":"(anonymous_22)","decl":{"start":{"line":117,"column":28},"end":{"line":117,"column":29}},"loc":{"start":{"line":117,"column":40},"end":{"line":160,"column":3}},"line":117},"23":{"name":"(anonymous_23)","decl":{"start":{"line":118,"column":58},"end":{"line":118,"column":59}},"loc":{"start":{"line":118,"column":74},"end":{"line":127,"column":5}},"line":118},"24":{"name":"(anonymous_24)","decl":{"start":{"line":120,"column":112},"end":{"line":120,"column":113}},"loc":{"start":{"line":120,"column":132},"end":{"line":126,"column":7}},"line":120},"25":{"name":"(anonymous_25)","decl":{"start":{"line":128,"column":70},"end":{"line":128,"column":71}},"loc":{"start":{"line":128,"column":86},"end":{"line":135,"column":5}},"line":128},"26":{"name":"(anonymous_26)","decl":{"start":{"line":130,"column":111},"end":{"line":130,"column":112}},"loc":{"start":{"line":130,"column":131},"end":{"line":134,"column":7}},"line":130},"27":{"name":"(anonymous_27)","decl":{"start":{"line":136,"column":78},"end":{"line":136,"column":79}},"loc":{"start":{"line":136,"column":94},"end":{"line":143,"column":5}},"line":136},"28":{"name":"(anonymous_28)","decl":{"start":{"line":138,"column":112},"end":{"line":138,"column":113}},"loc":{"start":{"line":138,"column":132},"end":{"line":142,"column":7}},"line":138},"29":{"name":"(anonymous_29)","decl":{"start":{"line":144,"column":69},"end":{"line":144,"column":70}},"loc":{"start":{"line":144,"column":85},"end":{"line":151,"column":5}},"line":144},"30":{"name":"(anonymous_30)","decl":{"start":{"line":146,"column":112},"end":{"line":146,"column":113}},"loc":{"start":{"line":146,"column":132},"end":{"line":150,"column":7}},"line":146},"31":{"name":"(anonymous_31)","decl":{"start":{"line":152,"column":68},"end":{"line":152,"column":69}},"loc":{"start":{"line":152,"column":84},"end":{"line":159,"column":5}},"line":152},"32":{"name":"(anonymous_32)","decl":{"start":{"line":154,"column":112},"end":{"line":154,"column":113}},"loc":{"start":{"line":154,"column":132},"end":{"line":158,"column":7}},"line":154},"33":{"name":"(anonymous_33)","decl":{"start":{"line":161,"column":28},"end":{"line":161,"column":29}},"loc":{"start":{"line":161,"column":40},"end":{"line":199,"column":3}},"line":161},"34":{"name":"(anonymous_34)","decl":{"start":{"line":162,"column":66},"end":{"line":162,"column":67}},"loc":{"start":{"line":162,"column":82},"end":{"line":171,"column":5}},"line":162},"35":{"name":"(anonymous_35)","decl":{"start":{"line":164,"column":144},"end":{"line":164,"column":145}},"loc":{"start":{"line":164,"column":164},"end":{"line":170,"column":7}},"line":164},"36":{"name":"(anonymous_36)","decl":{"start":{"line":172,"column":77},"end":{"line":172,"column":78}},"loc":{"start":{"line":172,"column":93},"end":{"line":180,"column":5}},"line":172},"37":{"name":"(anonymous_37)","decl":{"start":{"line":174,"column":135},"end":{"line":174,"column":136}},"loc":{"start":{"line":174,"column":155},"end":{"line":179,"column":7}},"line":174},"38":{"name":"(anonymous_38)","decl":{"start":{"line":181,"column":90},"end":{"line":181,"column":91}},"loc":{"start":{"line":181,"column":106},"end":{"line":189,"column":5}},"line":181},"39":{"name":"(anonymous_39)","decl":{"start":{"line":183,"column":136},"end":{"line":183,"column":137}},"loc":{"start":{"line":183,"column":156},"end":{"line":188,"column":7}},"line":183},"40":{"name":"(anonymous_40)","decl":{"start":{"line":190,"column":96},"end":{"line":190,"column":97}},"loc":{"start":{"line":190,"column":112},"end":{"line":198,"column":5}},"line":190},"41":{"name":"(anonymous_41)","decl":{"start":{"line":192,"column":139},"end":{"line":192,"column":140}},"loc":{"start":{"line":192,"column":159},"end":{"line":197,"column":7}},"line":192},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":31},"end":{"line":200,"column":32}},"loc":{"start":{"line":200,"column":43},"end":{"line":236,"column":3}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":201,"column":63},"end":{"line":201,"column":64}},"loc":{"start":{"line":201,"column":79},"end":{"line":208,"column":5}},"line":201},"44":{"name":"(anonymous_44)","decl":{"start":{"line":203,"column":115},"end":{"line":203,"column":116}},"loc":{"start":{"line":203,"column":135},"end":{"line":206,"column":7}},"line":203},"45":{"name":"(anonymous_45)","decl":{"start":{"line":209,"column":74},"end":{"line":209,"column":75}},"loc":{"start":{"line":209,"column":90},"end":{"line":217,"column":5}},"line":209},"46":{"name":"(anonymous_46)","decl":{"start":{"line":211,"column":114},"end":{"line":211,"column":115}},"loc":{"start":{"line":211,"column":134},"end":{"line":216,"column":7}},"line":211},"47":{"name":"(anonymous_47)","decl":{"start":{"line":218,"column":79},"end":{"line":218,"column":80}},"loc":{"start":{"line":218,"column":95},"end":{"line":226,"column":5}},"line":218},"48":{"name":"(anonymous_48)","decl":{"start":{"line":220,"column":115},"end":{"line":220,"column":116}},"loc":{"start":{"line":220,"column":135},"end":{"line":225,"column":7}},"line":220},"49":{"name":"(anonymous_49)","decl":{"start":{"line":227,"column":99},"end":{"line":227,"column":100}},"loc":{"start":{"line":227,"column":115},"end":{"line":235,"column":5}},"line":227},"50":{"name":"(anonymous_50)","decl":{"start":{"line":229,"column":115},"end":{"line":229,"column":116}},"loc":{"start":{"line":229,"column":135},"end":{"line":234,"column":7}},"line":229}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":0,"44":0,"45":0,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":0,"56":0,"57":0,"58":0,"59":0,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":0,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":1,"124":1,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":1,"140":1,"141":1,"142":1,"143":1,"144":0,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":0},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":0,"16":0,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"b6d3d728e746d8f6bf90308417d5883dc86931ef","contentHash":"5d2462fcad3bc8d205ae464d4bb3ea35_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/search.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/search.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":0},"end":{"line":25,"column":30}},"12":{"start":{"line":27,"column":13},"end":{"line":27,"column":34}},"13":{"start":{"line":28,"column":0},"end":{"line":28,"column":39}},"14":{"start":{"line":29,"column":16},"end":{"line":29,"column":22}},"15":{"start":{"line":30,"column":17},"end":{"line":30,"column":23}},"16":{"start":{"line":31,"column":22},"end":{"line":31,"column":28}},"17":{"start":{"line":32,"column":12},"end":{"line":32,"column":36}},"18":{"start":{"line":33,"column":13},"end":{"line":33,"column":38}},"19":{"start":{"line":36,"column":0},"end":{"line":100,"column":3}},"20":{"start":{"line":37,"column":2},"end":{"line":42,"column":5}},"21":{"start":{"line":38,"column":4},"end":{"line":41,"column":7}},"22":{"start":{"line":39,"column":6},"end":{"line":39,"column":34}},"23":{"start":{"line":40,"column":6},"end":{"line":40,"column":13}},"24":{"start":{"line":43,"column":2},"end":{"line":48,"column":5}},"25":{"start":{"line":44,"column":4},"end":{"line":47,"column":7}},"26":{"start":{"line":45,"column":6},"end":{"line":45,"column":33}},"27":{"start":{"line":46,"column":6},"end":{"line":46,"column":13}},"28":{"start":{"line":49,"column":2},"end":{"line":54,"column":5}},"29":{"start":{"line":50,"column":4},"end":{"line":53,"column":7}},"30":{"start":{"line":51,"column":6},"end":{"line":51,"column":39}},"31":{"start":{"line":52,"column":6},"end":{"line":52,"column":13}},"32":{"start":{"line":56,"column":2},"end":{"line":72,"column":5}},"33":{"start":{"line":57,"column":4},"end":{"line":63,"column":7}},"34":{"start":{"line":58,"column":18},"end":{"line":58,"column":20}},"35":{"start":{"line":59,"column":6},"end":{"line":62,"column":9}},"36":{"start":{"line":60,"column":8},"end":{"line":60,"column":41}},"37":{"start":{"line":61,"column":8},"end":{"line":61,"column":64}},"38":{"start":{"line":64,"column":4},"end":{"line":71,"column":7}},"39":{"start":{"line":65,"column":18},"end":{"line":65,"column":24}},"40":{"start":{"line":66,"column":6},"end":{"line":70,"column":9}},"41":{"start":{"line":67,"column":8},"end":{"line":67,"column":41}},"42":{"start":{"line":68,"column":8},"end":{"line":68,"column":53}},"43":{"start":{"line":69,"column":8},"end":{"line":69,"column":52}},"44":{"start":{"line":73,"column":2},"end":{"line":99,"column":5}},"45":{"start":{"line":74,"column":4},"end":{"line":80,"column":7}},"46":{"start":{"line":75,"column":18},"end":{"line":75,"column":20}},"47":{"start":{"line":76,"column":6},"end":{"line":79,"column":9}},"48":{"start":{"line":77,"column":8},"end":{"line":77,"column":41}},"49":{"start":{"line":78,"column":8},"end":{"line":78,"column":86}},"50":{"start":{"line":81,"column":4},"end":{"line":91,"column":7}},"51":{"start":{"line":82,"column":18},"end":{"line":82,"column":24}},"52":{"start":{"line":83,"column":6},"end":{"line":90,"column":9}},"53":{"start":{"line":84,"column":8},"end":{"line":84,"column":41}},"54":{"start":{"line":85,"column":8},"end":{"line":85,"column":54}},"55":{"start":{"line":86,"column":8},"end":{"line":86,"column":84}},"56":{"start":{"line":87,"column":8},"end":{"line":87,"column":96}},"57":{"start":{"line":88,"column":8},"end":{"line":88,"column":56}},"58":{"start":{"line":89,"column":8},"end":{"line":89,"column":78}},"59":{"start":{"line":92,"column":4},"end":{"line":98,"column":7}},"60":{"start":{"line":93,"column":18},"end":{"line":93,"column":22}},"61":{"start":{"line":94,"column":6},"end":{"line":97,"column":9}},"62":{"start":{"line":95,"column":8},"end":{"line":95,"column":41}},"63":{"start":{"line":96,"column":8},"end":{"line":96,"column":84}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":36,"column":19},"end":{"line":36,"column":20}},"loc":{"start":{"line":36,"column":31},"end":{"line":100,"column":1}},"line":36},"2":{"name":"(anonymous_2)","decl":{"start":{"line":37,"column":9},"end":{"line":37,"column":10}},"loc":{"start":{"line":37,"column":25},"end":{"line":42,"column":3}},"line":37},"3":{"name":"(anonymous_3)","decl":{"start":{"line":38,"column":90},"end":{"line":38,"column":91}},"loc":{"start":{"line":38,"column":110},"end":{"line":41,"column":5}},"line":38},"4":{"name":"(anonymous_4)","decl":{"start":{"line":43,"column":9},"end":{"line":43,"column":10}},"loc":{"start":{"line":43,"column":25},"end":{"line":48,"column":3}},"line":43},"5":{"name":"(anonymous_5)","decl":{"start":{"line":44,"column":91},"end":{"line":44,"column":92}},"loc":{"start":{"line":44,"column":111},"end":{"line":47,"column":5}},"line":44},"6":{"name":"(anonymous_6)","decl":{"start":{"line":49,"column":9},"end":{"line":49,"column":10}},"loc":{"start":{"line":49,"column":25},"end":{"line":54,"column":3}},"line":49},"7":{"name":"(anonymous_7)","decl":{"start":{"line":50,"column":136},"end":{"line":50,"column":137}},"loc":{"start":{"line":50,"column":156},"end":{"line":53,"column":5}},"line":50},"8":{"name":"(anonymous_8)","decl":{"start":{"line":56,"column":38},"end":{"line":56,"column":39}},"loc":{"start":{"line":56,"column":50},"end":{"line":72,"column":3}},"line":56},"9":{"name":"(anonymous_9)","decl":{"start":{"line":57,"column":63},"end":{"line":57,"column":64}},"loc":{"start":{"line":57,"column":75},"end":{"line":63,"column":5}},"line":57},"10":{"name":"(anonymous_10)","decl":{"start":{"line":59,"column":126},"end":{"line":59,"column":127}},"loc":{"start":{"line":59,"column":146},"end":{"line":62,"column":7}},"line":59},"11":{"name":"(anonymous_11)","decl":{"start":{"line":64,"column":76},"end":{"line":64,"column":77}},"loc":{"start":{"line":64,"column":88},"end":{"line":71,"column":5}},"line":64},"12":{"name":"(anonymous_12)","decl":{"start":{"line":66,"column":126},"end":{"line":66,"column":127}},"loc":{"start":{"line":66,"column":146},"end":{"line":70,"column":7}},"line":66},"13":{"name":"(anonymous_13)","decl":{"start":{"line":73,"column":36},"end":{"line":73,"column":37}},"loc":{"start":{"line":73,"column":48},"end":{"line":99,"column":3}},"line":73},"14":{"name":"(anonymous_14)","decl":{"start":{"line":74,"column":63},"end":{"line":74,"column":64}},"loc":{"start":{"line":74,"column":75},"end":{"line":80,"column":5}},"line":74},"15":{"name":"(anonymous_15)","decl":{"start":{"line":76,"column":129},"end":{"line":76,"column":130}},"loc":{"start":{"line":76,"column":149},"end":{"line":79,"column":7}},"line":76},"16":{"name":"(anonymous_16)","decl":{"start":{"line":81,"column":67},"end":{"line":81,"column":68}},"loc":{"start":{"line":81,"column":79},"end":{"line":91,"column":5}},"line":81},"17":{"name":"(anonymous_17)","decl":{"start":{"line":83,"column":130},"end":{"line":83,"column":131}},"loc":{"start":{"line":83,"column":150},"end":{"line":90,"column":7}},"line":83},"18":{"name":"(anonymous_18)","decl":{"start":{"line":92,"column":70},"end":{"line":92,"column":71}},"loc":{"start":{"line":92,"column":82},"end":{"line":98,"column":5}},"line":92},"19":{"name":"(anonymous_19)","decl":{"start":{"line":94,"column":130},"end":{"line":94,"column":131}},"loc":{"start":{"line":94,"column":150},"end":{"line":97,"column":7}},"line":94}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":0,"38":1,"39":1,"40":1,"41":1,"42":0,"43":0,"44":1,"45":1,"46":1,"47":1,"48":1,"49":0,"50":1,"51":1,"52":1,"53":1,"54":0,"55":0,"56":0,"57":0,"58":0,"59":1,"60":1,"61":1,"62":1,"63":0},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"1cefcdc6ec733ba336232f4e731e671c109981d4","contentHash":"c9ee84a134872aeb8ff7858e8ade4eb1_11.0.3"},"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/user.spec.js":{"path":"/Users/andeladeveloper/Documents/projects/document-manager/server/test/controllers/user.spec.js","statementMap":{"0":{"start":{"line":3,"column":12},"end":{"line":3,"column":27}},"1":{"start":{"line":5,"column":13},"end":{"line":5,"column":42}},"2":{"start":{"line":7,"column":17},"end":{"line":7,"column":37}},"3":{"start":{"line":9,"column":18},"end":{"line":9,"column":52}},"4":{"start":{"line":11,"column":16},"end":{"line":11,"column":36}},"5":{"start":{"line":13,"column":17},"end":{"line":13,"column":50}},"6":{"start":{"line":15,"column":13},"end":{"line":15,"column":38}},"7":{"start":{"line":17,"column":14},"end":{"line":17,"column":44}},"8":{"start":{"line":19,"column":16},"end":{"line":19,"column":37}},"9":{"start":{"line":21,"column":17},"end":{"line":21,"column":50}},"10":{"start":{"line":23,"column":39},"end":{"line":23,"column":93}},"11":{"start":{"line":25,"column":13},"end":{"line":25,"column":34}},"12":{"start":{"line":26,"column":0},"end":{"line":26,"column":39}},"13":{"start":{"line":27,"column":16},"end":{"line":27,"column":22}},"14":{"start":{"line":28,"column":17},"end":{"line":28,"column":23}},"15":{"start":{"line":29,"column":22},"end":{"line":29,"column":28}},"16":{"start":{"line":30,"column":12},"end":{"line":30,"column":36}},"17":{"start":{"line":31,"column":15},"end":{"line":31,"column":42}},"18":{"start":{"line":32,"column":13},"end":{"line":32,"column":38}},"19":{"start":{"line":33,"column":12},"end":{"line":33,"column":36}},"20":{"start":{"line":34,"column":12},"end":{"line":34,"column":36}},"21":{"start":{"line":37,"column":0},"end":{"line":306,"column":3}},"22":{"start":{"line":38,"column":2},"end":{"line":43,"column":5}},"23":{"start":{"line":39,"column":4},"end":{"line":42,"column":7}},"24":{"start":{"line":40,"column":6},"end":{"line":40,"column":34}},"25":{"start":{"line":41,"column":6},"end":{"line":41,"column":13}},"26":{"start":{"line":44,"column":2},"end":{"line":49,"column":5}},"27":{"start":{"line":45,"column":4},"end":{"line":48,"column":7}},"28":{"start":{"line":46,"column":6},"end":{"line":46,"column":33}},"29":{"start":{"line":47,"column":6},"end":{"line":47,"column":13}},"30":{"start":{"line":50,"column":2},"end":{"line":55,"column":5}},"31":{"start":{"line":51,"column":4},"end":{"line":54,"column":7}},"32":{"start":{"line":52,"column":6},"end":{"line":52,"column":39}},"33":{"start":{"line":53,"column":6},"end":{"line":53,"column":13}},"34":{"start":{"line":57,"column":2},"end":{"line":305,"column":5}},"35":{"start":{"line":58,"column":4},"end":{"line":66,"column":7}},"36":{"start":{"line":59,"column":6},"end":{"line":65,"column":9}},"37":{"start":{"line":60,"column":8},"end":{"line":60,"column":41}},"38":{"start":{"line":61,"column":8},"end":{"line":61,"column":62}},"39":{"start":{"line":62,"column":8},"end":{"line":62,"column":82}},"40":{"start":{"line":63,"column":8},"end":{"line":63,"column":47}},"41":{"start":{"line":64,"column":8},"end":{"line":64,"column":15}},"42":{"start":{"line":68,"column":4},"end":{"line":76,"column":7}},"43":{"start":{"line":69,"column":6},"end":{"line":75,"column":9}},"44":{"start":{"line":70,"column":8},"end":{"line":70,"column":41}},"45":{"start":{"line":71,"column":8},"end":{"line":71,"column":62}},"46":{"start":{"line":72,"column":8},"end":{"line":72,"column":82}},"47":{"start":{"line":73,"column":8},"end":{"line":73,"column":47}},"48":{"start":{"line":74,"column":8},"end":{"line":74,"column":15}},"49":{"start":{"line":78,"column":4},"end":{"line":85,"column":7}},"50":{"start":{"line":79,"column":6},"end":{"line":84,"column":9}},"51":{"start":{"line":80,"column":8},"end":{"line":80,"column":41}},"52":{"start":{"line":81,"column":8},"end":{"line":81,"column":60}},"53":{"start":{"line":82,"column":8},"end":{"line":82,"column":46}},"54":{"start":{"line":83,"column":8},"end":{"line":83,"column":15}},"55":{"start":{"line":87,"column":4},"end":{"line":97,"column":7}},"56":{"start":{"line":88,"column":6},"end":{"line":96,"column":9}},"57":{"start":{"line":89,"column":8},"end":{"line":95,"column":11}},"58":{"start":{"line":90,"column":10},"end":{"line":90,"column":43}},"59":{"start":{"line":91,"column":10},"end":{"line":91,"column":79}},"60":{"start":{"line":92,"column":10},"end":{"line":92,"column":48}},"61":{"start":{"line":93,"column":10},"end":{"line":93,"column":79}},"62":{"start":{"line":94,"column":10},"end":{"line":94,"column":17}},"63":{"start":{"line":99,"column":4},"end":{"line":134,"column":7}},"64":{"start":{"line":100,"column":6},"end":{"line":107,"column":9}},"65":{"start":{"line":101,"column":8},"end":{"line":106,"column":11}},"66":{"start":{"line":102,"column":10},"end":{"line":102,"column":43}},"67":{"start":{"line":103,"column":10},"end":{"line":103,"column":45}},"68":{"start":{"line":104,"column":10},"end":{"line":104,"column":64}},"69":{"start":{"line":105,"column":10},"end":{"line":105,"column":17}},"70":{"start":{"line":108,"column":6},"end":{"line":115,"column":9}},"71":{"start":{"line":109,"column":8},"end":{"line":114,"column":11}},"72":{"start":{"line":110,"column":10},"end":{"line":110,"column":43}},"73":{"start":{"line":111,"column":10},"end":{"line":111,"column":45}},"74":{"start":{"line":112,"column":10},"end":{"line":112,"column":68}},"75":{"start":{"line":113,"column":10},"end":{"line":113,"column":17}},"76":{"start":{"line":116,"column":6},"end":{"line":123,"column":9}},"77":{"start":{"line":117,"column":8},"end":{"line":122,"column":11}},"78":{"start":{"line":118,"column":10},"end":{"line":118,"column":43}},"79":{"start":{"line":119,"column":10},"end":{"line":119,"column":45}},"80":{"start":{"line":120,"column":10},"end":{"line":120,"column":64}},"81":{"start":{"line":121,"column":10},"end":{"line":121,"column":17}},"82":{"start":{"line":124,"column":6},"end":{"line":133,"column":9}},"83":{"start":{"line":125,"column":20},"end":{"line":125,"column":21}},"84":{"start":{"line":126,"column":8},"end":{"line":132,"column":11}},"85":{"start":{"line":127,"column":10},"end":{"line":127,"column":43}},"86":{"start":{"line":128,"column":10},"end":{"line":128,"column":45}},"87":{"start":{"line":129,"column":10},"end":{"line":129,"column":66}},"88":{"start":{"line":130,"column":10},"end":{"line":130,"column":61}},"89":{"start":{"line":131,"column":10},"end":{"line":131,"column":17}},"90":{"start":{"line":135,"column":4},"end":{"line":196,"column":7}},"91":{"start":{"line":136,"column":6},"end":{"line":148,"column":9}},"92":{"start":{"line":137,"column":17},"end":{"line":137,"column":18}},"93":{"start":{"line":138,"column":8},"end":{"line":147,"column":11}},"94":{"start":{"line":139,"column":10},"end":{"line":139,"column":43}},"95":{"start":{"line":140,"column":10},"end":{"line":140,"column":41}},"96":{"start":{"line":141,"column":10},"end":{"line":141,"column":60}},"97":{"start":{"line":142,"column":10},"end":{"line":142,"column":43}},"98":{"start":{"line":143,"column":10},"end":{"line":143,"column":54}},"99":{"start":{"line":144,"column":10},"end":{"line":144,"column":60}},"100":{"start":{"line":145,"column":10},"end":{"line":145,"column":47}},"101":{"start":{"line":146,"column":10},"end":{"line":146,"column":17}},"102":{"start":{"line":149,"column":6},"end":{"line":161,"column":9}},"103":{"start":{"line":150,"column":17},"end":{"line":150,"column":18}},"104":{"start":{"line":151,"column":8},"end":{"line":160,"column":11}},"105":{"start":{"line":152,"column":10},"end":{"line":152,"column":43}},"106":{"start":{"line":153,"column":10},"end":{"line":153,"column":41}},"107":{"start":{"line":154,"column":10},"end":{"line":154,"column":60}},"108":{"start":{"line":155,"column":10},"end":{"line":155,"column":40}},"109":{"start":{"line":156,"column":10},"end":{"line":156,"column":54}},"110":{"start":{"line":157,"column":10},"end":{"line":157,"column":60}},"111":{"start":{"line":158,"column":10},"end":{"line":158,"column":47}},"112":{"start":{"line":159,"column":10},"end":{"line":159,"column":17}},"113":{"start":{"line":162,"column":6},"end":{"line":169,"column":9}},"114":{"start":{"line":163,"column":17},"end":{"line":163,"column":29}},"115":{"start":{"line":164,"column":8},"end":{"line":168,"column":11}},"116":{"start":{"line":165,"column":10},"end":{"line":165,"column":43}},"117":{"start":{"line":166,"column":10},"end":{"line":166,"column":112}},"118":{"start":{"line":167,"column":10},"end":{"line":167,"column":17}},"119":{"start":{"line":170,"column":6},"end":{"line":178,"column":9}},"120":{"start":{"line":171,"column":17},"end":{"line":171,"column":18}},"121":{"start":{"line":172,"column":8},"end":{"line":176,"column":11}},"122":{"start":{"line":173,"column":10},"end":{"line":173,"column":43}},"123":{"start":{"line":174,"column":10},"end":{"line":174,"column":53}},"124":{"start":{"line":175,"column":10},"end":{"line":175,"column":65}},"125":{"start":{"line":177,"column":8},"end":{"line":177,"column":15}},"126":{"start":{"line":179,"column":6},"end":{"line":187,"column":9}},"127":{"start":{"line":180,"column":17},"end":{"line":180,"column":20}},"128":{"start":{"line":181,"column":8},"end":{"line":186,"column":11}},"129":{"start":{"line":182,"column":10},"end":{"line":182,"column":43}},"130":{"start":{"line":183,"column":10},"end":{"line":183,"column":55}},"131":{"start":{"line":184,"column":10},"end":{"line":184,"column":60}},"132":{"start":{"line":185,"column":10},"end":{"line":185,"column":17}},"133":{"start":{"line":188,"column":6},"end":{"line":195,"column":9}},"134":{"start":{"line":189,"column":17},"end":{"line":189,"column":35}},"135":{"start":{"line":190,"column":8},"end":{"line":194,"column":11}},"136":{"start":{"line":191,"column":10},"end":{"line":191,"column":43}},"137":{"start":{"line":192,"column":10},"end":{"line":192,"column":119}},"138":{"start":{"line":193,"column":10},"end":{"line":193,"column":17}},"139":{"start":{"line":197,"column":4},"end":{"line":246,"column":7}},"140":{"start":{"line":198,"column":6},"end":{"line":207,"column":9}},"141":{"start":{"line":199,"column":17},"end":{"line":199,"column":18}},"142":{"start":{"line":200,"column":8},"end":{"line":206,"column":11}},"143":{"start":{"line":201,"column":10},"end":{"line":201,"column":43}},"144":{"start":{"line":202,"column":10},"end":{"line":202,"column":45}},"145":{"start":{"line":203,"column":10},"end":{"line":203,"column":40}},"146":{"start":{"line":204,"column":10},"end":{"line":204,"column":55}},"147":{"start":{"line":205,"column":10},"end":{"line":205,"column":17}},"148":{"start":{"line":208,"column":6},"end":{"line":217,"column":9}},"149":{"start":{"line":209,"column":17},"end":{"line":209,"column":18}},"150":{"start":{"line":210,"column":8},"end":{"line":216,"column":11}},"151":{"start":{"line":211,"column":10},"end":{"line":211,"column":43}},"152":{"start":{"line":212,"column":10},"end":{"line":212,"column":45}},"153":{"start":{"line":213,"column":10},"end":{"line":213,"column":40}},"154":{"start":{"line":214,"column":10},"end":{"line":214,"column":62}},"155":{"start":{"line":215,"column":10},"end":{"line":215,"column":17}},"156":{"start":{"line":218,"column":6},"end":{"line":227,"column":9}},"157":{"start":{"line":219,"column":17},"end":{"line":219,"column":18}},"158":{"start":{"line":220,"column":8},"end":{"line":226,"column":11}},"159":{"start":{"line":221,"column":10},"end":{"line":221,"column":43}},"160":{"start":{"line":222,"column":10},"end":{"line":222,"column":45}},"161":{"start":{"line":223,"column":10},"end":{"line":223,"column":40}},"162":{"start":{"line":224,"column":10},"end":{"line":224,"column":56}},"163":{"start":{"line":225,"column":10},"end":{"line":225,"column":17}},"164":{"start":{"line":228,"column":6},"end":{"line":236,"column":9}},"165":{"start":{"line":229,"column":17},"end":{"line":229,"column":18}},"166":{"start":{"line":230,"column":8},"end":{"line":235,"column":11}},"167":{"start":{"line":231,"column":10},"end":{"line":231,"column":43}},"168":{"start":{"line":232,"column":10},"end":{"line":232,"column":45}},"169":{"start":{"line":233,"column":10},"end":{"line":233,"column":88}},"170":{"start":{"line":234,"column":10},"end":{"line":234,"column":17}},"171":{"start":{"line":237,"column":6},"end":{"line":245,"column":9}},"172":{"start":{"line":238,"column":17},"end":{"line":238,"column":21}},"173":{"start":{"line":239,"column":8},"end":{"line":244,"column":11}},"174":{"start":{"line":240,"column":10},"end":{"line":240,"column":43}},"175":{"start":{"line":241,"column":10},"end":{"line":241,"column":45}},"176":{"start":{"line":242,"column":10},"end":{"line":242,"column":88}},"177":{"start":{"line":243,"column":10},"end":{"line":243,"column":17}},"178":{"start":{"line":247,"column":4},"end":{"line":272,"column":7}},"179":{"start":{"line":248,"column":6},"end":{"line":254,"column":9}},"180":{"start":{"line":249,"column":17},"end":{"line":249,"column":18}},"181":{"start":{"line":250,"column":8},"end":{"line":253,"column":11}},"182":{"start":{"line":251,"column":10},"end":{"line":251,"column":43}},"183":{"start":{"line":252,"column":10},"end":{"line":252,"column":17}},"184":{"start":{"line":255,"column":6},"end":{"line":262,"column":9}},"185":{"start":{"line":256,"column":17},"end":{"line":256,"column":18}},"186":{"start":{"line":257,"column":8},"end":{"line":261,"column":11}},"187":{"start":{"line":258,"column":10},"end":{"line":258,"column":43}},"188":{"start":{"line":259,"column":10},"end":{"line":259,"column":89}},"189":{"start":{"line":260,"column":10},"end":{"line":260,"column":17}},"190":{"start":{"line":263,"column":6},"end":{"line":271,"column":9}},"191":{"start":{"line":264,"column":17},"end":{"line":264,"column":19}},"192":{"start":{"line":265,"column":8},"end":{"line":270,"column":11}},"193":{"start":{"line":266,"column":10},"end":{"line":266,"column":43}},"194":{"start":{"line":267,"column":10},"end":{"line":267,"column":45}},"195":{"start":{"line":268,"column":10},"end":{"line":268,"column":60}},"196":{"start":{"line":269,"column":10},"end":{"line":269,"column":17}},"197":{"start":{"line":273,"column":4},"end":{"line":304,"column":7}},"198":{"start":{"line":274,"column":6},"end":{"line":282,"column":9}},"199":{"start":{"line":275,"column":21},"end":{"line":275,"column":22}},"200":{"start":{"line":276,"column":8},"end":{"line":281,"column":11}},"201":{"start":{"line":277,"column":10},"end":{"line":277,"column":43}},"202":{"start":{"line":278,"column":10},"end":{"line":278,"column":42}},"203":{"start":{"line":279,"column":10},"end":{"line":279,"column":60}},"204":{"start":{"line":280,"column":10},"end":{"line":280,"column":17}},"205":{"start":{"line":283,"column":6},"end":{"line":292,"column":9}},"206":{"start":{"line":284,"column":21},"end":{"line":284,"column":22}},"207":{"start":{"line":285,"column":8},"end":{"line":291,"column":11}},"208":{"start":{"line":286,"column":10},"end":{"line":286,"column":43}},"209":{"start":{"line":287,"column":10},"end":{"line":287,"column":42}},"210":{"start":{"line":288,"column":10},"end":{"line":288,"column":64}},"211":{"start":{"line":289,"column":10},"end":{"line":289,"column":49}},"212":{"start":{"line":290,"column":10},"end":{"line":290,"column":17}},"213":{"start":{"line":293,"column":6},"end":{"line":303,"column":9}},"214":{"start":{"line":294,"column":21},"end":{"line":294,"column":22}},"215":{"start":{"line":295,"column":8},"end":{"line":302,"column":11}},"216":{"start":{"line":296,"column":10},"end":{"line":296,"column":43}},"217":{"start":{"line":297,"column":10},"end":{"line":297,"column":42}},"218":{"start":{"line":298,"column":10},"end":{"line":298,"column":56}},"219":{"start":{"line":299,"column":10},"end":{"line":299,"column":68}},"220":{"start":{"line":300,"column":10},"end":{"line":300,"column":85}},"221":{"start":{"line":301,"column":10},"end":{"line":301,"column":17}}},"fnMap":{"0":{"name":"_interopRequireDefault","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":31}},"loc":{"start":{"line":23,"column":37},"end":{"line":23,"column":95}},"line":23},"1":{"name":"(anonymous_1)","decl":{"start":{"line":37,"column":18},"end":{"line":37,"column":19}},"loc":{"start":{"line":37,"column":30},"end":{"line":306,"column":1}},"line":37},"2":{"name":"(anonymous_2)","decl":{"start":{"line":38,"column":9},"end":{"line":38,"column":10}},"loc":{"start":{"line":38,"column":25},"end":{"line":43,"column":3}},"line":38},"3":{"name":"(anonymous_3)","decl":{"start":{"line":39,"column":90},"end":{"line":39,"column":91}},"loc":{"start":{"line":39,"column":110},"end":{"line":42,"column":5}},"line":39},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":9},"end":{"line":44,"column":10}},"loc":{"start":{"line":44,"column":25},"end":{"line":49,"column":3}},"line":44},"5":{"name":"(anonymous_5)","decl":{"start":{"line":45,"column":91},"end":{"line":45,"column":92}},"loc":{"start":{"line":45,"column":111},"end":{"line":48,"column":5}},"line":45},"6":{"name":"(anonymous_6)","decl":{"start":{"line":50,"column":9},"end":{"line":50,"column":10}},"loc":{"start":{"line":50,"column":25},"end":{"line":55,"column":3}},"line":50},"7":{"name":"(anonymous_7)","decl":{"start":{"line":51,"column":136},"end":{"line":51,"column":137}},"loc":{"start":{"line":51,"column":156},"end":{"line":54,"column":5}},"line":51},"8":{"name":"(anonymous_8)","decl":{"start":{"line":57,"column":31},"end":{"line":57,"column":32}},"loc":{"start":{"line":57,"column":43},"end":{"line":305,"column":3}},"line":57},"9":{"name":"(anonymous_9)","decl":{"start":{"line":58,"column":75},"end":{"line":58,"column":76}},"loc":{"start":{"line":58,"column":91},"end":{"line":66,"column":5}},"line":58},"10":{"name":"(anonymous_10)","decl":{"start":{"line":59,"column":92},"end":{"line":59,"column":93}},"loc":{"start":{"line":59,"column":112},"end":{"line":65,"column":7}},"line":59},"11":{"name":"(anonymous_11)","decl":{"start":{"line":68,"column":59},"end":{"line":68,"column":60}},"loc":{"start":{"line":68,"column":75},"end":{"line":76,"column":5}},"line":68},"12":{"name":"(anonymous_12)","decl":{"start":{"line":69,"column":92},"end":{"line":69,"column":93}},"loc":{"start":{"line":69,"column":112},"end":{"line":75,"column":7}},"line":69},"13":{"name":"(anonymous_13)","decl":{"start":{"line":78,"column":50},"end":{"line":78,"column":51}},"loc":{"start":{"line":78,"column":66},"end":{"line":85,"column":5}},"line":78},"14":{"name":"(anonymous_14)","decl":{"start":{"line":79,"column":92},"end":{"line":79,"column":93}},"loc":{"start":{"line":79,"column":112},"end":{"line":84,"column":7}},"line":79},"15":{"name":"(anonymous_15)","decl":{"start":{"line":87,"column":34},"end":{"line":87,"column":35}},"loc":{"start":{"line":87,"column":46},"end":{"line":97,"column":5}},"line":87},"16":{"name":"(anonymous_16)","decl":{"start":{"line":88,"column":37},"end":{"line":88,"column":38}},"loc":{"start":{"line":88,"column":53},"end":{"line":96,"column":7}},"line":88},"17":{"name":"(anonymous_17)","decl":{"start":{"line":89,"column":92},"end":{"line":89,"column":93}},"loc":{"start":{"line":89,"column":112},"end":{"line":95,"column":9}},"line":89},"18":{"name":"(anonymous_18)","decl":{"start":{"line":99,"column":27},"end":{"line":99,"column":28}},"loc":{"start":{"line":99,"column":39},"end":{"line":134,"column":5}},"line":99},"19":{"name":"(anonymous_19)","decl":{"start":{"line":100,"column":58},"end":{"line":100,"column":59}},"loc":{"start":{"line":100,"column":74},"end":{"line":107,"column":7}},"line":100},"20":{"name":"(anonymous_20)","decl":{"start":{"line":101,"column":110},"end":{"line":101,"column":111}},"loc":{"start":{"line":101,"column":130},"end":{"line":106,"column":9}},"line":101},"21":{"name":"(anonymous_21)","decl":{"start":{"line":108,"column":74},"end":{"line":108,"column":75}},"loc":{"start":{"line":108,"column":90},"end":{"line":115,"column":7}},"line":108},"22":{"name":"(anonymous_22)","decl":{"start":{"line":109,"column":109},"end":{"line":109,"column":110}},"loc":{"start":{"line":109,"column":129},"end":{"line":114,"column":9}},"line":109},"23":{"name":"(anonymous_23)","decl":{"start":{"line":116,"column":66},"end":{"line":116,"column":67}},"loc":{"start":{"line":116,"column":82},"end":{"line":123,"column":7}},"line":116},"24":{"name":"(anonymous_24)","decl":{"start":{"line":117,"column":75},"end":{"line":117,"column":76}},"loc":{"start":{"line":117,"column":95},"end":{"line":122,"column":9}},"line":117},"25":{"name":"(anonymous_25)","decl":{"start":{"line":124,"column":63},"end":{"line":124,"column":64}},"loc":{"start":{"line":124,"column":79},"end":{"line":133,"column":7}},"line":124},"26":{"name":"(anonymous_26)","decl":{"start":{"line":126,"column":123},"end":{"line":126,"column":124}},"loc":{"start":{"line":126,"column":143},"end":{"line":132,"column":9}},"line":126},"27":{"name":"(anonymous_27)","decl":{"start":{"line":135,"column":32},"end":{"line":135,"column":33}},"loc":{"start":{"line":135,"column":44},"end":{"line":196,"column":5}},"line":135},"28":{"name":"(anonymous_28)","decl":{"start":{"line":136,"column":54},"end":{"line":136,"column":55}},"loc":{"start":{"line":136,"column":70},"end":{"line":148,"column":7}},"line":136},"29":{"name":"(anonymous_29)","decl":{"start":{"line":138,"column":116},"end":{"line":138,"column":117}},"loc":{"start":{"line":138,"column":136},"end":{"line":147,"column":9}},"line":138},"30":{"name":"(anonymous_30)","decl":{"start":{"line":149,"column":74},"end":{"line":149,"column":75}},"loc":{"start":{"line":149,"column":90},"end":{"line":161,"column":7}},"line":149},"31":{"name":"(anonymous_31)","decl":{"start":{"line":151,"column":115},"end":{"line":151,"column":116}},"loc":{"start":{"line":151,"column":135},"end":{"line":160,"column":9}},"line":151},"32":{"name":"(anonymous_32)","decl":{"start":{"line":162,"column":69},"end":{"line":162,"column":70}},"loc":{"start":{"line":162,"column":85},"end":{"line":169,"column":7}},"line":162},"33":{"name":"(anonymous_33)","decl":{"start":{"line":164,"column":116},"end":{"line":164,"column":117}},"loc":{"start":{"line":164,"column":136},"end":{"line":168,"column":9}},"line":164},"34":{"name":"(anonymous_34)","decl":{"start":{"line":170,"column":74},"end":{"line":170,"column":75}},"loc":{"start":{"line":170,"column":90},"end":{"line":178,"column":7}},"line":170},"35":{"name":"(anonymous_35)","decl":{"start":{"line":172,"column":117},"end":{"line":172,"column":118}},"loc":{"start":{"line":172,"column":137},"end":{"line":176,"column":9}},"line":172},"36":{"name":"(anonymous_36)","decl":{"start":{"line":179,"column":65},"end":{"line":179,"column":66}},"loc":{"start":{"line":179,"column":81},"end":{"line":187,"column":7}},"line":179},"37":{"name":"(anonymous_37)","decl":{"start":{"line":181,"column":116},"end":{"line":181,"column":117}},"loc":{"start":{"line":181,"column":136},"end":{"line":186,"column":9}},"line":181},"38":{"name":"(anonymous_38)","decl":{"start":{"line":188,"column":64},"end":{"line":188,"column":65}},"loc":{"start":{"line":188,"column":80},"end":{"line":195,"column":7}},"line":188},"39":{"name":"(anonymous_39)","decl":{"start":{"line":190,"column":116},"end":{"line":190,"column":117}},"loc":{"start":{"line":190,"column":136},"end":{"line":194,"column":9}},"line":190},"40":{"name":"(anonymous_40)","decl":{"start":{"line":197,"column":39},"end":{"line":197,"column":40}},"loc":{"start":{"line":197,"column":51},"end":{"line":246,"column":5}},"line":197},"41":{"name":"(anonymous_41)","decl":{"start":{"line":198,"column":73},"end":{"line":198,"column":74}},"loc":{"start":{"line":198,"column":89},"end":{"line":207,"column":7}},"line":198},"42":{"name":"(anonymous_42)","decl":{"start":{"line":200,"column":146},"end":{"line":200,"column":147}},"loc":{"start":{"line":200,"column":166},"end":{"line":206,"column":9}},"line":200},"43":{"name":"(anonymous_43)","decl":{"start":{"line":208,"column":69},"end":{"line":208,"column":70}},"loc":{"start":{"line":208,"column":85},"end":{"line":217,"column":7}},"line":208},"44":{"name":"(anonymous_44)","decl":{"start":{"line":210,"column":153},"end":{"line":210,"column":154}},"loc":{"start":{"line":210,"column":173},"end":{"line":216,"column":9}},"line":210},"45":{"name":"(anonymous_45)","decl":{"start":{"line":218,"column":72},"end":{"line":218,"column":73}},"loc":{"start":{"line":218,"column":88},"end":{"line":227,"column":7}},"line":218},"46":{"name":"(anonymous_46)","decl":{"start":{"line":220,"column":147},"end":{"line":220,"column":148}},"loc":{"start":{"line":220,"column":167},"end":{"line":226,"column":9}},"line":220},"47":{"name":"(anonymous_47)","decl":{"start":{"line":228,"column":102},"end":{"line":228,"column":103}},"loc":{"start":{"line":228,"column":118},"end":{"line":236,"column":7}},"line":228},"48":{"name":"(anonymous_48)","decl":{"start":{"line":230,"column":153},"end":{"line":230,"column":154}},"loc":{"start":{"line":230,"column":173},"end":{"line":235,"column":9}},"line":230},"49":{"name":"(anonymous_49)","decl":{"start":{"line":237,"column":99},"end":{"line":237,"column":100}},"loc":{"start":{"line":237,"column":115},"end":{"line":245,"column":7}},"line":237},"50":{"name":"(anonymous_50)","decl":{"start":{"line":239,"column":153},"end":{"line":239,"column":154}},"loc":{"start":{"line":239,"column":173},"end":{"line":244,"column":9}},"line":239},"51":{"name":"(anonymous_51)","decl":{"start":{"line":247,"column":35},"end":{"line":247,"column":36}},"loc":{"start":{"line":247,"column":47},"end":{"line":272,"column":5}},"line":247},"52":{"name":"(anonymous_52)","decl":{"start":{"line":248,"column":65},"end":{"line":248,"column":66}},"loc":{"start":{"line":248,"column":81},"end":{"line":254,"column":7}},"line":248},"53":{"name":"(anonymous_53)","decl":{"start":{"line":250,"column":119},"end":{"line":250,"column":120}},"loc":{"start":{"line":250,"column":139},"end":{"line":253,"column":9}},"line":250},"54":{"name":"(anonymous_54)","decl":{"start":{"line":255,"column":73},"end":{"line":255,"column":74}},"loc":{"start":{"line":255,"column":89},"end":{"line":262,"column":7}},"line":255},"55":{"name":"(anonymous_55)","decl":{"start":{"line":257,"column":118},"end":{"line":257,"column":119}},"loc":{"start":{"line":257,"column":138},"end":{"line":261,"column":9}},"line":257},"56":{"name":"(anonymous_56)","decl":{"start":{"line":263,"column":62},"end":{"line":263,"column":63}},"loc":{"start":{"line":263,"column":78},"end":{"line":271,"column":7}},"line":263},"57":{"name":"(anonymous_57)","decl":{"start":{"line":265,"column":119},"end":{"line":265,"column":120}},"loc":{"start":{"line":265,"column":139},"end":{"line":270,"column":9}},"line":265},"58":{"name":"(anonymous_58)","decl":{"start":{"line":273,"column":51},"end":{"line":273,"column":52}},"loc":{"start":{"line":273,"column":63},"end":{"line":304,"column":5}},"line":273},"59":{"name":"(anonymous_59)","decl":{"start":{"line":274,"column":68},"end":{"line":274,"column":69}},"loc":{"start":{"line":274,"column":84},"end":{"line":282,"column":7}},"line":274},"60":{"name":"(anonymous_60)","decl":{"start":{"line":276,"column":134},"end":{"line":276,"column":135}},"loc":{"start":{"line":276,"column":154},"end":{"line":281,"column":9}},"line":276},"61":{"name":"(anonymous_61)","decl":{"start":{"line":283,"column":70},"end":{"line":283,"column":71}},"loc":{"start":{"line":283,"column":86},"end":{"line":292,"column":7}},"line":283},"62":{"name":"(anonymous_62)","decl":{"start":{"line":285,"column":100},"end":{"line":285,"column":101}},"loc":{"start":{"line":285,"column":120},"end":{"line":291,"column":9}},"line":285},"63":{"name":"(anonymous_63)","decl":{"start":{"line":293,"column":69},"end":{"line":293,"column":70}},"loc":{"start":{"line":293,"column":85},"end":{"line":303,"column":7}},"line":293},"64":{"name":"(anonymous_64)","decl":{"start":{"line":295,"column":134},"end":{"line":295,"column":135}},"loc":{"start":{"line":295,"column":154},"end":{"line":302,"column":9}},"line":295}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":92}},"type":"cond-expr","locations":[{"start":{"line":23,"column":70},"end":{"line":23,"column":73}},{"start":{"line":23,"column":76},"end":{"line":23,"column":92}}],"line":23},"1":{"loc":{"start":{"line":23,"column":46},"end":{"line":23,"column":67}},"type":"binary-expr","locations":[{"start":{"line":23,"column":46},"end":{"line":23,"column":49}},{"start":{"line":23,"column":53},"end":{"line":23,"column":67}}],"line":23}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":5,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":1,"68":1,"69":1,"70":1,"71":1,"72":1,"73":1,"74":1,"75":1,"76":1,"77":1,"78":1,"79":1,"80":1,"81":1,"82":1,"83":1,"84":1,"85":1,"86":1,"87":1,"88":1,"89":1,"90":1,"91":1,"92":1,"93":1,"94":1,"95":1,"96":1,"97":1,"98":1,"99":1,"100":1,"101":1,"102":1,"103":1,"104":1,"105":1,"106":1,"107":1,"108":1,"109":1,"110":1,"111":1,"112":1,"113":1,"114":1,"115":1,"116":1,"117":1,"118":1,"119":1,"120":1,"121":1,"122":1,"123":0,"124":0,"125":1,"126":1,"127":1,"128":1,"129":1,"130":1,"131":1,"132":1,"133":1,"134":1,"135":1,"136":1,"137":1,"138":0,"139":1,"140":1,"141":1,"142":1,"143":1,"144":1,"145":1,"146":1,"147":1,"148":1,"149":1,"150":1,"151":1,"152":1,"153":1,"154":1,"155":1,"156":1,"157":1,"158":1,"159":1,"160":1,"161":1,"162":1,"163":1,"164":1,"165":1,"166":1,"167":1,"168":1,"169":1,"170":1,"171":1,"172":1,"173":1,"174":1,"175":1,"176":1,"177":1,"178":1,"179":1,"180":1,"181":1,"182":1,"183":1,"184":1,"185":1,"186":1,"187":1,"188":1,"189":1,"190":1,"191":1,"192":1,"193":1,"194":1,"195":1,"196":1,"197":1,"198":1,"199":1,"200":1,"201":1,"202":1,"203":1,"204":1,"205":1,"206":1,"207":1,"208":1,"209":1,"210":1,"211":1,"212":1,"213":1,"214":1,"215":1,"216":1,"217":1,"218":1,"219":1,"220":1,"221":1},"f":{"0":5,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":1,"25":1,"26":1,"27":1,"28":1,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":1,"41":1,"42":1,"43":1,"44":1,"45":1,"46":1,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":1,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":1,"61":1,"62":1,"63":1,"64":1},"b":{"0":[2,3],"1":[5,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"060516ee641f350d496788a93e3f15efcfed500f","contentHash":"f57e82a76a737be2530dffb11f4a5fbd_11.0.3"}} \ No newline at end of file diff --git a/.nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json b/.nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json deleted file mode 100644 index 9e26dfe..0000000 --- a/.nyc_output/af900f3c2b7376a2ee4661b3a5b4960c.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index eff9866..e19d5e0 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index f15ff6d..2154d6a 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index b9f1bc4..afb70da 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index f5846ae..847358b 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index 2c3a47d..bffc262 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 4d61cbd..859a6e2 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -721,7 +721,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 8ee86ad..3cca8eb 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,9 +20,9 @@

- 72.29% + 72.73% Statements - 167/231 + 168/231
72.41% @@ -30,14 +30,14 @@

84/116

- 63.1% + 64.29% Functions - 53/84 + 54/84
- 72.29% + 72.73% Lines - 167/231 + 168/231
@@ -73,15 +73,15 @@

- - - + + + - - - - + + + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index 52845e2..d9f6f0d 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -20,9 +20,9 @@

- 80% + 82.5% Statements - 32/40 + 33/40
72.22% @@ -30,14 +30,14 @@

13/18

- 76.19% + 80.95% Functions - 16/21 + 17/21
- 80% + 82.5% Lines - 32/40 + 33/40
@@ -188,13 +188,13 @@

      -2x +3x   -2x -2x +3x +3x     -2x +3x     2x @@ -209,7 +209,7 @@

      -  +1x       @@ -289,11 +289,11 @@

      -3x +2x       -3x +2x   2x 1x @@ -307,7 +307,7 @@

    1x -2x +1x       @@ -343,7 +343,7 @@

res.json(error.errors); }); } - }).catch(error => res.json(error)); + }).catch(error => res.json(error)); } }   @@ -451,7 +451,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index 423e165..97449f2 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -424,7 +424,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index fd8dcb8..5bec8ed 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -901,7 +901,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index 15e61a2..e3723a4 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index 06ba426..533a236 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index 46e3e38..6b7ca7c 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index 4a038f9..281c225 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index e98b306..4e5e863 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -136,7 +136,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 70f0017..0293f79 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index c3a7641..882eaa7 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 465c4b5..67977d7 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -100,7 +100,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 42bb2e6..4ecbc39 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -169,7 +169,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index f9a832d..a483a98 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index 3f0dc53..c12124a 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index 46fd940..57b03f3 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index 96af5c7..4ef8153 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index cd0743f..4946aaa 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index aeb1c2b..9226aa2 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html index a5e278c..dea6a0b 100644 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -1120,7 +1120,7 @@

diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html index 3a8f473..bff643b 100644 --- a/coverage/document-manager/server/test/controllers/index.html +++ b/coverage/document-manager/server/test/controllers/index.html @@ -20,9 +20,9 @@

- 94.93% + 94.44% Statements - 581/612 + 578/612
100% @@ -35,9 +35,9 @@

186/189

- 94.87% + 94.37% Lines - 573/604 + 570/604
@@ -86,15 +86,15 @@

- - - + + + - - + + @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html index c5c76d7..cf2715e 100644 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -181,7 +181,7 @@

diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html index 7a5a046..5218155 100644 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -20,9 +20,9 @@

- 92.45% + 90.57% Statements - 147/159 + 144/159
100% @@ -35,9 +35,9 @@

48/50

- 92.36% + 90.45% Lines - 145/157 + 142/157
@@ -431,12 +431,12 @@

    1x -  +1x         -  +1x       @@ -637,14 +637,14 @@

  1x   -1x -1x +  +        -1x -1x -1x +  +  +        @@ -734,13 +734,13 @@

done(); }); }); - it('Should return an error if the title is not a string', (done) => { - chai.request(server) + it('Should return an error if the title is not a string', (done) => { + chai.request(server) .post('/api/v1/roles') .set({ authorization: adminToken }) .send({ title: 358583 }) - .end((err, res) => { - expect(res.status).to.equal(400); + .end((err, res) => { + expect(res.status).to.equal(400); expect(res.body).to.be.a('object'); expect(res.body.message).to.eql('Invalid input credentials'); done(); @@ -940,15 +940,15 @@

}); }); it(`Should fail to delete a role given - the admin enters an input that is out of range`, (done) => { - const id = 3000000000000000; - chai.request(server) + the admin enters an input that is out of range`, (done) => { + const id = 3000000000000000; + chai.request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message) .to.eql(`value "${id}" is out of range for type integer`); done(); }); @@ -961,7 +961,7 @@

diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html index dd6f75e..9ca2894 100644 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -326,34 +326,34 @@

.set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('Invalid search input') + expect(res.body.message).to.eql('Invalid search input'); }); - }); - it('Should return a search list of the required search input', () => { - const query = 'John'; - request(server) + }); + it('Should return a search list of the required search input', () => { + const query = 'John'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.have.property('document'); - expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); - expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); + expect(res.body.document[0].title).to.equal('John Doe'); + expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); }); - }); - it('Should throw an error if the searched document is not found', () => { - const query = 'jk'; - request(server) + }); + it('Should throw an error if the searched document is not found', () => { + const query = 'jk'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(404); - expect(res.body).to.have.property('message').to.equal('Document not found'); + expect(res.body.message).to.equal('Document not found'); }); - }); - }); + }); + }); });  

1 2 @@ -145,12 +145,7 @@

100 101 102 -103 -104 -105 -106 -107 -108

1x +1031x 1x 1x 1x @@ -187,34 +182,29 @@

    1x -  -  -  -1x -1x 1x       1x 1x -  -  +1x +1x       -  +1x       1x   -  -  +1x +1x       -  +1x       @@ -222,22 +212,22 @@

  1x 1x -  -  +1x +1x       -  +1x       1x -  -  +1x +1x       -  +1x       @@ -246,12 +236,12 @@

    1x -  -  +1x +1x       -  +1x       @@ -266,7 +256,7 @@

  const expect = chai.expect; chai.use(http); -let userToken, adminToken, sampleUserToke; +let userToken, adminToken, sampleUserToken; const { admin, fellow } = data;   describe('Users', () => { @@ -294,57 +284,52 @@

.send({ email: 'blessing@test.com', password: 'pass123' }) .end((err, res) => { sampleUserToken = res.body.token; - done(); + done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - }); -    describe('/SEARCH/users/?q={name}', () => { - it('Should return an error if no querystring is provided', () => { - const query = ''; - request(server) + it('Should return an error if no querystring is provided', () => { + const query = ''; + request(server) .get(`/api/v1/search/users/?q=${query}`) .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(400); + .end((err, res) => { + expect(res.status).to.equal(400); expect(res.body.message).to.eql('Inval search input'); }); }); it('Should return a search list response of the required search input', - () => { - const query = 'jame'; - request(server) + () => { + const query = 'jame'; + request(server) .get(`/api/v1/search/users/?q=${query}`) .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(200); + .end((err, res) => { + expect(res.status).to.equal(200); expect(res.body.fullName).to.eql('jame doe'); expect(res.body.userName).to.eql('testdoe'); }); }); }); describe('/SEARCH/documents/?q=', () => { - it('Should return an error if no querystring is provided', () => { - const query = ''; - request(server) + it('Should return an error if no querystring is provided', () => { + const query = ''; + request(server) .get(`/api/v1/search/document/?q=${query}`) .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(400); + .end((err, res) => { + expect(res.status).to.equal(400); expect(res.body).to.have.property('message').to.equal('Invalid search input') }); }); - it('Should return a search list of the required search input', () => { - const query = 'John'; - request(server) + it('Should return a search list of the required search input', () => { + const query = 'John'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(200); + .end((err, res) => { + expect(res.status).to.equal(200); expect(res.body).to.have.property('document'); expect(res.body.document[0]).to.have.property('title').to.equal('John Doe'); expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school'); @@ -352,13 +337,13 @@

expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); }); }); - it('Should throw an error if the searched document is not found', () => { - const query = 'jk'; - request(server) + it('Should throw an error if the searched document is not found', () => { + const query = 'jk'; + request(server) .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(404); + .end((err, res) => { + expect(res.status).to.equal(404); expect(res.body).to.have.property('message').to.equal('Document not found'); }); }); @@ -370,7 +355,7 @@

diff --git a/coverage/document-manager/server/test/user.spec.js.html b/coverage/document-manager/server/test/user.spec.js.html index 139c062..3d7d402 100644 --- a/coverage/document-manager/server/test/user.spec.js.html +++ b/coverage/document-manager/server/test/user.spec.js.html @@ -20,9 +20,9 @@

- 98.6% + 98.58% Statements - 212/215 + 209/212
100% @@ -32,12 +32,12 @@

100% Functions - 65/65 + 64/64
- 98.59% + 98.57% Lines - 210/213 + 207/210

@@ -433,11 +433,7 @@

388 389 390 -391 -392 -393 -394 -395

1x +3911x 1x 1x 1x @@ -477,10 +473,6 @@

1x     -1x -1x -1x -    1x 1x @@ -871,10 +863,6 @@

done(); }); }); - after((done) => { - models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } }); - done(); - });   describe('/POST User login', () => { it('Should fail if the user enters incorrect crendentials upon login', @@ -1231,7 +1219,7 @@

diff --git a/coverage/gulpfile.babel.js.html b/coverage/gulpfile.babel.js.html new file mode 100644 index 0000000..479875a --- /dev/null +++ b/coverage/gulpfile.babel.js.html @@ -0,0 +1,182 @@ + + + + Code coverage report for gulpfile.babel.js + + + + + + + +
+
+

+ All files gulpfile.babel.js +

+
+
+ 78.57% + Statements + 11/14 +
+
+ 100% + Branches + 0/0 +
+
+ 0% + Functions + 0/3 +
+
+ 91.67% + Lines + 11/12 +
+
+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +401x +1x +  +1x +1x +  +  +1x +  +1x +  +  +  +  +1x +  +  +  +  +  +1x +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +1x +1x + 
import gulp from 'gulp';
+import mocha from 'gulp-mocha';
+ 
+import loadPlugins from 'gulp-load-plugins';
+import path from 'path';
+ 
+// Load the gulp plugins into the `plugins` variable
+const plugins = loadPlugins();
+ 
+const paths = {
+  js: ['./**/*.js', '!dist/**', '!node_modules/**']
+};
+ 
+// Compile all Babel Javascript into ES5 and put it into the dist dir
+gulp.task('babel', () =>
+  gulp.src(paths.js, { base: '.' })
+    .pipe(plugins.babel())
+    .pipe(gulp.dest('dist'))
+);
+ 
+gulp.task('mochaTest', () => {
+  gulp.src(['server/test/**/*.js'])
+    .pipe(mocha({
+      reporter: 'spec',
+    }));
+});
+ 
+// Start server with restart on file change events
+gulp.task('nodemon', ['babel'], () =>
+  plugins.nodemon({
+    script: path.join('dist', 'index.js'),
+    ext: 'js',
+    ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'],
+    tasks: ['babel']
+  })
+);
+ 
+gulp.task('test', ['mochaTest']);
+gulp.task('default', ['nodemon']);
+ 
+
+
+ + + + + + + diff --git a/coverage/index.html b/coverage/index.html index 22b9602..28fe5b4 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,9 +20,9 @@

- 88.21% + 89.9% Statements - 860/975 + 863/960
73.72% @@ -30,14 +30,14 @@

101/137

- 85.32% + 88.24% Functions - 250/293 + 255/289
- 88.08% + 89.79% Lines - 850/965 + 853/950
@@ -86,15 +86,15 @@

document-manager/server/controllers
72.73%168/231
72.29%167/231 72.41% 84/11664.29%54/8472.73%168/23163.1%53/8472.29%167/231
document-manager/server/test
92.03%577/627document-manager/server/test/controllers
94.93%581/612 100% 0/093.26%180/19391.92%569/61998.41%186/18994.87%573/604
roles.js
80%32/40
82.5%33/40 72.22% 13/1876.19%16/2180%32/4080.95%17/2182.5%33/40
role.spec.js
92.45%147/159
90.57%144/159 100% 0/0 96% 48/5092.36%145/15790.45%142/157
@@ -361,7 +361,7 @@

diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html index 00de34e..e7181eb 100644 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -920,7 +920,7 @@

it('Should get all users if the user is an admin ', (done) => { request(server) .get('/api/v1/users') - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -932,7 +932,7 @@

(done) => { request(server) .get('/api/v1/users') - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); @@ -954,7 +954,7 @@

const limit = 1; chai.request(server) .get(`/api/v1/users?limit=${limit}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -969,7 +969,7 @@

const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -986,7 +986,7 @@

const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -1003,7 +1003,7 @@

const id = 'fddjsdcdjn'; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.property('message') @@ -1016,7 +1016,7 @@

const id = 2; request(server) .get(`api/users/${id}`) - .set({ authorization: sampleUserToken }) + .set({ 'authorization': sampleUserToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.keys(['message']); @@ -1029,7 +1029,7 @@

const id = 250; request(server) .get(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.have.property('message'); @@ -1057,7 +1057,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ fullName: 'jake doe' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1071,7 +1071,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1086,7 +1086,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ userName: 'jakedoe12' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1102,7 +1102,7 @@

const id = 3; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -1118,7 +1118,7 @@

const id = 2302; request(server) .put(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -1134,7 +1134,7 @@

const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(204); done(); @@ -1145,7 +1145,7 @@

const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body.message) @@ -1157,7 +1157,7 @@

const id = 23; request(server) .delete(`/api/v1/users/${id}`) - .set({ authorization: adminToken }) + .set({ 'authorization': adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); @@ -1171,7 +1171,7 @@

const userId = 9; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).be.a('object'); @@ -1196,7 +1196,7 @@

const userId = 2; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ authorization: userToken }) + .set({ 'authorization': userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('object'); @@ -1216,7 +1216,7 @@

diff --git a/coverage/index.html b/coverage/index.html index 28fe5b4..b84aff6 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,9 +20,9 @@

- 89.9% + 89.69% Statements - 863/960 + 861/960
73.72% @@ -30,14 +30,14 @@

101/137

- 88.24% + 88.58% Functions - 255/289 + 256/289
- 89.79% + 89.58% Lines - 853/950 + 851/950
@@ -86,15 +86,15 @@

document-manager/server/controllers
72.29%167/231
72.73%168/231 72.41% 84/11663.1%53/8472.29%167/23164.29%54/8472.73%168/231
document-manager/server/test/controllers
94.93%581/612
94.44%578/612 100% 0/0 98.41% 186/18994.87%573/60494.37%570/604
search.js
14.29%5/350%0/140%0/814.29%5/35
41.67%15/3621.43%3/1425%2/841.67%15/36
1x +126 +1271x 1x   1x @@ -182,15 +183,15 @@

      -  -  -  -  -  +2x +2x +2x +2x +1x       -  +1x       @@ -200,11 +201,12 @@

      -  -  +2x +1x +1x     -  +1x       @@ -306,16 +308,16 @@

* @param {array} res - array of users * @returns {array} - array users searched */ -function searchUser(req, res) { - const searchQuery = req.query.q, - limit = req.query.limit, - offset = req.query.offset; - if (!searchQuery) { - return res.status(400).json({ +function searchUser(req, res) { + const searchQuery = req.query.q, + limit = req.query.limit, + offset = req.query.offset; + if (!searchQuery) { + return res.status(400).json({ message: 'Invalid search input' }); } - return User + return User .findAndCountAll({ limit, offset, @@ -325,11 +327,12 @@

$like: `%${searchQuery}%`, } } - }).then(({ rows: user, count }) => { - if (count === 0) { + }).then(({ rows: user, count }) => { + console.log(count, 'User Count'); + Iif (count === 0) { return res.status(404).json({ message: 'User not found' }); } - res.status(200).send({ + res.status(200).send({ user, pagination: metaData(count, limit, offset) }); @@ -424,7 +427,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index 5bec8ed..f470e41 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -901,7 +901,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index e3723a4..4f21864 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -51,7 +51,7 @@

6 7 8 -9

6x +97x       @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index 533a236..b43b9dd 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index 6b7ca7c..fbd644c 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -84,14 +84,14 @@

      -64x -64x -60x -60x +66x +66x +62x +62x     -60x -60x +62x +62x       @@ -103,10 +103,10 @@

      -25x -15x +27x +18x   -10x +9x       @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index 281c225..b624db2 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 4e5e863..754bf43 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -136,7 +136,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 0293f79..b9798b9 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index 882eaa7..45b8b31 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 67977d7..7cb787c 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -100,7 +100,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 4ecbc39..a214418 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -169,7 +169,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index a483a98..b1ac31f 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index c12124a..cc2a9da 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index 57b03f3..e23e1db 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index 4ef8153..d91af56 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index 4946aaa..d2a41ad 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index 9226aa2..ecba766 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html index dea6a0b..4be26a0 100644 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -1120,7 +1120,7 @@

diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html index bff643b..570df90 100644 --- a/coverage/document-manager/server/test/controllers/index.html +++ b/coverage/document-manager/server/test/controllers/index.html @@ -20,9 +20,9 @@

- 94.44% + 95.31% Statements - 578/612 + 589/618
100% @@ -30,14 +30,14 @@

0/0

- 98.41% + 99.47% Functions - 186/189 + 188/189
- 94.37% + 95.25% Lines - 570/604 + 581/610
@@ -86,28 +86,28 @@

role.spec.js
90.57%144/159
93.71%149/159 100% 0/096%48/5090.45%142/157100%50/5093.63%147/157
search.spec.js
82.14%46/56
83.87%52/62 100% 0/0 100% 19/1981.48%44/5483.33%50/60
1x +45 +46 +47 +48 +49 +50 +51 +52 +53 +541x   1x   @@ -131,6 +140,15 @@

      +  +  +  +  +  +  +  +  +   

import dotenv from 'dotenv';
  
 dotenv.config();
@@ -165,6 +183,15 @@ 

createdAt: new Date(), updatedAt: new Date() }, + Baas: { + fullName: 'Baas Bank', + userName: 'bank', + email: 'baas@test.com', + password: 'pass123', + roleId: 1, + createdAt: new Date(), + updatedAt: new Date() + }, fakeUserDetails: { fullName: 'Daniel Cfh', userName: 'cfh', @@ -181,7 +208,7 @@

diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html index 5218155..e1ad90a 100644 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -20,9 +20,9 @@

- 90.57% + 93.71% Statements - 144/159 + 149/159
100% @@ -30,14 +30,14 @@

0/0

- 96% + 100% Functions - 48/50 + 50/50
- 90.45% + 93.63% Lines - 142/157 + 147/157
@@ -637,14 +637,14 @@

  1x   -  -  +1x +1x       -  -  -  +1x +1x +1x       @@ -940,15 +940,15 @@

}); }); it(`Should fail to delete a role given - the admin enters an input that is out of range`, (done) => { - const id = 3000000000000000; - chai.request(server) + the admin enters an input that is out of range`, (done) => { + const id = 3000000000000000; + chai.request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.be.a('object'); + expect(res.body.message) .to.eql(`value "${id}" is out of range for type integer`); done(); }); @@ -961,7 +961,7 @@

diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html index 9ca2894..753d923 100644 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -20,9 +20,9 @@

- 82.14% + 83.87% Statements - 46/56 + 52/62
100% @@ -35,9 +35,9 @@

19/19

- 81.48% + 83.33% Lines - 44/54 + 50/60
@@ -147,7 +147,12 @@

102 103 104 -105

1x +105 +106 +107 +108 +109 +1101x 1x 1x 1x @@ -155,8 +160,6 @@

    1x -  -1x 1x 1x   @@ -198,19 +201,23 @@

    1x -  +1x +1x     1x   1x 1x +1x       1x -  -  +1x +1x +1x +1x       @@ -223,6 +230,7 @@

  1x   +      1x @@ -237,6 +245,7 @@

      +      1x @@ -247,6 +256,7 @@

  1x   +        @@ -258,12 +268,10 @@

import data from './mockData';     -process.env.NODE_ENV = 'test'; -  const expect = chai.expect; chai.use(http); let userToken, adminToken, sampleUserToken; -const { admin, fellow } = data; +const { admin, fellow, Baas } = data;   describe('Search', () => { before((done) => { @@ -295,41 +303,46 @@

});   describe('/SEARCH/users/?q={name}', () => { - it('Should return an error if no querystring is provided', () => { + it('Should return an error if no querystring is provided', (done) => { const query = ''; request(server) .get(`/api/v1/search/users/?q=${query}`) - .set({ authorization: userToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); + expect(res.body.message).to.eql('Invalid search input'); + done(); }); }); it('Should return a search list response of the required search input', - () => { - const query = 'jame'; + (done) => { + const query = Baas.userName; + console.log(adminToken); request(server) .get(`/api/v1/search/users/?q=${query}`) - .set({ authorization: userToken }) + .set({ authorization: adminToken }) .end((err, res) => { + console.log(res.body, 'Baas Bank Details *************'); expect(res.status).to.equal(200); - expect(res.body.fullName).to.eql('jame doe'); - expect(res.body.userName).to.eql('testdoe'); + expect(res.body.user[0].fullName).to.eql(Baas.fullName); + expect(res.body.user[0].userName).to.equal(Baas.userName); + done(); }); }); }); describe('/SEARCH/documents/?q=', () => { - it('Should return an error if no querystring is provided', () => { + it('Should return an error if no querystring is provided', (done) => { const query = ''; request(server) - .get(`/api/v1/search/document/?q=${query}`) + .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(400); expect(res.body.message).to.eql('Invalid search input'); + done(); }); }); - it('Should return a search list of the required search input', () => { + it('Should return a search list of the required search input', (done) => { const query = 'John'; request(server) .get(`/api/v1/search/documents/?q=${query}`) @@ -341,9 +354,10 @@

expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + done(); }); }); - it('Should throw an error if the searched document is not found', () => { + it('Should throw an error if the searched document is not found', (done) => { const query = 'jk'; request(server) .get(`/api/v1/search/documents/?q=${query}`) @@ -351,6 +365,7 @@

.end((err, res) => { expect(res.status).to.equal(404); expect(res.body.message).to.equal('Document not found'); + done(); }); }); }); @@ -361,7 +376,7 @@

diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html index e7181eb..cde0057 100644 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -1216,7 +1216,7 @@

diff --git a/coverage/index.html b/coverage/index.html index b84aff6..741d10d 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,24 +20,24 @@

- 89.69% + 91.21% Statements - 861/960 + 882/967
- 73.72% + 75.91% Branches - 101/137 + 104/137
- 88.58% + 89.97% Functions - 256/289 + 260/289
- 89.58% + 91.12% Lines - 851/950 + 872/957
@@ -86,15 +86,15 @@

document-manager/server/controllers
72.73%168/23172.41%84/11664.29%54/8472.73%168/231
76.72%178/23275%87/11666.67%56/8476.72%178/232
document-manager/server/test/controllers
94.44%578/612
95.31%589/618 100% 0/098.41%186/18994.37%570/60499.47%188/18995.25%581/610
- + - + @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index 206ad14..2ccb50a 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -22,7 +22,7 @@

100% Statements - 4/4 + 3/3
100% @@ -37,7 +37,7 @@

100% Lines - 4/4 + 3/3

@@ -52,7 +52,7 @@

7 8 9 -10

- + - + @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 62166ff..bc4ed32 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -20,9 +20,9 @@

- 79.71% + 80% Statements - 55/69 + 52/65
85.71% @@ -35,13 +35,13 @@

15/25

- 79.71% + 80% Lines - 55/69 + 52/65
-
+
1 2 @@ -267,7 +267,9 @@

222 223 224 -225

1x +225 +226 +2271x 1x   1x @@ -281,14 +283,14 @@

      -2x -2x -2x +5x +5x +5x   -2x +5x   -2x -1x +5x +4x   1x   @@ -462,13 +464,14 @@

      -  4x   4x 1x   -4x +  +  +3x       @@ -480,9 +483,10 @@

  2x   +      -1x +        @@ -494,8 +498,8 @@

 

import helper from '../helpers/helper';
 import models from '../models';
  
-const Document = models.Document;
 const User = models.User;
+const Document = models.Document;
 const metaData = helper.paginationMetaData;
  
 /**
@@ -526,11 +530,11 @@ 

access: req.body.value, userId: req.body.userId }) - .then(documentResponse => res.status(201).send(documentResponse)) + .then(documentResponse => res.status(200).send(documentResponse)) .catch(error => res.status(400).send(error)); } return res.status(403).json({ - title: 'Document already exists' + message: 'Document already exists' }); }).catch(error => res.status(400).send(error)); } @@ -680,7 +684,6 @@

}   /** - * * Delete a document by Id * @param {number} req - id of the requested document * @param {object} res - message @@ -690,7 +693,9 @@

return Document.findById(req.params.id) .then((document) => { if (!document) { - res.status(404).json({ message: 'Document not found' }); + return res.status(404).send({ + message: 'Document Not Found' + }); } if ( req.decoded.roleId !== 1 && @@ -702,11 +707,12 @@

} return document .destroy() - .then(() => res.status(204) - .send({ message: 'Document deleted successfully' })) + .then(() => res.status(204).send({ + message: 'Document successfully deleted' + })) .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   export default { @@ -721,7 +727,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 0d2abb2..869ce22 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,28 +20,28 @@

- 76.72% + 80.95% Statements - 178/232 + 187/231
- 75% + 80.17% Branches - 87/116 + 93/116
- 66.67% + 65.48% Functions - 56/84 + 55/84
- 76.72% + 80.95% Lines - 178/232 + 187/231
-
+
@@ -59,42 +59,42 @@

- - - - + + + + - - - - + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index d0cd455..09611f8 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -20,28 +20,28 @@

- 82.5% + 72.5% Statements - 33/40 + 29/40
- 72.22% + 66.67% Branches - 13/18 + 12/18
- 80.95% + 66.67% Functions - 17/21 + 14/21
- 82.5% + 72.5% Lines - 33/40 + 29/40
-
+
documents.js
81.16%56/69documents.js
79.71%55/69 85.71% 36/4264%16/2581.16%56/6960%15/2579.71%55/69
roles.js
82.5%33/4072.22%13/1880.95%17/2182.5%33/40roles.js
72.5%29/4066.67%12/1866.67%14/2172.5%29/40
search.js
41.67%15/3621.43%3/1425%2/841.67%15/36search.js
82.86%29/3571.43%10/1462.5%5/882.86%29/35
- - - - - - - - - - + + + + + + + + + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index 09611f8..d38538d 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -20,28 +20,28 @@

- 72.5% + 80% Statements - 29/40 + 32/40
- 66.67% + 72.22% Branches - 12/18 + 13/18
- 66.67% + 76.19% Functions - 14/21 + 16/21
- 72.5% + 80% Lines - 29/40 + 32/40
-
+
1 2 @@ -176,8 +176,7 @@

131 132 133 -134 -135

1x +1341x   1x   @@ -233,12 +232,12 @@

      -4x +3x 1x       -3x +2x     2x @@ -247,7 +246,7 @@

    1x -1x +        @@ -258,11 +257,11 @@

      -3x +2x       -3x +2x     2x @@ -279,7 +278,7 @@

      -1x +        @@ -289,25 +288,24 @@

      -3x +1x       -3x +1x   -2x 1x +        -2x +1x         -  1x -2x +        @@ -381,7 +379,7 @@

}); } res.status(200).json(role); - }).catch(error => res.status(400).json(error)); + }).catch(error => res.status(400).json(error)); } }   @@ -413,7 +411,7 @@

role })) .catch(error => res.status(400).json(error)); - }).catch(error => res.status(400).json(error)); + }).catch(error => res.status(400).json(error)); }   /** @@ -429,19 +427,18 @@

} return Role.findById(req.params.id) .then((role) => { - if (!role) { - res.status(404).json({ + Iif (!role) { + res.status(404).json({ message: 'Role not found' }); } return role .destroy() - .then(() => res.status(204) - .json({ - message: 'Role deleted successfully' - })) + .then(() => res.status(204).send({ + message: 'Role deleted successfully' + })) .catch(error => res.status(400).send(error)); - }).catch(error => res.json(error)); + }).catch(error => res.json(error)); }   export default { createRole, getRoles, findRole, updateRole, deleteRole }; @@ -451,7 +448,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index 471e156..f645d1b 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -20,28 +20,28 @@

- 41.67% + 82.86% Statements - 15/36 + 29/35
- 21.43% + 71.43% Branches - 3/14 + 10/14
- 25% + 62.5% Functions - 2/8 + 5/8
- 41.67% + 82.86% Lines - 15/36 + 29/35
-
+

@@ -94,7 +94,7 @@ 

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index ecba766..774a0df 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -135,7 +135,7 @@

.delete(auth.verifyToken, userController.deleteUser);   router.route('/:id/documents') - /** GET /api/users/id/documents - get user document */ + /** GET /api/users/id/documents - Find documents of a specific user*/ .get(auth.verifyToken, userController.getUserDocuments);   export default router; @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html index 4be26a0..f2c5cb0 100644 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -20,9 +20,9 @@

- 96.74% + 97.07% Statements - 178/184 + 199/205
100% @@ -30,14 +30,14 @@

0/0

- 98.21% + 98.39% Functions - 55/56 + 61/62
- 96.7% + 97.04% Lines - 176/182 + 197/203
@@ -400,7 +400,64 @@

355 356 357 -358

- - - + + + - - - - + + + + @@ -86,28 +86,28 @@

- - - + + + - - - + + + - - - + + + - - + + @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html index da1b8aa..92d7937 100644 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -208,7 +208,7 @@

diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html index e1ad90a..d98b530 100644 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -20,9 +20,9 @@

- 93.71% + 94.7% Statements - 149/159 + 125/132
100% @@ -32,12 +32,12 @@

100% Functions - 50/50 + 42/42
- 93.63% + 94.62% Lines - 147/157 + 123/130

@@ -523,16 +523,16 @@

1x     -1x -1x -1x       -1x -1x   -  +  +  +  +  +  +        @@ -580,20 +580,20 @@

1x     -1x     -1x -1x         -1x -1x -1x   -  +  +  +  +  +  +  +        @@ -622,31 +622,31 @@

1x     -1x   -1x -1x       -1x -1x -1x -1x     -1x   -1x -1x       -1x -1x -1x   -  +  +  +  +  +  +  +  +  +  +  +  +  +  +        @@ -827,18 +827,18 @@

done(); }); }); - it('Should fail to get a role by id if the id is out of range', (done) => { - const id = 500000000000000000000; - chai.request(server) - .get(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it('Should fail to get a role by id if the id is out of range', (done) => { + // const id = 500000000000000000000; + // chai.request(server) + // .get(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); describe('/PUT/:id Role', () => { it('Should update a role by id if the user has admin access', (done) => { @@ -884,22 +884,22 @@

done(); }); }); - it(`Should fail to update a role by - id if the admin enters an id that is out range`, - (done) => { - const id = 2000000000000000; - chai.request(server) - .put(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .send({ title: 'regular' }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it(`Should fail to update a role by + // id if the admin enters an id that is out range`, + // (done) => { + // const id = 2000000000000000; + // chai.request(server) + // .put(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .send({ title: 'regular' }) + // .end((err, res) => { + // expect(res.status).to.equal(400); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); describe('/DELETE/:id Role', () => { it('Should delete a role given the user has admin access', (done) => { @@ -926,33 +926,33 @@

done(); }); }); - it('Should fail to delete a role given the admin enters an invalid input', - (done) => { - const id = 300; - chai.request(server) - .delete(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it(`Should fail to delete a role given - the admin enters an input that is out of range`, (done) => { - const id = 3000000000000000; - chai.request(server) - .delete(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message) - .to.eql(`value "${id}" is out of range for type integer`); - done(); - }); - }); + // it('Should fail to delete a role given the admin enters an invalid input', + // (done) => { + // const id = 300; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(404); + // expect(res.body).to.be.a('object'); + // expect(res.body.message).to.equal('Role not found'); + // done(); + // }); + // }); + // it(`Should fail to delete a role given + // the admin enters an input that is out of range`, (done) => { + // const id = 3000000000000000; + // chai.request(server) + // .delete(`/api/v1/roles/${id}`) + // .set({ authorization: adminToken }) + // .end((err, res) => { + // expect(res.status).to.equal(200); + // expect(res.body).to.be.a('object'); + // expect(res.body.message) + // .to.eql(`value "${id}" is out of range for type integer`); + // done(); + // }); + // }); }); });  

@@ -961,7 +961,7 @@

diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html index 753d923..8876054 100644 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -20,9 +20,9 @@

- 83.87% + 98.33% Statements - 52/62 + 59/60
100% @@ -35,9 +35,9 @@

19/19

- 83.33% + 98.28% Lines - 50/60 + 57/58
@@ -151,8 +151,7 @@

106 107 108 -109 -110

@@ -376,7 +373,7 @@

diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html index cde0057..e583780 100644 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -920,7 +920,7 @@

it('Should get all users if the user is an admin ', (done) => { request(server) .get('/api/v1/users') - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -932,7 +932,7 @@

(done) => { request(server) .get('/api/v1/users') - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); @@ -954,7 +954,7 @@

const limit = 1; chai.request(server) .get(`/api/v1/users?limit=${limit}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); @@ -969,7 +969,7 @@

const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -986,7 +986,7 @@

const id = 2; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('array'); @@ -1003,7 +1003,7 @@

const id = 'fddjsdcdjn'; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.property('message') @@ -1016,7 +1016,7 @@

const id = 2; request(server) .get(`api/users/${id}`) - .set({ 'authorization': sampleUserToken }) + .set({ authorization: sampleUserToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.have.keys(['message']); @@ -1029,7 +1029,7 @@

const id = 250; request(server) .get(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.have.property('message'); @@ -1057,7 +1057,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ fullName: 'jake doe' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1071,7 +1071,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1086,7 +1086,7 @@

const id = 2; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ userName: 'jakedoe12' }) .end((err, res) => { expect(res.status).to.equal(200); @@ -1102,7 +1102,7 @@

const id = 3; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -1118,7 +1118,7 @@

const id = 2302; request(server) .put(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) .end((err, res) => { expect(res.status).to.equal(401); @@ -1134,7 +1134,7 @@

const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(204); done(); @@ -1145,7 +1145,7 @@

const id = 3; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body.message) @@ -1157,7 +1157,7 @@

const id = 23; request(server) .delete(`/api/v1/users/${id}`) - .set({ 'authorization': adminToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); @@ -1171,7 +1171,7 @@

const userId = 9; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).be.a('object'); @@ -1196,14 +1196,14 @@

const userId = 2; request(server) .get(`/api/v1/users/${userId}/documents`) - .set({ 'authorization': userToken }) + .set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(200); expect(res.body).be.a('object'); expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('boromir-team'); + expect(res.body.document[1].title).to.eql('hey yo!'); expect(res.body.document[1].content) - .to.eql('Andela is really awesome!!!'); + .to.eql('Andela is really fun!!'); done(); }); }); @@ -1216,7 +1216,7 @@

diff --git a/coverage/index.html b/coverage/index.html index 741d10d..010797d 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,24 +20,24 @@

- 91.21% + 93.42% Statements - 882/967 + 895/958
- 75.91% + 80.29% Branches - 104/137 + 110/137
- 89.97% + 89.55% Functions - 260/289 + 257/287
- 91.12% + 93.35% Lines - 872/957 + 885/948
@@ -85,16 +85,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -151,15 +151,15 @@

- - - + + + - - - + + + @@ -168,7 +168,7 @@

diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index ccd5109..a5f150d 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -16,14 +16,6 @@ var _gulpMocha = require('gulp-mocha'); var _gulpMocha2 = _interopRequireDefault(_gulpMocha); -var _gulpIstanbul = require('gulp-istanbul'); - -var _gulpIstanbul2 = _interopRequireDefault(_gulpIstanbul); - -var _gulpInjectModules = require('gulp-inject-modules'); - -var _gulpInjectModules2 = _interopRequireDefault(_gulpInjectModules); - var _gulpExit = require('gulp-exit'); var _gulpExit2 = _interopRequireDefault(_gulpExit); @@ -56,7 +48,7 @@ _gulp2.default.task('babel', function () { }); _gulp2.default.task('coverage', function () { - _gulp2.default.src('dist/server/test/**/*.js', { read: false }).pipe(_gulpCoverage2.default.instrument({ + _gulp2.default.src('server/test/**/*.js', { read: false }).pipe(_gulpCoverage2.default.instrument({ pattern: ['server/controllers/**/*.js'], debugDirectory: 'debug' })).pipe((0, _gulpMocha2.default)()).pipe(_gulpCoverage2.default.gather()).pipe(_gulpCoverage2.default.format()).pipe(_gulp2.default.dest('reports')); diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js index b3268df..04f90f1 100644 --- a/dist/server/controllers/documents.js +++ b/dist/server/controllers/documents.js @@ -45,8 +45,8 @@ function createDocument(req, res) { content: req.body.content, access: req.body.value, userId: req.body.userId - }).then(function () { - return res.status(200).send(document); + }).then(function (documentResponse) { + return res.status(200).send(documentResponse); }).catch(function (error) { return res.status(400).send(error); }); @@ -161,7 +161,6 @@ function getAllDocument(req, res) { } } -<<<<<<< HEAD /** * Find a document by Id * @param {number} req - id of the requested document @@ -182,37 +181,14 @@ function findDocument(req, res) { if (document.access === 'private') { if (document.userId !== req.decoded.id) { return res.status(401).json({ -======= -function findDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - return res.status(404).json({ - message: 'Document not found' - }); - } - if (req.decoded.roleId === 1) { - return res.json(document); - } - if (document.access === 'public') { - res.status(200).send(document); - } - if (document.access === 'private') { - if (document.userId !== req.decoded.id) { - res.status(401).json({ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 message: 'You are not authorized to view this document' }); } return res.status(200).send(document); } if (document.access === 'role') { -<<<<<<< HEAD return _models2.default.User.findById(document.userId).then(function (documentOwner) { if (Number(documentOwner.roleId) !== Number(req.decoded.roleId)) { -======= - return _models2.default.User.findById(document.userId).then(function (documentAuthor) { - if (Number(documentAuthor.roleId) !== Number(req.decoded.roleId)) { ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 return res.status(401).json({ message: 'You are not authorized to view this document' }); @@ -227,26 +203,18 @@ function findDocument(req, res) { }); } -<<<<<<< HEAD /** - * * Delete a document by Id * @param {number} req - id of the requested document * @param {object} res - message * @returns {object} - message */ -function deleteDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - res.status(404).json({ message: 'Document not found' }); -======= function deleteDocument(req, res) { return Document.findById(req.params.id).then(function (document) { if (!document) { return res.status(404).send({ message: 'Document Not Found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } if (req.decoded.roleId !== 1 && Number(document.userId) !== Number(req.decoded.id)) { return res.status(401).json({ @@ -254,13 +222,9 @@ function deleteDocument(req, res) { }); } return document.destroy().then(function () { -<<<<<<< HEAD - return res.status(204).send({ message: 'Document deleted successfully' }); -======= return res.status(204).send({ message: 'Document successfully deleted' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 }).catch(function (error) { return res.status(400).send(error); }); @@ -274,9 +238,4 @@ exports.default = { updateDocument: updateDocument, getAllDocument: getAllDocument, findDocument: findDocument, -<<<<<<< HEAD - deleteDocument: deleteDocument }; -======= - deleteDocument: deleteDocument -}; ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 + deleteDocument: deleteDocument }; \ No newline at end of file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js index 13d610b..a2e80f8 100644 --- a/dist/server/controllers/roles.js +++ b/dist/server/controllers/roles.js @@ -62,7 +62,6 @@ function getRoles(req, res) { * @returns {object} - role found by id */ function findRole(req, res) { -<<<<<<< HEAD if (isNaN(req.params.id)) { return res.status(401).json({ message: 'invalid input syntax for integer: "' + req.params.id + '"' @@ -79,18 +78,6 @@ function findRole(req, res) { return res.status(400).json(error); }); } -======= - return Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(function (error) { - return res.status(400).json(error); - }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } /** @@ -141,11 +128,7 @@ function deleteRole(req, res) { }); } return role.destroy().then(function () { -<<<<<<< HEAD - return res.status(204).json({ -======= return res.status(204).send({ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 message: 'Role deleted successfully' }); }).catch(function (error) { diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js index 80ff77f..fa9f13b 100644 --- a/dist/server/controllers/search.js +++ b/dist/server/controllers/search.js @@ -16,7 +16,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de var Document = _models2.default.Document; var User = _models2.default.User; -var Document = _models2.default.Document; var metaData = _helper2.default.paginationMetaData; /** @@ -59,7 +58,6 @@ function searchUser(req, res) { }); } -<<<<<<< HEAD /** * * Search for documents by title @@ -67,8 +65,6 @@ function searchUser(req, res) { * @param {array} res - an array containing searched document * @returns {array} - searched document */ -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 function searchDocuments(req, res) { var limit = req.query.limit, offset = req.query.offset, @@ -99,13 +95,9 @@ function searchDocuments(req, res) { count = _ref2.count; if (count === 0) { -<<<<<<< HEAD - res.status(404).json({ message: 'Document not found' }); -======= return res.status(404).json({ message: 'Document not found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } res.status(200).send({ document: document, @@ -139,13 +131,9 @@ function searchDocuments(req, res) { count = _ref3.count; if (count === 0) { -<<<<<<< HEAD - res.status(404).json({ message: 'Document not found' }); -======= return res.status(404).json({ message: 'Document not found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } res.status(200).send({ document: document, diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 057f297..6496518 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -27,7 +27,6 @@ require('dotenv').config(); var jwtSecret = process.env.JWT_SECRET; var Document = _models2.default.Document; var User = _models2.default.User; -var Document = _models2.default.Document; var metaData = _helper2.default.paginationMetaData; /** @@ -253,16 +252,12 @@ function deleteUser(req, res) { }); } -<<<<<<< HEAD /** - * * Get documents for specific user * @param {object} req - request object containing limit query and offset * @param {array} res - array of documents for the requested user * @return {array} - array of requested user's document */ -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 function getUserDocuments(req, res) { var limit = req.query.limit; var offset = req.query.offset; diff --git a/dist/server/models/document.js b/dist/server/models/document.js index 75fe6b6..d204122 100644 --- a/dist/server/models/document.js +++ b/dist/server/models/document.js @@ -21,10 +21,6 @@ module.exports = function (sequelize, DataTypes) { } }); Document.associate = function (models) { -<<<<<<< HEAD - // associations can be defined here -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 Document.belongsTo(models.User, { foreignKey: 'userId' }); diff --git a/dist/server/models/role.js b/dist/server/models/role.js index 2f758f5..4979353 100644 --- a/dist/server/models/role.js +++ b/dist/server/models/role.js @@ -9,10 +9,6 @@ module.exports = function (sequelize, DataTypes) { } }); Role.associate = function (models) { -<<<<<<< HEAD - // associations can be defined here -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 Role.hasMany(models.User, { foreignKey: 'roleId' }); diff --git a/dist/server/models/user.js b/dist/server/models/user.js index 9bc2f07..def997e 100644 --- a/dist/server/models/user.js +++ b/dist/server/models/user.js @@ -27,10 +27,6 @@ module.exports = function (sequelize, DataTypes) { } }); User.associate = function (models) { -<<<<<<< HEAD - // associations can be defined here -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 User.hasMany(models.Document, { foreignKey: 'userId', onDelete: 'CASCADE', diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js index c857edd..f57376c 100644 --- a/dist/server/routes/documents.js +++ b/dist/server/routes/documents.js @@ -31,17 +31,10 @@ router.route('/:id') /** PUT /api/v1/documents/id - Create document */ .put(_auth2.default.verifyToken, _documents2.default.updateDocument) -<<<<<<< HEAD -/** GET /api/v1/documents/id - find document */ -.get(_auth2.default.verifyToken, _documents2.default.findDocument) - -/** GET /api/v1/documents/id - find document */ -======= /** GET /api/v1/documents/id - get document */ .get(_auth2.default.verifyToken, _documents2.default.findDocument) /** DELETE /api/v1/documents/id - delete document */ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 .delete(_auth2.default.verifyToken, _documents2.default.deleteDocument); exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js index 8600169..ea6c0e2 100644 --- a/dist/server/routes/search.js +++ b/dist/server/routes/search.js @@ -25,12 +25,7 @@ router.route('/users') .get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); router.route('/documents') -<<<<<<< HEAD -/** GET /api/documents - Get list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchDocuments); -======= /** GET /api/v1/search - search list of documents */ .get(_auth2.default.verifyToken, _search2.default.searchDocuments); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js index 835bbda..4eb365a 100644 --- a/dist/server/routes/users.js +++ b/dist/server/routes/users.js @@ -42,11 +42,7 @@ router.route('/:id') .delete(_auth2.default.verifyToken, _users2.default.deleteUser); router.route('/:id/documents') -<<<<<<< HEAD -/** GET /api/users/id/documents - get user document */ -======= /** GET /api/users/id/documents - Find documents of a specific user*/ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 .get(_auth2.default.verifyToken, _users2.default.getUserDocuments); exports.default = router; \ No newline at end of file diff --git a/dist/server/test/controllers/document.spec.js b/dist/server/test/controllers/document.spec.js index 22c9ddc..fb9ffdf 100644 --- a/dist/server/test/controllers/document.spec.js +++ b/dist/server/test/controllers/document.spec.js @@ -54,17 +54,17 @@ describe('Documents', function () { describe('/POST Document', function () { it('should add a new document if the user is authenticated', function (done) { var document = { - title: 'boromir-team', - content: 'Andela is really awesome!!!', + title: 'hey yo!', + content: 'Andela is really fun!!', access: 'public', userId: 2 }; (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(201); + expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('boromir-team'); - expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.title).to.eql('hey yo!'); + expect(res.body.content).to.eql('Andela is really fun!!'); expect(res.body.access).to.equal('public'); done(); }); @@ -95,6 +95,20 @@ describe('Documents', function () { done(); }); }); + it('should fail to add a new document if the value field is missing', function (done) { + var document = { + title: 'kiba-team', + content: 'Andela is really awesome!!!', + access: '', + userId: 1 + }; + _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.be.equal('accessType is required'); + done(); + }); + }); }); describe('/GET Documents', function () { @@ -149,7 +163,7 @@ describe('Documents', function () { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('boromir-team'); + expect(res.body.title).to.equal('hey yo!'); expect(res.body.access).to.equal('public'); done(); }); @@ -275,7 +289,7 @@ describe('Documents', function () { _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); + expect(res.body.message).to.eql('Document Not Found'); done(); }); }); diff --git a/dist/server/test/controllers/role.spec.js b/dist/server/test/controllers/role.spec.js index 4885a7d..6d28fb3 100644 --- a/dist/server/test/controllers/role.spec.js +++ b/dist/server/test/controllers/role.spec.js @@ -82,18 +82,14 @@ describe('Roles', function () { done(); }); }); - // it('Should return an error if the title is not a string', (done) => { - // chai.request(server) - // .post('/api/v1/roles') - // .set({ authorization: adminToken }) - // .send({ title: 358583 }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.eql('Invalid input credentials'); - // done(); - // }); - // }); + it('Should return an error if the title is not a string', function (done) { + _chai2.default.request(_index2.default).post('/api/v1/roles').set({ authorization: adminToken }).send({ title: 358583 }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Invalid input credentials'); + done(); + }); + }); }); describe('/GET Role', function () { diff --git a/dist/server/test/controllers/search.spec.js b/dist/server/test/controllers/search.spec.js index 1fa1e38..ebcbf38 100644 --- a/dist/server/test/controllers/search.spec.js +++ b/dist/server/test/controllers/search.spec.js @@ -71,43 +71,34 @@ describe('Search', function () { }); }); }); - // describe('/SEARCH/documents/?q=', () => { - // it('Should return an error if no querystring is provided', (done) => { - // const query = ''; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message).to.eql('Invalid search input'); - // done(); - // }); - // }); - // it('Should return a search list of the required search input', (done) => { - // const query = 'John'; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.have.property('document'); - // expect(res.body.document[0].title).to.equal('John Doe'); - // expect(res.body.document[0].content).to.equal('eze goes to school'); - // expect(res.body).to.have.property('pagination'); - // expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - // done(); - // }); - // }); - // it('Should throw an error if the searched document is not found', (done) => { - // const query = 'jk'; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body.message).to.equal('Document not found'); - // done(); - // }); - // }); - // }); + describe('/SEARCH/documents/?q=', function () { + it('Should return an error if no querystring is provided', function (done) { + var query = ''; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('Invalid search input'); + done(); + }); + }); + it('Should return a search list of the required search input', function (done) { + var query = 'John'; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(200); + expect(res.body).to.have.property('document'); + expect(res.body.document[0].title).to.equal('John Doe'); + expect(res.body.document[0].content).to.equal('eze goes to school'); + expect(res.body).to.have.property('pagination'); + expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + done(); + }); + }); + it('Should throw an error if the searched document is not found', function (done) { + var query = 'jk'; + (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body.message).to.equal('Document not found'); + done(); + }); + }); + }); }); \ No newline at end of file diff --git a/dist/server/test/controllers/user.spec.js b/dist/server/test/controllers/user.spec.js index 954e573..d747a63 100644 --- a/dist/server/test/controllers/user.spec.js +++ b/dist/server/test/controllers/user.spec.js @@ -185,19 +185,14 @@ describe('Users', function () { done(); }); }); - // it('Should fail to get a user if the id is out of range', - // (done) => { - // const id = 500000000000000000; - // request(server) - // .get(`/api/v1/users/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.have.property('message') - // .to.equal(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to get a user if the id is out of range', function (done) { + var id = 500000000000000000; + (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message').to.equal('value "' + id + '" is out of range for type integer'); + done(); + }); + }); }); describe('#PUT Update user by Id', function () { it('Should update a user`s full name if the user has the same id', function (done) { @@ -301,8 +296,8 @@ describe('Users', function () { expect(res.status).to.equal(200); expect(res.body).be.a('object'); expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('boromir-team'); - expect(res.body.document[1].content).to.eql('Andela is really awesome!!!'); + expect(res.body.document[1].title).to.eql('hey yo!'); + expect(res.body.document[1].content).to.eql('Andela is really fun!!'); done(); }); }); diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 4bc706b..10fcfd6 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -2,8 +2,6 @@ import gulp from 'gulp'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; import mocha from 'gulp-mocha'; -import istanbul from 'gulp-istanbul'; -import injectModules from 'gulp-inject-modules'; import exit from 'gulp-exit'; import coveralls from 'gulp-coveralls'; import cover from 'gulp-coverage'; @@ -32,7 +30,7 @@ gulp.task('babel', () => ); gulp.task('coverage', () => { - gulp.src('dist/server/test/**/*.js', { read: false }) + gulp.src('server/test/**/*.js', { read: false }) .pipe(cover.instrument({ pattern: ['server/controllers/**/*.js'], debugDirectory: 'debug' diff --git a/package.json b/package.json index fe24f6b..c874f70 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,10 @@ "scripts": { "start": "gulp production && node ./dist/index.js", "dev": "node node_modules/gulp/bin/gulp", - "pretest": "npm run cleardb && NODE_ENV=test sequelize db:migrate && NODE_ENV=test sequelize db:seed:all", - "test": "NODE_ENV=test node node_modules/gulp/bin/gulp coverage && gulp coveralls", - "devtest": "NODE_ENV=test gulp test", - "eslint": "eslint server.js", - "cleardb": "NODE_ENV=test sequelize db:migrate:undo:all" + "test:db:migrate": "NODE_ENV=test sequelize db:migrate:undo:all && NODE_ENV=test sequelize db:migrate", + "test:db:seed": "NODE_ENV=test sequelize db:seed:all", + "start:test:db": "npm run test:db:migrate && npm run test:db:seed", + "server-test": "npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000" }, "repository": { "type": "git", diff --git a/server/controllers/documents.js b/server/controllers/documents.js index 942e972..1fd46fd 100644 --- a/server/controllers/documents.js +++ b/server/controllers/documents.js @@ -33,7 +33,7 @@ function createDocument(req, res) { access: req.body.value, userId: req.body.userId }) - .then(() => res.status(200).send(document)) + .then(documentResponse => res.status(200).send(documentResponse)) .catch(error => res.status(400).send(error)); } return res.status(403).json({ @@ -141,7 +141,6 @@ function getAllDocument(req, res) { } } -<<<<<<< HEAD /** * Find a document by Id * @param {number} req - id of the requested document @@ -188,66 +187,18 @@ function findDocument(req, res) { } /** - * * Delete a document by Id * @param {number} req - id of the requested document * @param {object} res - message * @returns {object} - message */ -======= -function findDocument(req, res) { - return Document.findById(req.params.id) - .then((document) => { - if (!document) { - return res.status(404).json({ - message: 'Document not found' - }); - } - if (req.decoded.roleId === 1) { - return res.json(document); - } - if (document.access === 'public') { - res.status(200).send(document); - } - if (document.access === 'private') { - if (document.userId !== req.decoded.id) { - res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - } - if (document.access === 'role') { - return models.User - .findById(document.userId) - .then((documentAuthor) => { - if ( - Number(documentAuthor.roleId) !== Number(req.decoded.roleId) - ) { - return res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - }) - .catch(error => res.status(400).send(error)); - } - }) - .catch(error => res.status(400).send(error)); -} - ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 function deleteDocument(req, res) { return Document.findById(req.params.id) .then((document) => { if (!document) { -<<<<<<< HEAD - res.status(404).json({ message: 'Document not found' }); -======= return res.status(404).send({ message: 'Document Not Found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } if ( req.decoded.roleId !== 1 && @@ -259,14 +210,9 @@ function deleteDocument(req, res) { } return document .destroy() -<<<<<<< HEAD - .then(() => res.status(204) - .send({ message: 'Document deleted successfully' })) -======= .then(() => res.status(204).send({ message: 'Document successfully deleted' })) ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 .catch(error => res.status(400).send(error)); }) .catch(error => res.status(400).send(error)); @@ -277,9 +223,4 @@ export default { updateDocument, getAllDocument, findDocument, -<<<<<<< HEAD deleteDocument }; -======= - deleteDocument -}; ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 diff --git a/server/controllers/roles.js b/server/controllers/roles.js index 0a3dc82..7061789 100644 --- a/server/controllers/roles.js +++ b/server/controllers/roles.js @@ -54,7 +54,6 @@ function getRoles(req, res) { * @returns {object} - role found by id */ function findRole(req, res) { -<<<<<<< HEAD if (isNaN(req.params.id)) { return res.status(401).json({ message: `invalid input syntax for integer: "${req.params.id}"` @@ -71,18 +70,6 @@ function findRole(req, res) { res.status(200).json(role); }).catch(error => res.status(400).json(error)); } -======= - return Role - .findById(req.params.id) - .then((role) => { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(error => res.status(400).json(error)); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } /** @@ -136,14 +123,9 @@ function deleteRole(req, res) { } return role .destroy() - .then(() => res.status(204) -<<<<<<< HEAD - .json({ -======= - .send({ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 - message: 'Role deleted successfully' - })) + .then(() => res.status(204).send({ + message: 'Role deleted successfully' + })) .catch(error => res.status(400).send(error)); }).catch(error => res.json(error)); } diff --git a/server/controllers/search.js b/server/controllers/search.js index 9ec3c3d..19f88f1 100644 --- a/server/controllers/search.js +++ b/server/controllers/search.js @@ -3,7 +3,6 @@ import models from '../models'; const Document = models.Document; const User = models.User; -const Document = models.Document; const metaData = helper.paginationMetaData; /** @@ -42,7 +41,6 @@ function searchUser(req, res) { }).catch(error => res.status(400).send(error)); } -<<<<<<< HEAD /** * * Search for documents by title @@ -50,8 +48,6 @@ function searchUser(req, res) { * @param {array} res - an array containing searched document * @returns {array} - searched document */ -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 function searchDocuments(req, res) { const limit = req.query.limit, offset = req.query.offset, @@ -82,13 +78,9 @@ function searchDocuments(req, res) { }) .then(({ rows: document, count }) => { if (count === 0) { -<<<<<<< HEAD - res.status(404).json({ message: 'Document not found' }); -======= return res.status(404).json({ message: 'Document not found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } res.status(200).send({ document, @@ -121,13 +113,9 @@ function searchDocuments(req, res) { }) .then(({ rows: document, count }) => { if (count === 0) { -<<<<<<< HEAD - res.status(404).json({ message: 'Document not found' }); -======= return res.status(404).json({ message: 'Document not found' }); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 } res.status(200).send({ document, diff --git a/server/controllers/users.js b/server/controllers/users.js index f6fd464..ecdfcf2 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -9,7 +9,6 @@ require('dotenv').config(); const jwtSecret = process.env.JWT_SECRET; const Document = models.Document; const User = models.User; -const Document = models.Document; const metaData = helper.paginationMetaData; /** @@ -239,16 +238,12 @@ function deleteUser(req, res) { .catch(error => res.status(400).send(error)); } -<<<<<<< HEAD /** - * * Get documents for specific user * @param {object} req - request object containing limit query and offset * @param {array} res - array of documents for the requested user * @return {array} - array of requested user's document */ -======= ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 function getUserDocuments(req, res) { const limit = req.query.limit; const offset = req.query.offset; diff --git a/server/routes/documents.js b/server/routes/documents.js index b6c1a07..3224ec3 100644 --- a/server/routes/documents.js +++ b/server/routes/documents.js @@ -15,17 +15,10 @@ router.route('/:id') /** PUT /api/v1/documents/id - Create document */ .put(auth.verifyToken, documentController.updateDocument) -<<<<<<< HEAD - /** GET /api/v1/documents/id - find document */ - .get(auth.verifyToken, documentController.findDocument) - - /** GET /api/v1/documents/id - find document */ -======= /** GET /api/v1/documents/id - get document */ .get(auth.verifyToken, documentController.findDocument) /** DELETE /api/v1/documents/id - delete document */ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 .delete(auth.verifyToken, documentController.deleteDocument); export default router; diff --git a/server/routes/search.js b/server/routes/search.js index b21722e..ccca593 100644 --- a/server/routes/search.js +++ b/server/routes/search.js @@ -9,12 +9,7 @@ router.route('/users') .get(auth.verifyToken, auth.adminAccess, searchController.searchUser); router.route('/documents') -<<<<<<< HEAD - /** GET /api/documents - Get list of users */ - .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments); -======= /** GET /api/v1/search - search list of documents */ .get(auth.verifyToken, searchController.searchDocuments); ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 export default router; diff --git a/server/routes/users.js b/server/routes/users.js index bd55d90..e1bb222 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -26,11 +26,7 @@ router.route('/:id') .delete(auth.verifyToken, userController.deleteUser); router.route('/:id/documents') -<<<<<<< HEAD - /** GET /api/users/id/documents - get user document */ -======= /** GET /api/users/id/documents - Find documents of a specific user*/ ->>>>>>> 4f5d186dbe87514d3eeabae2b55811aef05eb4c6 .get(auth.verifyToken, userController.getUserDocuments); export default router; diff --git a/server/test/controllers/document.spec.js b/server/test/controllers/document.spec.js index 438e6ef..422caa9 100644 --- a/server/test/controllers/document.spec.js +++ b/server/test/controllers/document.spec.js @@ -41,8 +41,8 @@ describe('Documents', () => { describe('/POST Document', () => { it('should add a new document if the user is authenticated', (done) => { const document = { - title: 'boromir-team', - content: 'Andela is really awesome!!!', + title: 'hey yo!', + content: 'Andela is really fun!!', access: 'public', userId: 2, }; @@ -51,11 +51,11 @@ describe('Documents', () => { .send(document) .set({ authorization: userToken }) .end((err, res) => { - expect(res.status).to.equal(201); + expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('boromir-team'); - expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.title).to.eql('hey yo!'); + expect(res.body.content).to.eql('Andela is really fun!!'); expect(res.body.access).to.equal('public'); done(); }); @@ -93,6 +93,63 @@ describe('Documents', () => { done(); }); }); + it('should fail to add a new document if the access field is missing', + (done) => { + const document = { + title: 'boromir-team', + content: 'Andela is really awesome!!!', + access: '', + userId: 1, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('accessType is required'); + done(); + }); + }); + it('should fail to add a new document if the title field is missing', + (done) => { + const document = { + title: '', + content: 'Andela is really awesome!!!', + value: 'public', + userId: 2, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Title is required'); + done(); + }); + }); + it('should fail to add a new document if the content field is missing', + (done) => { + const document = { + title: 'boromir-team', + content: '', + value: 'public', + userId: 2, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Content is required'); + done(); + }); + }); }); describe('/GET Documents', () => { @@ -166,7 +223,7 @@ describe('Documents', () => { expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('boromir-team'); + expect(res.body.title).to.equal('hey yo!'); expect(res.body.access).to.equal('public'); done(); }); @@ -349,7 +406,7 @@ describe('Documents', () => { .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); + expect(res.body.message).to.eql('Document Not Found'); done(); }); }); diff --git a/server/test/controllers/role.spec.js b/server/test/controllers/role.spec.js index 80cef32..78be137 100644 --- a/server/test/controllers/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -81,18 +81,18 @@ describe('Roles', () => { done(); }); }); - // it('Should return an error if the title is not a string', (done) => { - // chai.request(server) - // .post('/api/v1/roles') - // .set({ authorization: adminToken }) - // .send({ title: 358583 }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.eql('Invalid input credentials'); - // done(); - // }); - // }); + it('Should return an error if the title is not a string', (done) => { + chai.request(server) + .post('/api/v1/roles') + .set({ authorization: adminToken }) + .send({ title: 358583 }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Invalid input credentials'); + done(); + }); + }); }); describe('/GET Role', () => { diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index e0b4bfe..ed89bfb 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -65,43 +65,44 @@ describe('Search', () => { }); }); }); - // describe('/SEARCH/documents/?q=', () => { - // it('Should return an error if no querystring is provided', (done) => { - // const query = ''; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message).to.eql('Invalid search input'); - // done(); - // }); - // }); - // it('Should return a search list of the required search input', (done) => { - // const query = 'John'; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.have.property('document'); - // expect(res.body.document[0].title).to.equal('John Doe'); - // expect(res.body.document[0].content).to.equal('eze goes to school'); - // expect(res.body).to.have.property('pagination'); - // expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - // done(); - // }); - // }); - // it('Should throw an error if the searched document is not found', (done) => { - // const query = 'jk'; - // request(server) - // .get(`/api/v1/search/documents/?q=${query}`) - // .set({ authorization: userToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body.message).to.equal('Document not found'); - // done(); - // }); - // }); - // }); + describe('/SEARCH/documents/?q=', () => { + it('Should return an error if no querystring is provided', (done) => { + const query = ''; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('Invalid search input'); + done(); + }); + }); + it('Should return a search list of the required search input', (done) => { + const query = 'John'; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(200); + expect(res.body).to.have.property('document'); + expect(res.body.document[0].title).to.equal('John Doe'); + expect(res.body.document[0].content).to.equal('eze goes to school'); + expect(res.body).to.have.property('pagination'); + expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); + done(); + }); + }); + it('Should throw an error if the searched document is not found', + (done) => { + const query = 'jk'; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body.message).to.equal('Document not found'); + done(); + }); + }); + }); }); diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index 47231b6..cc593d6 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -214,19 +214,19 @@ describe('Users', () => { done(); }); }); - // it('Should fail to get a user if the id is out of range', - // (done) => { - // const id = 500000000000000000; - // request(server) - // .get(`/api/v1/users/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.have.property('message') - // .to.equal(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to get a user if the id is out of range', + (done) => { + const id = 500000000000000000; + request(server) + .get(`/api/v1/users/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.have.property('message') + .to.equal(`value "${id}" is out of range for type integer`); + done(); + }); + }); }); describe('#PUT Update user by Id', () => { it('Should update a user`s full name if the user has the same id', @@ -378,9 +378,9 @@ describe('Users', () => { expect(res.status).to.equal(200); expect(res.body).be.a('object'); expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('boromir-team'); + expect(res.body.document[1].title).to.eql('hey yo!'); expect(res.body.document[1].content) - .to.eql('Andela is really awesome!!!'); + .to.eql('Andela is really fun!!'); done(); }); }); From 8feb9d032711069307c4142d1d42fb987043f4fa Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Wed, 2 Aug 2017 07:42:56 +0100 Subject: [PATCH 41/98] feat(testing):fixing gulp-mocha coverage -trying different pattern to show mocha coverage --- coverage/auth.spec.js.html | 383 ----- coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 14 +- .../document-manager/server/config/index.html | 2 +- .../server/controllers/documents.js.html | 2 +- .../server/controllers/index.html | 38 +- .../server/controllers/roles.js.html | 90 +- .../server/controllers/search.js.html | 2 +- .../server/controllers/searches.js.html | 440 ------ .../server/controllers/users.js.html | 12 +- .../server/helpers/helper.js.html | 2 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 18 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 2 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 2 +- .../server/routes/searches.js.html | 110 -- .../server/routes/users.js.html | 2 +- .../test/controllers/document.spec.js.html | 2 +- .../server/test/controllers/index.html | 48 +- .../server/test/controllers/mockData.js.html | 2 +- .../server/test/controllers/role.spec.js.html | 224 ++- .../test/controllers/search.spec.js.html | 20 +- .../server/test/controllers/user.spec.js.html | 16 +- .../server/test/document.spec.js.html | 1139 --------------- .../document-manager/server/test/index.html | 145 -- .../server/test/index.spec.js.html | 89 -- .../server/test/middlewares/auth.spec.js.html | 383 ----- .../server/test/middlewares/index.html | 93 -- .../server/test/mockData.js.html | 197 --- .../document-manager/server/test/role.js.html | 950 ------------- .../server/test/role.spec.js.html | 980 ------------- .../server/test/search.spec.js.html | 371 ----- .../server/test/user.spec.js.html | 1235 ----------------- coverage/gulpfile.babel.js.html | 182 --- coverage/index.html | 50 +- coverage/mockData.js.html | 197 --- coverage/user.spec.js.html | 179 --- dist/gulpfile.babel.js | 33 +- dist/server/controllers/roles.js | 24 +- dist/server/controllers/users.js | 6 +- dist/server/test/controllers/document.spec.js | 34 +- dist/server/test/controllers/role.spec.js | 103 +- dist/server/test/controllers/search.spec.js | 2 - dist/server/test/controllers/user.spec.js | 2 +- gulpfile.babel.js | 43 +- package.json | 9 +- server/controllers/roles.js | 18 +- server/controllers/users.js | 4 +- server/test/controllers/role.spec.js | 124 +- server/test/controllers/search.spec.js | 2 - server/test/controllers/user.spec.js | 2 +- 62 files changed, 481 insertions(+), 7572 deletions(-) delete mode 100644 coverage/auth.spec.js.html delete mode 100644 coverage/document-manager/server/controllers/searches.js.html delete mode 100644 coverage/document-manager/server/routes/searches.js.html delete mode 100644 coverage/document-manager/server/test/document.spec.js.html delete mode 100644 coverage/document-manager/server/test/index.html delete mode 100644 coverage/document-manager/server/test/index.spec.js.html delete mode 100644 coverage/document-manager/server/test/middlewares/auth.spec.js.html delete mode 100644 coverage/document-manager/server/test/middlewares/index.html delete mode 100644 coverage/document-manager/server/test/mockData.js.html delete mode 100644 coverage/document-manager/server/test/role.js.html delete mode 100644 coverage/document-manager/server/test/role.spec.js.html delete mode 100644 coverage/document-manager/server/test/search.spec.js.html delete mode 100644 coverage/document-manager/server/test/user.spec.js.html delete mode 100644 coverage/gulpfile.babel.js.html delete mode 100644 coverage/mockData.js.html delete mode 100644 coverage/user.spec.js.html diff --git a/coverage/auth.spec.js.html b/coverage/auth.spec.js.html deleted file mode 100644 index 0bf1156..0000000 --- a/coverage/auth.spec.js.html +++ /dev/null @@ -1,383 +0,0 @@ - - - - Code coverage report for auth.spec.js - - - - - - - -
-
-

- All files auth.spec.js -

-
-
- 12.5% - Statements - 8/64 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/20 -
-
- 12.7% - Lines - 8/63 -
-
-
-
-

1 2 @@ -169,7 +169,10 @@

124 125 126 -127

1x +127 +128 +129 +1301x 1x   1x @@ -203,7 +206,6 @@

  2x 1x -1x     1x @@ -221,16 +223,16 @@

      -  -  -  -  -  +3x +3x +3x +3x +1x       -  -  +2x +1x       @@ -248,18 +250,20 @@

      -  -  +2x +1x     -  +  +  +1x           -  -  +1x +1x       @@ -281,9 +285,11 @@

      -  -  -  +2x +1x +1x +  +        @@ -328,7 +334,6 @@

} } }).then(({ rows: user, count }) => { - console.log(count, 'User Count'); Iif (count === 0) { return res.status(404).json({ message: 'User not found' }); } @@ -346,17 +351,17 @@

* @param {array} res - an array containing searched document * @returns {array} - searched document */ -function searchDocuments(req, res) { - const limit = req.query.limit, - offset = req.query.offset, - queryString = req.query.q; - if (!queryString) { - return res.status(400).json({ +function searchDocuments(req, res) { + const limit = req.query.limit, + offset = req.query.offset, + queryString = req.query.q; + if (!queryString) { + return res.status(400).json({ message: 'Invalid search input' }); } - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ + if (req.decoded.roleId === 1) { + return Document.findAndCountAll({ limit, offset, where: { @@ -374,18 +379,20 @@

} ] }) - .then(({ rows: document, count }) => { - if (count === 0) { - res.status(404).json({ message: 'Document not found' }); + .then(({ rows: document, count }) => { + Iif (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); } - res.status(200).send({ + res.status(200).send({ document, pagination: metaData(count, limit, offset), }); }) .catch(error => res.status(400).send(error)); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ + } else Eif (req.decoded.roleId !== 1) { + return Document.findAndCountAll({ limit, offset, include: [ @@ -407,9 +414,11 @@

},   }) - .then(({ rows: document, count }) => { - if (count === 0) { - res.status(404).json({ message: 'Document not found' }); + .then(({ rows: document, count }) => { + Eif (count === 0) { + return res.status(404).json({ + message: 'Document not found' + }); } res.status(200).send({ document, @@ -427,7 +436,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index f470e41..7811f53 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -326,8 +326,7 @@

281 282 283 -284 -285

1x +2841x 1x   1x @@ -574,7 +573,6 @@

      -  2x 2x 2x @@ -852,7 +850,6 @@

}   /** - * * Get documents for specific user * @param {object} req - request object containing limit query and offset * @param {array} res - array of documents for the requested user @@ -901,7 +898,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index 4f21864..f296c46 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -51,7 +51,7 @@

6 7 8 -9

7x +98x       @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index b43b9dd..dd03f54 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index fbd644c..1778255 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -84,14 +84,14 @@

      -66x -66x -62x -62x +65x +65x +61x +61x     -62x -62x +61x +61x       @@ -103,10 +103,10 @@

      -27x -18x +20x +14x   -9x +6x       @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index b624db2..59391d7 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 754bf43..3325d86 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -71,8 +71,7 @@

26 27 28 -29 -30

  +29  1x 1x   @@ -94,7 +93,6 @@

    1x -  1x     @@ -123,7 +121,6 @@

} }); Document.associate = (models) => { - // associations can be defined here Document.belongsTo(models.User, { foreignKey: 'userId' }); @@ -136,7 +133,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index b9798b9..5525493 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index 45b8b31..3ba686b 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 7cb787c..1382e00 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -59,8 +59,7 @@

14 15 16 -17 -18

  +17  1x 1x   @@ -70,7 +69,6 @@

    1x -  1x     @@ -87,7 +85,6 @@

} }); Role.associate = (models) => { - // associations can be defined here Role.hasMany(models.User, { foreignKey: 'roleId' }); @@ -100,7 +97,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index a214418..51f2f7c 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -82,8 +82,7 @@

37 38 39 -40 -41

1x +401x 1x     @@ -110,7 +109,6 @@

    1x -  1x     @@ -150,7 +148,6 @@

} }); User.associate = (models) => { - // associations can be defined here User.hasMany(models.Document, { foreignKey: 'userId', onDelete: 'CASCADE', @@ -169,7 +166,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index b1ac31f..580e6a7 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -108,10 +108,10 @@

/** PUT /api/v1/documents/id - Create document */ .put(auth.verifyToken, documentController.updateDocument)   - /** GET /api/v1/documents/id - find document */ + /** GET /api/v1/documents/id - get document */ .get(auth.verifyToken, documentController.findDocument)   - /** GET /api/v1/documents/id - find document */ + /** DELETE /api/v1/documents/id - delete document */ .delete(auth.verifyToken, documentController.deleteDocument);   export default router; @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index cc2a9da..cbc962d 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index e23e1db..cc22d45 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index d91af56..f77e87c 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index d2a41ad..1e66300 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -80,12 +80,12 @@

const router = express.Router();   router.route('/users') - /** GET /api/users - Get list of users */ + /** GET /api/v1/users - search list of users */ .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);   router.route('/documents') - /** GET /api/documents - Get list of users */ - .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments); + /** GET /api/v1/search - search list of documents */ + .get(auth.verifyToken, searchController.searchDocuments);   export default router;  

1x +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +4151x 1x 1x 1x @@ -495,6 +552,63 @@

1x     +1x +  +1x +  +  +  +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +  +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +  +1x +  +1x +  +  +  +  +  +1x +  +  +  +  +1x +1x +1x +1x +  +      1x @@ -800,8 +914,8 @@

describe('/POST Document', () => { it('should add a new document if the user is authenticated', (done) => { const document = { - title: 'boromir-team', - content: 'Andela is really awesome!!!', + title: 'hey yo!', + content: 'Andela is really fun!!', access: 'public', userId: 2, }; @@ -810,11 +924,11 @@

.send(document) .set({ authorization: userToken }) .end((err, res) => { - expect(res.status).to.equal(201); + expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('boromir-team'); - expect(res.body.content).to.eql('Andela is really awesome!!!'); + expect(res.body.title).to.eql('hey yo!'); + expect(res.body.content).to.eql('Andela is really fun!!'); expect(res.body.access).to.equal('public'); done(); }); @@ -852,6 +966,63 @@

done(); }); }); + it('should fail to add a new document if the access field is missing', + (done) => { + const document = { + title: 'boromir-team', + content: 'Andela is really awesome!!!', + access: '', + userId: 1, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('accessType is required'); + done(); + }); + }); + it('should fail to add a new document if the title field is missing', + (done) => { + const document = { + title: '', + content: 'Andela is really awesome!!!', + value: 'public', + userId: 2, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Title is required'); + done(); + }); + }); + it('should fail to add a new document if the content field is missing', + (done) => { + const document = { + title: 'boromir-team', + content: '', + value: 'public', + userId: 2, + }; + chai.request(server) + .post('/api/v1/documents') + .send(document) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Content is required'); + done(); + }); + }); });   describe('/GET Documents', () => { @@ -925,7 +1096,7 @@

expect(res.status).to.equal(200); expect(res.body).to.be.a('object'); expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('boromir-team'); + expect(res.body.title).to.equal('hey yo!'); expect(res.body.access).to.equal('public'); done(); }); @@ -1108,7 +1279,7 @@

.end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); + expect(res.body.message).to.eql('Document Not Found'); done(); }); }); @@ -1120,7 +1291,7 @@

diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html index 570df90..499c8bf 100644 --- a/coverage/document-manager/server/test/controllers/index.html +++ b/coverage/document-manager/server/test/controllers/index.html @@ -20,9 +20,9 @@

- 95.31% + 97.21% Statements - 589/618 + 593/610
100% @@ -32,12 +32,12 @@

99.47% Functions - 188/189 + 186/187
- 95.25% + 97.18% Lines - 581/610 + 585/602

@@ -60,15 +60,15 @@

document.spec.js
96.74%178/184
97.07%199/205 100% 0/098.21%55/5696.7%176/18298.39%61/6297.04%197/203
role.spec.js
93.71%149/159
94.7%125/132 100% 0/0 100%50/5093.63%147/15742/4294.62%123/130
search.spec.js
83.87%52/62
98.33%59/60 100% 0/0 100% 19/1983.33%50/6098.28%57/58
1x +1091x 1x 1x 1x @@ -209,7 +208,6 @@

  1x 1x -1x       @@ -217,7 +215,6 @@

1x 1x 1x -1x       @@ -229,8 +226,8 @@

    1x -  -  +1x +1x     1x @@ -240,23 +237,24 @@

    1x -  -  -  -  -  +1x +1x +1x +1x +1x       1x +  1x 1x       1x -  -  +1x +1x       @@ -317,12 +315,10 @@

it('Should return a search list response of the required search input', (done) => { const query = Baas.userName; - console.log(adminToken); request(server) .get(`/api/v1/search/users/?q=${query}`) .set({ authorization: adminToken }) .end((err, res) => { - console.log(res.body, 'Baas Bank Details *************'); expect(res.status).to.equal(200); expect(res.body.user[0].fullName).to.eql(Baas.fullName); expect(res.body.user[0].userName).to.equal(Baas.userName); @@ -338,36 +334,37 @@

.set({ authorization: userToken }) .end((err, res) => { expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - done(); + expect(res.body.message).to.eql('Invalid search input'); + done(); }); }); it('Should return a search list of the required search input', (done) => { const query = 'John'; request(server) .get(`/api/v1/search/documents/?q=${query}`) - .set({ authorization: userToken }) + .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); - expect(res.body.document[0].title).to.equal('John Doe'); - expect(res.body.document[0].content).to.equal('eze goes to school'); - expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - done(); - }); - }); - it('Should throw an error if the searched document is not found', (done) => { - const query = 'jk'; - request(server) - .get(`/api/v1/search/documents/?q=${query}`) - .set({ authorization: userToken }) - .end((err, res) => { - expect(res.status).to.equal(404); - expect(res.body.message).to.equal('Document not found'); + expect(res.body).to.have.property('document'); + expect(res.body.document[0].title).to.equal('John Doe'); + expect(res.body.document[0].content).to.equal('eze goes to school'); + expect(res.body).to.have.property('pagination'); + expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); done(); }); }); + it('Should throw an error if the searched document is not found', + (done) => { + const query = 'jk'; + request(server) + .get(`/api/v1/search/documents/?q=${query}`) + .set({ authorization: userToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body.message).to.equal('Document not found'); + done(); + }); + }); }); });  

document-manager/server/controllers
76.72%178/23275%87/11666.67%56/8476.72%178/232document-manager/server/controllers
80.95%187/23180.17%93/11665.48%55/8480.95%187/231
document-manager/server/test/controllers
95.31%589/618
97.21%593/610 100% 0/0 99.47%188/18995.25%581/610186/18797.18%585/602
- -
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -1071x -1x -1x -1x -1x -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
process.NODE_ENV = 'test';
-const chai = require('chai');
-require('dotenv').config();
-const chaiHttp = require('chai-http');
-const expect = chai.expect;
-const EventEmitter = require('events').EventEmitter;
-const httpMocks = require('node-mocks-http');
-const samples = require('../apiEndpoints/mockdata');
-const server = require('../../../index');
-const auth = require('../../middlewares/auth');
- 
-chai.use(chaiHttp);
-let adminToken, userToken;
-describe('Authentication', () => {
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'johnbosco.ohia@andela.com', password: process.env.PASSWORD })
-      .end((err, res) => {
-        adminToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'testdoe@andela.com', password: 'jamestest' })
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('VerifyToken', () => {
-    it('Should check if the token is provided with request', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents',
-      });
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.verifyToken(request, response, nextCallBack);
-      expect(response._getData().message).to.equal('No token provided.');
-      done();
-    });
-  it('Should provide access if the token is provided and valid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents',
-      headers: { 'x-access-token': adminToken }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
-    expect(response._getData().message).to.equal(undefined);
-    done();
-  });
-  it('Should deny access if the token is invalid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents/',
-      headers: { 'x-access-token': 'themaniscoming' }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
- 
-    response.on('end', () => {
-      expect(response._getData().success).to.equal(false);
-    });
-    done();
-  });
-  });
-  describe('AdminAcess', () => {
-    it('Should deny access if the user is not admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': userToken }
-      });
-      request.decoded = { roleId: 2 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal('You are not authorized');
-      });
-      done();
-    });
-    it('Should grant access if the user is an admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': adminToken }
-      });
-      request.decoded = { roleId: 1 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal(undefined);
-      });
-      done();
-    });
-  });
-});
- 
-
- - - - - - - - diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index 7ae7336..6f90394 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index 73226f2..206ad14 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index b11456a..e8cf1d8 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index cd76966..e0ca8c5 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -88,14 +88,14 @@

1x   1x -81x -81x -81x +83x +83x +83x +115x +112x 112x -110x -110x   -81x +83x       @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index 56b2834..89116f6 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index 16fc973..62166ff 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -727,7 +727,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 869ce22..2f73bc1 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,24 +20,24 @@

- 80.95% + 82.25% Statements - 187/231 + 190/231
- 80.17% + 81.03% Branches - 93/116 + 94/116
- 65.48% + 67.86% Functions - 55/84 + 57/84
- 80.95% + 82.25% Lines - 187/231 + 190/231
@@ -72,16 +72,16 @@

roles.js
72.5%29/4066.67%12/1866.67%14/2172.5%29/40roles.js
80%32/4072.22%13/1876.19%16/2180%32/40
- - - + + + - - - - + + + + - - - + + + - - + + - - - + + + - - + + @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html index 92d7937..8605e19 100644 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -208,7 +208,7 @@

diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html index d98b530..2d2b09c 100644 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -20,9 +20,9 @@

- 94.7% + 92.86% Statements - 125/132 + 143/154
100% @@ -30,14 +30,14 @@

0/0

- 100% + 95.83% Functions - 42/42 + 46/48
- 94.62% + 92.76% Lines - 123/130 + 141/152
@@ -333,21 +333,7 @@

288 289 290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305

@@ -961,7 +919,7 @@

diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html index 8876054..a5d34e9 100644 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -20,9 +20,9 @@

- 98.33% + 100% Statements - 59/60 + 58/58
100% @@ -35,9 +35,9 @@

19/19

- 98.28% + 100% Lines - 57/58 + 56/56
@@ -149,9 +149,7 @@

104 105 106 -107 -108 -109

- - - - - - - - - + + + + + + + + + @@ -151,15 +151,15 @@

- - - + + + - - - - + + + + @@ -168,7 +168,7 @@

diff --git a/coverage/mockData.js.html b/coverage/mockData.js.html deleted file mode 100644 index f3adac1..0000000 --- a/coverage/mockData.js.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - Code coverage report for mockData.js - - - - - - - -
-
-

- All files mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

1 2 @@ -176,7 +176,13 @@

131 132 133 -134

1x +134 +135 +136 +137 +138 +139 +1401x   1x   @@ -187,13 +193,13 @@

      -3x +2x   -3x -3x +2x +2x     -3x +2x     2x @@ -208,7 +214,7 @@

      -1x +        @@ -232,12 +238,12 @@

      -3x +4x 1x       -2x +3x     2x @@ -246,7 +252,7 @@

    1x -  +1x       @@ -257,11 +263,13 @@

      -2x +  +  +3x       -2x +3x     2x @@ -278,7 +286,7 @@

      -  +1x       @@ -288,24 +296,28 @@

      -1x +  +  +2x       -1x +2x   +2x 1x -        -1x +2x         1x -  +1x +  +        @@ -341,7 +353,7 @@

res.json(error.errors); }); } - }).catch(error => res.json(error)); + }).catch(error => res.json(error)); } }   @@ -366,7 +378,7 @@

*/ function findRole(req, res) { if (isNaN(req.params.id)) { - return res.status(401).json({ + res.status(401).json({ message: `invalid input syntax for integer: "${req.params.id}"` }); } else { @@ -379,7 +391,9 @@

}); } res.status(200).json(role); - }).catch(error => res.status(400).json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); } }   @@ -392,7 +406,7 @@

function updateRole(req, res) { Iif (req.decoded.roleId !== 1) { return res.status(401) - .json({ message: 'You are not authorized to access the role' }); + .json({ message: 'You are not authorized' }); } return Role .findById(req.params.id) @@ -411,7 +425,9 @@

role })) .catch(error => res.status(400).json(error)); - }).catch(error => res.status(400).json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); }   /** @@ -423,12 +439,12 @@

function deleteRole(req, res) { Iif (req.decoded.roleId !== 1) { return res.status(401) - .json({ message: 'You are not authorized to access the role' }); + .json({ message: 'You are not authorized' }); } return Role.findById(req.params.id) .then((role) => { - Iif (!role) { - res.status(404).json({ + if (!role) { + res.status(404).json({ message: 'Role not found' }); } @@ -438,7 +454,9 @@

message: 'Role deleted successfully' })) .catch(error => res.status(400).send(error)); - }).catch(error => res.json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); }   export default { createRole, getRoles, findRole, updateRole, deleteRole }; @@ -448,7 +466,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index f645d1b..af6d002 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -436,7 +436,7 @@

diff --git a/coverage/document-manager/server/controllers/searches.js.html b/coverage/document-manager/server/controllers/searches.js.html deleted file mode 100644 index 029411e..0000000 --- a/coverage/document-manager/server/controllers/searches.js.html +++ /dev/null @@ -1,440 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/searches.js - - - - - - - -
-
-

- All files / document-manager/server/controllers searches.js -

-
-
- 14.29% - Statements - 5/35 -
-
- 0% - Branches - 0/14 -
-
- 0% - Functions - 0/8 -
-
- 14.29% - Lines - 5/35 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -1261x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Search for user using a query string
- * @param {string} req - search query of string
- * @param {array} res - array of users
- * @returns {array} - array users searched
- */
-function searchUser(req, res) {
-  const searchQuery = req.query.q,
-    limit = req.query.limit,
-    offset = req.query.offset;
-  if (!searchQuery) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  return User
-  .findAndCountAll({
-    limit,
-    offset,
-    attributes: { exclude: ['password'] },
-    where: {
-      userName: {
-        $like: `%${searchQuery}%`,
-      }
-    }
-  }).then(({ rows: user, count }) => {
-    if (count === 0) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  }).catch(error => res.status(400).send(error));
-}
- 
-/**
-   *
-   * Search for documents by title
-   * @param {string} req - an object containing the query, offset and limit
-   * @param {array} res - an array containing searched document
-   * @returns {array} - searched document
-   */
-function searchDocuments(req, res) {
-  const limit = req.query.limit,
-    offset = req.query.offset,
-    queryString = req.query.q;
-  if (!queryString) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  if (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      if (count === 0) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else if (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      if (count === 0) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-export default { searchUser, searchDocuments };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index 7811f53..fdf2c72 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -326,7 +326,9 @@

281 282 283 -284

1x +284 +285 +2861x 1x   1x @@ -500,6 +502,8 @@

      +  +  5x 2x   @@ -773,7 +777,9 @@

} res.status(200).send(user); }) - .catch(error => res.status(400).send(error)); + .catch(() => res.status(400).send({ + message: 'out of range' + })); }   /** @@ -898,7 +904,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index f296c46..8850d18 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index dd03f54..91ef423 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index 1778255..90c32a2 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -84,14 +84,14 @@

      -65x -65x -61x -61x +67x +67x +63x +63x     -61x -61x +63x +63x       @@ -103,8 +103,8 @@

      -20x -14x +22x +16x   6x   @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index 59391d7..00c29e1 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 3325d86..5247eb1 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -133,7 +133,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 5525493..763d5a3 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index 3ba686b..d5dd340 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 1382e00..5c0a78c 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 51f2f7c..761a76e 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -166,7 +166,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index 580e6a7..ce87407 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index cbc962d..43260a1 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index cc22d45..7f5f6a9 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index f77e87c..74c82f6 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index 1e66300..154e391 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/searches.js.html b/coverage/document-manager/server/routes/searches.js.html deleted file mode 100644 index 1787a66..0000000 --- a/coverage/document-manager/server/routes/searches.js.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/searches.js - - - - - - - -
-
-

- All files / document-manager/server/routes searches.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -161x -1x -1x -  -1x -  -1x -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import searchController from '../controllers/searches';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/users')
-  /** GET /api/users - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
- 
-router.route('/documents')
-  /** GET /api/documents - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index 774a0df..8dacf45 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html index f2c5cb0..34d1a28 100644 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -1291,7 +1291,7 @@

diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html index 499c8bf..f84569d 100644 --- a/coverage/document-manager/server/test/controllers/index.html +++ b/coverage/document-manager/server/test/controllers/index.html @@ -20,9 +20,9 @@

- 97.21% + 96.98% Statements - 593/610 + 611/630
100% @@ -30,14 +30,14 @@

0/0

- 99.47% + 98.45% Functions - 186/187 + 190/193
- 97.18% + 96.95% Lines - 585/602 + 603/622
@@ -86,41 +86,41 @@

role.spec.js
94.7%125/132
92.86%143/154 100% 0/0100%42/4294.62%123/13095.83%46/4892.76%141/152
search.spec.js
98.33%59/60
100%58/58 100% 0/0 100% 19/1998.28%57/58100%56/56
user.spec.js
98.58%208/211
99.05%209/211 100% 0/0 100% 64/6498.56%206/20999.04%207/209
1x +2911x 1x 1x 1x @@ -430,18 +416,6 @@

1x     -1x -1x -  -  -  -  -1x -  -  -  -  -      1x @@ -523,16 +497,15 @@

1x     +1x +1x +1x       -  -  -  -  -  -  -  +1x +1x +1x       @@ -580,20 +553,18 @@

1x     +1x   +1x +1x         -  -  -  -  -  -  -  -  -  +1x +1x +1x +1x       @@ -606,6 +577,7 @@

  1x   +    1x   @@ -622,31 +594,31 @@

1x     +1x     +1x +1x       +1x +1x +1x +1x     +1x   +  +        -  -  -  -  -  -  -  -  -  -  -  -  -  -  +  +  +  +        @@ -734,18 +706,6 @@

done(); }); }); - it('Should return an error if the title is not a string', (done) => { - chai.request(server) - .post('/api/v1/roles') - .set({ authorization: adminToken }) - .send({ title: 358583 }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); });   describe('/GET Role', () => { @@ -827,18 +787,17 @@

done(); }); }); - // it('Should fail to get a role by id if the id is out of range', (done) => { - // const id = 500000000000000000000; - // chai.request(server) - // .get(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to get a role by id if the id is out of range', (done) => { + const id = 500000000000000000000; + request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/PUT/:id Role', () => { it('Should update a role by id if the user has admin access', (done) => { @@ -884,39 +843,38 @@

done(); }); }); - // it(`Should fail to update a role by - // id if the admin enters an id that is out range`, - // (done) => { - // const id = 2000000000000000; - // chai.request(server) - // .put(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .send({ title: 'regular' }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it(`Should fail to update a role by id if the + admin enters an id that is out range`, (done) => { + const id = 2000000000000000; + request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'regular' }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/DELETE/:id Role', () => { it('Should delete a role given the user has admin access', (done) => { const id = 3; - chai.request(server) + request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(204); expect(res.body).to.be.a('object'); + expect(res.body.message).to.be.eql('Role deleted successfully'); }); done(); }); it('Should fail to delete a role given the user has no admin access', (done) => { const id = 3; - chai.request(server) + request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -926,33 +884,33 @@

done(); }); }); - // it('Should fail to delete a role given the admin enters an invalid input', - // (done) => { - // const id = 300; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.equal('Role not found'); - // done(); - // }); - // }); - // it(`Should fail to delete a role given - // the admin enters an input that is out of range`, (done) => { - // const id = 3000000000000000; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it(`Should fail to delete a role + given the admin enters an id that is not found`, + (done) => { + const id = 300; + request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it(`Should fail to delete a role given the admin + enters an input that is out of range`, (done) => { + const id = 3000000000000000; + request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('out of range for type integer'); + done(); + }); + }); }); });  

1x +1071x 1x 1x 1x @@ -241,8 +239,6 @@

1x 1x 1x -1x -      1x @@ -345,12 +341,10 @@

.set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); expect(res.body.document[0].title).to.equal('John Doe'); expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - done(); + done(); }); }); it('Should throw an error if the searched document is not found', @@ -373,7 +367,7 @@

diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html index e583780..19ee730 100644 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -20,9 +20,9 @@

- 98.58% + 99.05% Statements - 208/211 + 209/211
100% @@ -35,9 +35,9 @@

64/64

- 98.56% + 99.04% Lines - 206/209 + 207/209
@@ -658,7 +658,7 @@

1x 1x   -  +1x       @@ -1046,8 +1046,8 @@

.end((err, res) => { expect(res.status).to.equal(400); expect(res.body).to.have.property('message') - .to.equal(`value "${id}" is out of range for type integer`); - done(); + .to.equal('out of range'); + done(); }); }); }); @@ -1216,7 +1216,7 @@

diff --git a/coverage/document-manager/server/test/document.spec.js.html b/coverage/document-manager/server/test/document.spec.js.html deleted file mode 100644 index 73007d7..0000000 --- a/coverage/document-manager/server/test/document.spec.js.html +++ /dev/null @@ -1,1139 +0,0 @@ - - - - Code coverage report for document-manager/server/test/document.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test document.spec.js -

-
-
- 96.76% - Statements - 179/185 -
-
- 100% - Branches - 0/0 -
-
- 98.21% - Functions - 55/56 -
-
- 96.72% - Lines - 177/183 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -3591x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -1x -  -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Documents', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Document', () => {
-    it('should add a new document if the user is authenticated', (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome!!!',
-        access: 'public',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('id');
-        expect(res.body.title).to.eql('boromir-team');
-        expect(res.body.content).to.eql('Andela is really awesome!!!');
-        expect(res.body.access).to.equal('public');
-        done();
-      });
-    });
- 
-    it('Should fail if document already exist', () => {
-      const document = {
-        title: 'John team',
-        content: 'eze goes to school',
-        access: 'public',
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body.message).to.eql('Document already exists');
-      });
-    });
-    it('should fail to add a new document if the user is not authenticated',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome !!!',
-        value: 'private',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('No token provided.');
-        done();
-      });
-    });
-  });
- 
-  describe('/GET Documents', () => {
-    it('Should get all documents for the user that is authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.keys(['document', 'pagination']);
-        done();
-      });
-    });
-    it('should fail to get all documents if the user is not authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents/')
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).be.eql('No token provided.');
-        expect(res.body.success).to.eql(false);
-        done();
-      });
-    });
-    it('Should get all documents with correct limit as a query', (done) => {
-      const limit = 1;
-      request(server)
-        .get(`/api/v1/documents?limit=${limit}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-    it('Should get all documents with correct offset as a query', (done) => {
-      const offset = 0;
-      request(server)
-        .get(`/api/v1/documents?limit=${offset}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Document', () => {
-    it('Should fail to get document if it doesn`t exist', (done) => {
-      const documentId = 8;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-    it('Should get all public regardless of id', (done) => {
-      const documentId = 4;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(4);
-          expect(res.body.title).to.equal('boromir-team');
-          expect(res.body.access).to.equal('public');
-          done();
-        });
-    });
-    it('Should fail to get a private document if the requester does not own it',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a private document the where the requester is the owner',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.access).to.eql('private');
-          expect(res.body.title).to.eql('John naddddd');
-          expect(res.body.id).to.eql(2);
-          expect(res.body.userId).to.eql(2);
-          done();
-        });
-    });
-    it('Should fail get a role document if the users are not on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a role document if the users are on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-          done();
-        });
-    });
-    it('Should get a role document if the user is an admin', (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-        });
-      done();
-    });
-  });
- 
-  describe('/PUT/:id, Document', () => {
-    it('Should update a document by id if the user has the same id',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: userToken })
-          .send({ title: 'wreck it ralph' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.title).to.eql('wreck it ralph');
-            done();
-          });
-      });
-    it(`Should fail to update a document by
-      id if the user does not have the same id`,
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: sampleUserToken })
-          .send({ title: 'spiderman Homecoming' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to edit this document');
-            done();
-          });
-      });
-    it('Should not update a document by id if the user has admin access',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'wreck it' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            done();
-          });
-      });
-    it('Should fail to update a document by id if the document does not exist',
-      (done) => {
-        const id = 10;
-        request(server)
-        .put(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .send({ title: 'Deadpool' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-      });
-  });
- 
-  describe('DELETE/:id Document', () => {
-    it('Should delete a document if the user has admin access', (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should delete a document if the user is the owner', (done) => {
-      const id = 2;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should fail to delete the document given the user is not the owner',
-    (done) => {
-      const id = 1;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to delete this document');
-          done();
-        });
-    });
-    it('Should fail to delete if the document does not exist', (done) => {
-      const id = 234;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/index.html b/coverage/document-manager/server/test/index.html deleted file mode 100644 index 003d5a5..0000000 --- a/coverage/document-manager/server/test/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/test - - - - - - - -
-
-

- All files document-manager/server/test -

-
-
- 95.28% - Statements - 586/615 -
-
- 100% - Branches - 0/0 -
-
- 99.47% - Functions - 188/189 -
-
- 95.22% - Lines - 578/607 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.spec.js
96.76%179/185100%0/098.21%55/5696.72%177/183
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
93.75%150/160100%0/0100%50/5093.67%148/158
search.spec.js
82.14%46/56100%0/0100%19/1981.48%44/54
user.spec.js
98.58%209/212100%0/0100%64/6498.57%207/210
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/index.spec.js.html b/coverage/document-manager/server/test/index.spec.js.html deleted file mode 100644 index ca3eb5d..0000000 --- a/coverage/document-manager/server/test/index.spec.js.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Code coverage report for document-manager/server/test/index.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test index.spec.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -91x -1x -1x -1x -  -1x -  -1x - 
process.env.NODE_ENV = 'test';
-const chai = require('chai');
-const chaiHttp = require('chai-http');
-const server = require('../../index');
- 
-let expect = chai.expect();
- 
-chai.use(chaiHttp);
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/middlewares/auth.spec.js.html b/coverage/document-manager/server/test/middlewares/auth.spec.js.html deleted file mode 100644 index 52005bf..0000000 --- a/coverage/document-manager/server/test/middlewares/auth.spec.js.html +++ /dev/null @@ -1,383 +0,0 @@ - - - - Code coverage report for document-manager/server/test/middlewares/auth.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/middlewares auth.spec.js -

-
-
- 35.48% - Statements - 22/62 -
-
- 100% - Branches - 0/0 -
-
- 20% - Functions - 4/20 -
-
- 34.43% - Lines - 21/61 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -1071x -1x -  -1x -1x -1x -1x -1x -1x -  -1x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
const chai = require('chai');
-const chaiHttp = require('chai-http');
- 
-const expect = chai.expect;
-const EventEmitter = require('events').EventEmitter;
-const httpMocks = require('node-mocks-http');
-const data = require('../controllers/mockdata');
-const server = require('../../../index');
-const auth = require('../../middlewares/auth');
- 
-chai.use(chaiHttp);
-let adminToken, userToken;
-const { admin, fellow } = data;
-describe('Authentication', () => {
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-      .end((err, res) => {
-        adminToken = res.body.token;
-        done();
-      });
-  });
-    before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('VerifyJwtToken', () => {
-    it('Should check if the token is provided with request', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents',
-      });
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.verifyJwtToken(request, response, nextCallBack);
-      expect(response._getData().message).to.equal('No token provided.');
-      done();
-    });
-  it('Should provide access if the token is provided and valid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents',
-      headers: { 'x-access-token': adminToken }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
-    expect(response._getData().message).to.equal(undefined);
-    done();
-  });
-  it('Should deny access if the token is invalid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents/',
-      headers: { 'x-access-token': 'themaniscoming' }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
- 
-    response.on('end', () => {
-      expect(response._getData().success).to.equal(false);
-    });
-    done();
-  });
-  });
-  describe('AdminAcess', () => {
-    it('Should deny access if the user is not admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': userToken }
-      });
-      request.decoded = { roleId: 2 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal('You are not authorized');
-      });
-      done();
-    });
-    it('Should grant access if the user is an admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': adminToken }
-      });
-      request.decoded = { roleId: 1 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal(undefined);
-      });
-      done();
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/middlewares/index.html b/coverage/document-manager/server/test/middlewares/index.html deleted file mode 100644 index d19829c..0000000 --- a/coverage/document-manager/server/test/middlewares/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/test/middlewares - - - - - - - -
-
-

- All files document-manager/server/test/middlewares -

-
-
- 35.48% - Statements - 22/62 -
-
- 100% - Branches - 0/0 -
-
- 20% - Functions - 4/20 -
-
- 34.43% - Lines - 21/61 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
auth.spec.js
35.48%22/62100%0/020%4/2034.43%21/61
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/mockData.js.html b/coverage/document-manager/server/test/mockData.js.html deleted file mode 100644 index 2135885..0000000 --- a/coverage/document-manager/server/test/mockData.js.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - Code coverage report for document-manager/server/test/mockData.js - - - - - - - -
-
-

- All files / document-manager/server/test mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -451x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/role.js.html b/coverage/document-manager/server/test/role.js.html deleted file mode 100644 index a81a819..0000000 --- a/coverage/document-manager/server/test/role.js.html +++ /dev/null @@ -1,950 +0,0 @@ - - - - Code coverage report for document-manager/server/test/role.js - - - - - - - -
-
-

- All files / document-manager/server/test role.js -

-
-
- 92.02% - Statements - 150/163 -
-
- 100% - Branches - 0/0 -
-
- 96.08% - Functions - 49/51 -
-
- 91.93% - Lines - 148/161 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -2961x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -1x -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
-  after((done) => {
-    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
-    done();
-  });
- 
-  describe('/POST Role', () => {
-  it('should add a new role if the user is an admin', (done) => {
-    request(server)
-    .post('/api/v1/roles')
-    .send({ title: 'boromir' })
-    .set({ authorization: adminToken })
-    .end((err, res) => {
-      expect(res.status).to.equal(201);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('Role successfully created');
-      expect(res.body).to.have.property('role');
-      expect(res.body.role).to.have.property('title').to.equal('kiba');
-    });
-    done();
-  });
-  it('should add a new role if the user is an admin', (done) => {
-    request(server)
-    .post('/api/v1/roles')
-    .send({ title: 'king' })
-    .set({ authorization: adminToken })
-    .end((err, res) => {
-      expect(res.status).to.equal(204);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('Role successfully created');
-      expect(res.body).to.have.property('role');
-    });
-    done();
-  });
-  it('Should fail if a non-admin wants to add a new role', (done) => {
-    const role = {
-      title: 'boromir-team'
-    };
-    request(server)
-      .post('/api/v1/roles/')
-      .set({ authorization: userToken })
-    .send(role)
-    .end((err, res) => {
-      expect(res.status).to.equal(401);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('You are not authorized');
-      done();
-    });
-  });
-  it('Should return an error if the title is not a string', (done) => {
-    chai.request(server)
-      .post('/api/v1/roles')
-      .set({ authorization: adminToken })
-      .send({ title: 358583 })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('message').to.equal('Invalid input credentials');
-        done();
-      });
-  });
-});
- 
-describe('/GET Role', () => {
-  it('Should get all the roles if the user is an admin', (done) => {
-    chai.request(server)
-      .get('/api/v1/roles')
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.have.length(5);
-        expect(res.body).to.be.a('array');
-        expect(res.body[0]).to.have.property('id').to.equal(1);
-        expect(res.body[0]).to.have.property('title').to.equal('admin')
-        expect(res.body[1]).to.have.property('id').to.equal(2);
-        expect(res.body[1]).to.have.property('title').to.equal('facilitator');
-        done();
-      });
-  });
-  it('Should fail to get the roles if the user is not admin', (done) => {
-    chai.request(server)
-      .get('/api/v1/roles')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.have.property('message').to.equal('You are not authorized');
-        done();
-      });
-  });
-});
- 
-describe('/GET/:id Role', () => {
-  it('Should get a role by id if the user is an admin', (done) => {
-    const id = 2;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).be.a('object');
-        expect(res.body).to.have.property('title').to.equal('facilitator');
-        expect(res.body).to.have.property('id').to.equal(2);
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the user is not an admin', (done) => {
-    const id = 2;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.have.property('message').to.equal('You are not authorized');
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the user enters an invalid input', (done) => {
-    const id = 'fddjsdcdjn';
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.have.property('message').to.equal(`invalid input syntax for integer: "${id}"`);
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the role does not exist', (done) => {
-    const id = 250;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(404);
-        expect(res.body).to.have.property('message').to.equal('Role not found');
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the id is out of range', (done) => {
-    const id = 500000000000000000000;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-        done();
-      });
-  });
-});
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the admin enters an invalid input'
-      , (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role not found');
-          done();
-        });
-      });
-    it('Should fail to update a role by id if the admin enters an id that is out range', (done) => {
-      const id = 2000000000000000;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'regular' })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-        });
-       done();
-    });
-    it('Should fail to delete a role given the user has no admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an invalid input', (done) => {
-      const id = 300;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role not found');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an input that is out of range', (done) => {
-      const id = 3000000000000000;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/role.spec.js.html b/coverage/document-manager/server/test/role.spec.js.html deleted file mode 100644 index eec4810..0000000 --- a/coverage/document-manager/server/test/role.spec.js.html +++ /dev/null @@ -1,980 +0,0 @@ - - - - Code coverage report for document-manager/server/test/role.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test role.spec.js -

-
-
- 93.75% - Statements - 150/160 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 50/50 -
-
- 93.67% - Lines - 148/158 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -3061x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -  -  -1x -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Role', () => {
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'boromir' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-        expect(res.body.role).to.have.property('title').to.equal('boromir');
-      });
-      done();
-    });
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'king' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(204);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-      });
-      done();
-    });
-    it('Should fail if a non-admin wants to add a new role', (done) => {
-      const role = {
-        title: 'boromir-team'
-      };
-      request(server)
-        .post('/api/v1/roles/')
-        .set({ authorization: userToken })
-      .send(role)
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('You are not authorized');
-        done();
-      });
-    });
-    it('Should return an error if the title is not a string', (done) => {
-      chai.request(server)
-        .post('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .send({ title: 358583 })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Invalid input credentials');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET Role', () => {
-    it('Should get all the roles if the user is an admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.length(5);
-          expect(res.body).to.be.a('array');
-          expect(res.body[0].id).to.eql(1);
-          expect(res.body[0].title).to.eql('admin');
-          expect(res.body[1].id).to.eql(2);
-          expect(res.body[1].title).to.eql('facilitator');
-          done();
-        });
-    });
-    it('Should fail to get the roles if the user is not admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql('You are not authorized');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Role', () => {
-    it('Should get a role by id if the user is an admin', (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).be.a('object');
-          expect(res.body.title).to.eql('facilitator');
-          expect(res.body.id).to.equal(2);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user is not an admin',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user enters an invalid input',
-    (done) => {
-      const id = 'fddjsdcdjn';
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql(`invalid input syntax for integer: "${id}"`);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the role does not exist', (done) => {
-      const id = 250;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body.message).to.eql('Role not found');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the id is out of range', (done) => {
-      const id = 500000000000000000000;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message)
-          .to.eql(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'boromir-team' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it(`Should fail to update a
-       role by id if the admin enters an invalid input`,
-      (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-      });
-    it(`Should fail to update a role by
-      id if the admin enters an id that is out range`,
-      (done) => {
-        const id = 2000000000000000;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'regular' })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql(`value "${id}" is out of range for type integer`);
-            done();
-          });
-      });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-        });
-      done();
-    });
-    it('Should fail to delete a role given the user has no admin access',
-    (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an invalid input',
-    (done) => {
-      const id = 300;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-    });
-    it(`Should fail to delete a role given
-      the admin enters an input that is out of range`, (done) => {
-      const id = 3000000000000000;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/search.spec.js.html b/coverage/document-manager/server/test/search.spec.js.html deleted file mode 100644 index 2374e28..0000000 --- a/coverage/document-manager/server/test/search.spec.js.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - Code coverage report for document-manager/server/test/search.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test search.spec.js -

-
-
- 82.14% - Statements - 46/56 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 19/19 -
-
- 81.48% - Lines - 44/54 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -1031x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -  -1x -1x -1x -  -  -  -1x -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/SEARCH/users/?q={name}', () => {
-    it('Should return an error if no querystring is provided', () => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/users/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Inval search input');
-        });
-    });
-    it('Should return a search list response of the required search input',
-    () => {
-      const query = 'jame';
-      request(server)
-      .get(`/api/v1/search/users/?q=${query}`)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body.fullName).to.eql('jame doe');
-        expect(res.body.userName).to.eql('testdoe');
-      });
-    });
-  });
-  describe('/SEARCH/documents/?q=', () => {
-    it('Should return an error if no querystring is provided', () => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/document/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.property('message').to.equal('Invalid search input')
-        });
-      });
-     it('Should return a search list of the required search input', () => {
-       const query = 'John';
-       request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.property('document');
-          expect(res.body.document[0]).to.have.property('title').to.equal('John Doe');
-          expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school');
-          expect(res.body).to.have.property('pagination');
-          expect(res.body.paginaton).to.have.property('totalCount').to.equal(1);
-        });
-     });
-     it('Should throw an error if the searched document is not found', () => {
-       const query = 'jk';
-       request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.have.property('message').to.equal('Document not found');
-        });
-     });
-   });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/user.spec.js.html b/coverage/document-manager/server/test/user.spec.js.html deleted file mode 100644 index 3d7d402..0000000 --- a/coverage/document-manager/server/test/user.spec.js.html +++ /dev/null @@ -1,1235 +0,0 @@ - - - - Code coverage report for document-manager/server/test/user.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test user.spec.js -

-
-
- 98.58% - Statements - 209/212 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 64/64 -
-
- 98.57% - Lines - 207/210 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -3911x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fakeBass, fellow, user1, user2 } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST User login', () => {
-    it('Should fail if the user enters incorrect crendentials upon login',
-    (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user1)
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. User not found.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('Should fail if the user provide a wrong password', (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user2)
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. Wrong password.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('should log in a user and return a token', (done) => {
-      request(server)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['success', 'token']);
-          expect(res.body.success).to.eql(true);
-          done();
-        });
-    });
- 
-    describe('/POST User Signup', () => {
-      it('should create a new user', (done) => {
-        request(server)
-          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body)
-              .to.have.keys(['message', 'success', 'userDetails']);
-            expect(res.body.success).to.eql(true);
-            expect(res.body.message)
-            .to.eql('You have successfully registered.');
-            done();
-          });
-      });
-    });
- 
-    describe('#GET Users', () => {
-      it('Should get all users if the user is an admin ', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body).to.have.keys(['user', 'pagination']);
-            done();
-          });
-      });
-      it('Should fail to get all users if the user has no admin access ',
-      (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('You are not authorized');
-            done();
-          });
-      });
-      it('Should fail to get all users if no token was provided', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            done();
-          });
-      });
-      it('Should get all users with correct limit as a query', (done) => {
-        const limit = 1;
-        chai.request(server)
-          .get(`/api/v1/users?limit=${limit}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.user[0].fullName).to.equal('Baas Bank');
-            expect(res.body.user[0].userName).to.equal('bank');
-            done();
-          });
-      });
-    });
-    describe('#GET User by Id', () => {
-      it('Should get a user if the user is an admin', (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).to.eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should get the user if the requested user is the current user',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should fail to get a user if an invalid input is entered',
-      (done) => {
-        const id = 'fddjsdcdjn';
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.property('message')
-            .to.eql(`invalid input syntax for integer: "${id}"`);
-            done();
-          });
-      });
-      it('should fail to get the user if the requester is not the owner',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`api/users/${id}`)
-          .set({ authorization: sampleUserToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.keys(['message']);
-            expect(res.body.message).to.eql('Unauthorized access');
-          });
-        done();
-      });
-      it('Should fail to get a user if the user does not exist',
-      (done) => {
-        const id = 250;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.have.property('message');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get a user if the id is out of range',
-      (done) => {
-        const id = 500000000000000000;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.have.property('message')
-            .to.equal(`value "${id}" is out of range for type integer`);
-            done();
-          });
-      });
-    });
-    describe('#PUT Update user by Id', () => {
-      it('Should update a user`s full name if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ fullName: 'jake doe' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.fullName).to.eql('jake doe');
-              done();
-            });
-        });
-      it('Should update a user`s email if the user has the same id', (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.email).to.eql('jakedoe@andela.com');
-            done();
-          });
-      });
-      it('Should update a user`s username if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ userName: 'jakedoe12' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.userName).to.eql('jakedoe12');
-              done();
-            });
-        });
-      it(`Should fail to update a user's
-      details if the user does not have the same user id`,
-      (done) => {
-        const id = 3;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-      it(`Should fail to update a user's
-        details if the user enters an invalid user id`,
-      (done) => {
-        const id = 2302;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-    });
-    describe('#DELETE /:id Users', () => {
-      it('Should delete a user given the user has admin access', (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(204);
-            done();
-          });
-      });
-      it('Should fail to delete a user if the user has no admin access',
-      (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this field');
-            done();
-          });
-      });
-      it('Should give a User not found if user don\'t exist', (done) => {
-        const id = 23;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-    });
-    describe('/GET/users/:id/documents Documents', () => {
-      it('Should fail to get documents if the user does not exist', (done) => {
-        const userId = 9;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get documents if there is no token present',
-      (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            expect(res.body.success).to.eql(false);
-            done();
-          });
-      });
-      it('Should get documents for the user with its unique userId', (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('object');
-            expect(res.body.document[1].userId).to.eql(2);
-            expect(res.body.document[1].title).to.eql('boromir-team');
-            expect(res.body.document[1].content)
-            .to.eql('Andela is really awesome!!!');
-            done();
-          });
-      });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/gulpfile.babel.js.html b/coverage/gulpfile.babel.js.html deleted file mode 100644 index 479875a..0000000 --- a/coverage/gulpfile.babel.js.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Code coverage report for gulpfile.babel.js - - - - - - - -
-
-

- All files gulpfile.babel.js -

-
-
- 78.57% - Statements - 11/14 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/3 -
-
- 91.67% - Lines - 11/12 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -401x -1x -  -1x -1x -  -  -1x -  -1x -  -  -  -  -1x -  -  -  -  -  -1x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -1x -1x - 
import gulp from 'gulp';
-import mocha from 'gulp-mocha';
- 
-import loadPlugins from 'gulp-load-plugins';
-import path from 'path';
- 
-// Load the gulp plugins into the `plugins` variable
-const plugins = loadPlugins();
- 
-const paths = {
-  js: ['./**/*.js', '!dist/**', '!node_modules/**']
-};
- 
-// Compile all Babel Javascript into ES5 and put it into the dist dir
-gulp.task('babel', () =>
-  gulp.src(paths.js, { base: '.' })
-    .pipe(plugins.babel())
-    .pipe(gulp.dest('dist'))
-);
- 
-gulp.task('mochaTest', () => {
-  gulp.src(['server/test/**/*.js'])
-    .pipe(mocha({
-      reporter: 'spec',
-    }));
-});
- 
-// Start server with restart on file change events
-gulp.task('nodemon', ['babel'], () =>
-  plugins.nodemon({
-    script: path.join('dist', 'index.js'),
-    ext: 'js',
-    ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'],
-    tasks: ['babel']
-  })
-);
- 
-gulp.task('test', ['mochaTest']);
-gulp.task('default', ['nodemon']);
- 
-
-
- - - - - - - diff --git a/coverage/index.html b/coverage/index.html index 010797d..c633d74 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,24 +20,24 @@

- 93.42% + 93.66% Statements - 895/958 + 916/978
- 80.29% + 81.02% Branches - 110/137 + 111/137
- 89.55% + 89.76% Functions - 257/287 + 263/293
- 93.35% + 93.6% Lines - 885/948 + 906/968
@@ -86,15 +86,15 @@

document-manager/server/controllers
80.95%187/23180.17%93/11665.48%55/8480.95%187/231
82.25%190/23181.03%94/11667.86%57/8482.25%190/231
document-manager/server/test/controllers
97.21%593/610
96.98%611/630 100% 0/099.47%186/18797.18%585/60298.45%190/19396.95%603/622
- -
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -451x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
- - - - - - - - diff --git a/coverage/user.spec.js.html b/coverage/user.spec.js.html deleted file mode 100644 index c42313f..0000000 --- a/coverage/user.spec.js.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - Code coverage report for user.spec.js - - - - - - - -
-
-

- All files user.spec.js -

-
-
- 6.67% - Statements - 1/15 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/5 -
-
- 6.67% - Lines - 1/15 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -391x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import models from '../../models/';
-import data from '../mockData';
- 
- 
-const expect = chai.expect;
-chai.use(http);
- 
-const { admin, incompleteLoginCredentials, fakeEsther } = data;
-// , superUser, regularUser, fakeEsther, fakeUserDetails
- 
-describe('Users', () => {
-  after((done) => {
-    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
-    done();
-  });
-  describe('user login endpoint', () => {
-    it('should log in a user and return a token', (done) => {
-      chai.request(app)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['message', 'token']);
-          expect(res.body.message).to.eql('login successful');
-          done();
-        });
-    });
-  // describe('user sign up endpoint', () => {
-  //   it('should create a new user', (done) => {
-  //     chai.request(app)
-  //       .post('/api/v1/users/').send(fakeEsther).end((err, res) => {
-  //         console.log("here?", res.status);
-  //         expect(res.status).to.equal(201);
-  //         expect(res.body).to.have.keys(['message', 'user', 'token']);
-  //         expect(res.body.message).to.eql('signup successful');
-  //         done();
-  //       });
-  //   });
-  });
-});
- 
-
-
- - - - - - - diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index a5f150d..f697f6b 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -12,21 +12,17 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path); -var _gulpMocha = require('gulp-mocha'); - -var _gulpMocha2 = _interopRequireDefault(_gulpMocha); - var _gulpExit = require('gulp-exit'); var _gulpExit2 = _interopRequireDefault(_gulpExit); -var _gulpCoveralls = require('gulp-coveralls'); +var _gulpIstanbul = require('gulp-istanbul'); -var _gulpCoveralls2 = _interopRequireDefault(_gulpCoveralls); +var _gulpIstanbul2 = _interopRequireDefault(_gulpIstanbul); -var _gulpCoverage = require('gulp-coverage'); +var _gulpMocha = require('gulp-mocha'); -var _gulpCoverage2 = _interopRequireDefault(_gulpCoverage); +var _gulpMocha2 = _interopRequireDefault(_gulpMocha); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -47,15 +43,22 @@ _gulp2.default.task('babel', function () { return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); }); -_gulp2.default.task('coverage', function () { - _gulp2.default.src('server/test/**/*.js', { read: false }).pipe(_gulpCoverage2.default.instrument({ - pattern: ['server/controllers/**/*.js'], - debugDirectory: 'debug' - })).pipe((0, _gulpMocha2.default)()).pipe(_gulpCoverage2.default.gather()).pipe(_gulpCoverage2.default.format()).pipe(_gulp2.default.dest('reports')); +_gulp2.default.task('pre-test', function () { + return _gulp2.default.src(['server/**/*.js', '!server/test/', '!gulpfile.js']) + // Covering files + .pipe((0, _gulpIstanbul2.default)({ includeUntested: true })).pipe(_gulpIstanbul2.default.hookRequire()); }); -_gulp2.default.task('coveralls', function () { - return _gulp2.default.src('./coverage/lcov').pipe((0, _gulpCoveralls2.default)()); +_gulp2.default.task('test', ['pre-test'], function () { + return _gulp2.default.src(['test/**/*spec.js']).pipe((0, _gulpMocha2.default)({ + reporter: 'mochawesome' + })) + // Creating the reports after tests ran + .pipe(_gulpIstanbul2.default.writeReports({ + dir: './server/unit-test-coverage', + reporters: ['html'], + reportOpts: { dir: './unit-test-coverage' } + })).pipe(_gulpIstanbul2.default.enforceThresholds({ thresholds: { global: 90 } })); }); // Restart server with on every changes made to file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js index a2e80f8..a386967 100644 --- a/dist/server/controllers/roles.js +++ b/dist/server/controllers/roles.js @@ -63,7 +63,7 @@ function getRoles(req, res) { */ function findRole(req, res) { if (isNaN(req.params.id)) { - return res.status(401).json({ + res.status(401).json({ message: 'invalid input syntax for integer: "' + req.params.id + '"' }); } else { @@ -74,8 +74,10 @@ function findRole(req, res) { }); } res.status(200).json(role); - }).catch(function (error) { - return res.status(400).json(error); + }).catch(function () { + return res.status(400).json({ + message: 'out of range for type integer' + }); }); } } @@ -88,7 +90,7 @@ function findRole(req, res) { */ function updateRole(req, res) { if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized to access the role' }); + return res.status(401).json({ message: 'You are not authorized' }); } return Role.findById(req.params.id).then(function (role) { if (!role) { @@ -106,8 +108,10 @@ function updateRole(req, res) { }).catch(function (error) { return res.status(400).json(error); }); - }).catch(function (error) { - return res.status(400).json(error); + }).catch(function () { + return res.status(400).json({ + message: 'out of range for type integer' + }); }); } @@ -119,7 +123,7 @@ function updateRole(req, res) { */ function deleteRole(req, res) { if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized to access the role' }); + return res.status(401).json({ message: 'You are not authorized' }); } return Role.findById(req.params.id).then(function (role) { if (!role) { @@ -134,8 +138,10 @@ function deleteRole(req, res) { }).catch(function (error) { return res.status(400).send(error); }); - }).catch(function (error) { - return res.json(error); + }).catch(function () { + return res.status(400).json({ + message: 'out of range for type integer' + }); }); } diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js index 6496518..c935cf8 100644 --- a/dist/server/controllers/users.js +++ b/dist/server/controllers/users.js @@ -176,8 +176,10 @@ function findUser(req, res) { res.status(404).json({ message: 'User not found' }); } res.status(200).send(user); - }).catch(function (error) { - return res.status(400).send(error); + }).catch(function () { + return res.status(400).send({ + message: 'out of range' + }); }); } diff --git a/dist/server/test/controllers/document.spec.js b/dist/server/test/controllers/document.spec.js index fb9ffdf..4654b83 100644 --- a/dist/server/test/controllers/document.spec.js +++ b/dist/server/test/controllers/document.spec.js @@ -95,9 +95,9 @@ describe('Documents', function () { done(); }); }); - it('should fail to add a new document if the value field is missing', function (done) { + it('should fail to add a new document if the access field is missing', function (done) { var document = { - title: 'kiba-team', + title: 'boromir-team', content: 'Andela is really awesome!!!', access: '', userId: 1 @@ -105,7 +105,35 @@ describe('Documents', function () { _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { expect(res.status).to.equal(400); expect(res.body).to.be.a('object'); - expect(res.body.message).to.be.equal('accessType is required'); + expect(res.body.errors[0].msg).to.be.equal('accessType is required'); + done(); + }); + }); + it('should fail to add a new document if the title field is missing', function (done) { + var document = { + title: '', + content: 'Andela is really awesome!!!', + value: 'public', + userId: 2 + }; + _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Title is required'); + done(); + }); + }); + it('should fail to add a new document if the content field is missing', function (done) { + var document = { + title: 'boromir-team', + content: '', + value: 'public', + userId: 2 + }; + _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.errors[0].msg).to.be.equal('Content is required'); done(); }); }); diff --git a/dist/server/test/controllers/role.spec.js b/dist/server/test/controllers/role.spec.js index 6d28fb3..53a0fd7 100644 --- a/dist/server/test/controllers/role.spec.js +++ b/dist/server/test/controllers/role.spec.js @@ -82,14 +82,6 @@ describe('Roles', function () { done(); }); }); - it('Should return an error if the title is not a string', function (done) { - _chai2.default.request(_index2.default).post('/api/v1/roles').set({ authorization: adminToken }).send({ title: 358583 }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); }); describe('/GET Role', function () { @@ -149,18 +141,14 @@ describe('Roles', function () { done(); }); }); - // it('Should fail to get a role by id if the id is out of range', (done) => { - // const id = 500000000000000000000; - // chai.request(server) - // .get(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to get a role by id if the id is out of range', function (done) { + var id = 500000000000000000000; + (0, _supertest2.default)(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/PUT/:id Role', function () { it('Should update a role by id if the user has admin access', function (done) { @@ -191,67 +179,52 @@ describe('Roles', function () { done(); }); }); - // it(`Should fail to update a role by - // id if the admin enters an id that is out range`, - // (done) => { - // const id = 2000000000000000; - // chai.request(server) - // .put(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .send({ title: 'regular' }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to update a role by id if the\n admin enters an id that is out range', function (done) { + var id = 2000000000000000; + (0, _supertest2.default)(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'regular' }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/DELETE/:id Role', function () { it('Should delete a role given the user has admin access', function (done) { var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { expect(res.status).to.equal(204); expect(res.body).to.be.a('object'); + expect(res.body.message).to.be.eql('Role deleted successfully'); }); done(); }); it('Should fail to delete a role given the user has no admin access', function (done) { var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { + (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); expect(res.body.message).to.eql('You are not authorized'); done(); }); }); - // it('Should fail to delete a role given the admin enters an invalid input', - // (done) => { - // const id = 300; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.equal('Role not found'); - // done(); - // }); - // }); - // it(`Should fail to delete a role given - // the admin enters an input that is out of range`, (done) => { - // const id = 3000000000000000; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to delete a role\n given the admin enters an id that is not found', function (done) { + var id = 300; + (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it('Should fail to delete a role given the admin\n enters an input that is out of range', function (done) { + var id = 3000000000000000; + (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('out of range for type integer'); + done(); + }); + }); }); }); \ No newline at end of file diff --git a/dist/server/test/controllers/search.spec.js b/dist/server/test/controllers/search.spec.js index ebcbf38..23970d1 100644 --- a/dist/server/test/controllers/search.spec.js +++ b/dist/server/test/controllers/search.spec.js @@ -84,11 +84,9 @@ describe('Search', function () { var query = 'John'; (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); expect(res.body.document[0].title).to.equal('John Doe'); expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); done(); }); }); diff --git a/dist/server/test/controllers/user.spec.js b/dist/server/test/controllers/user.spec.js index d747a63..f3eabb8 100644 --- a/dist/server/test/controllers/user.spec.js +++ b/dist/server/test/controllers/user.spec.js @@ -189,7 +189,7 @@ describe('Users', function () { var id = 500000000000000000; (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('value "' + id + '" is out of range for type integer'); + expect(res.body).to.have.property('message').to.equal('out of range'); done(); }); }); diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 10fcfd6..a3fb131 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,22 +1,21 @@ import gulp from 'gulp'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; +import injectModules from 'gulp-inject-modules'; +import coveralls from 'gulp-coveralls'; +import istanbul from 'gulp-istanbul'; import mocha from 'gulp-mocha'; import exit from 'gulp-exit'; -import coveralls from 'gulp-coveralls'; -import cover from 'gulp-coverage'; // Load the gulp plugins into the `plugins` variable const plugins = loadPlugins(); -gulp.task('tests', () => { - gulp.src('./server/tests/*.js') - .pipe(plugins.babel()) - .pipe(mocha()) - .pipe(exit()); +gulp.task('mochaTest', () => { + gulp.src(['dist/server/test/**/*.js']) + .pipe(mocha({ + reporter: 'spec', + })); }); - - // Compile all Babel Javascript into ES5 and place in dist folder const paths = { js: ['./**/*.js', '!dist/**', '!node_modules/**'] @@ -29,16 +28,20 @@ gulp.task('babel', () => .pipe(gulp.dest('dist')) ); -gulp.task('coverage', () => { - gulp.src('server/test/**/*.js', { read: false }) - .pipe(cover.instrument({ - pattern: ['server/controllers/**/*.js'], - debugDirectory: 'debug' - })) - .pipe(mocha()) - .pipe(cover.gather()) - .pipe(cover.format()) - .pipe(gulp.dest('reports')); +gulp.task('coverage', (cb) => { + gulp.src('dist/server/test/controllers/*.js') + .pipe(istanbul()) + .pipe(istanbul.hookRequire()) + .on('finish', () => { + gulp.src('dist/server/test/*.js') + .pipe(plugins.babel()) + .pipe(injectModules()) + .pipe(mocha()) + .pipe(istanbul.writeReports()) + .pipe(istanbul.enforceThresholds({ thresholds: { global: 30 } })) + .on('end', cb) + .pipe(exit()); + }); }); gulp.task('coveralls', () => gulp.src('./coverage/lcov') @@ -55,6 +58,6 @@ gulp.task('nodemon', ['babel'], () => }) ); -gulp.task('test', ['tests']); +gulp.task('test', ['mochaTest']); gulp.task('default', ['nodemon']); gulp.task('production', ['babel']); diff --git a/package.json b/package.json index c874f70..13e44a3 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "scripts": { "start": "gulp production && node ./dist/index.js", "dev": "node node_modules/gulp/bin/gulp", - "test:db:migrate": "NODE_ENV=test sequelize db:migrate:undo:all && NODE_ENV=test sequelize db:migrate", - "test:db:seed": "NODE_ENV=test sequelize db:seed:all", - "start:test:db": "npm run test:db:migrate && npm run test:db:seed", - "server-test": "npm run start:test:db && NODE_ENV=test nyc --reporter=html --reporter=text mocha --compilers js:babel-core/register ./server/test/**/*.js --timeout 90000" + "pretest": "npm run cleardb && NODE_ENV=test sequelize db:migrate && NODE_ENV=test sequelize db:seed:all", + "test": "NODE_ENV=test node node_modules/gulp/bin/gulp test", + "devtest": "NODE_ENV=test gulp test", + "eslint": "eslint index.js", + "cleardb": "NODE_ENV=test sequelize db:migrate:undo:all" }, "repository": { "type": "git", diff --git a/server/controllers/roles.js b/server/controllers/roles.js index 7061789..c8a8158 100644 --- a/server/controllers/roles.js +++ b/server/controllers/roles.js @@ -55,7 +55,7 @@ function getRoles(req, res) { */ function findRole(req, res) { if (isNaN(req.params.id)) { - return res.status(401).json({ + res.status(401).json({ message: `invalid input syntax for integer: "${req.params.id}"` }); } else { @@ -68,7 +68,9 @@ function findRole(req, res) { }); } res.status(200).json(role); - }).catch(error => res.status(400).json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); } } @@ -81,7 +83,7 @@ function findRole(req, res) { function updateRole(req, res) { if (req.decoded.roleId !== 1) { return res.status(401) - .json({ message: 'You are not authorized to access the role' }); + .json({ message: 'You are not authorized' }); } return Role .findById(req.params.id) @@ -100,7 +102,9 @@ function updateRole(req, res) { role })) .catch(error => res.status(400).json(error)); - }).catch(error => res.status(400).json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); } /** @@ -112,7 +116,7 @@ function updateRole(req, res) { function deleteRole(req, res) { if (req.decoded.roleId !== 1) { return res.status(401) - .json({ message: 'You are not authorized to access the role' }); + .json({ message: 'You are not authorized' }); } return Role.findById(req.params.id) .then((role) => { @@ -127,7 +131,9 @@ function deleteRole(req, res) { message: 'Role deleted successfully' })) .catch(error => res.status(400).send(error)); - }).catch(error => res.json(error)); + }).catch(() => res.status(400).json({ + message: 'out of range for type integer' + })); } export default { createRole, getRoles, findRole, updateRole, deleteRole }; diff --git a/server/controllers/users.js b/server/controllers/users.js index ecdfcf2..0047bd7 100644 --- a/server/controllers/users.js +++ b/server/controllers/users.js @@ -162,7 +162,9 @@ function findUser(req, res) { } res.status(200).send(user); }) - .catch(error => res.status(400).send(error)); + .catch(() => res.status(400).send({ + message: 'out of range' + })); } /** diff --git a/server/test/controllers/role.spec.js b/server/test/controllers/role.spec.js index 78be137..d24b448 100644 --- a/server/test/controllers/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -81,18 +81,6 @@ describe('Roles', () => { done(); }); }); - it('Should return an error if the title is not a string', (done) => { - chai.request(server) - .post('/api/v1/roles') - .set({ authorization: adminToken }) - .send({ title: 358583 }) - .end((err, res) => { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); }); describe('/GET Role', () => { @@ -174,18 +162,17 @@ describe('Roles', () => { done(); }); }); - // it('Should fail to get a role by id if the id is out of range', (done) => { - // const id = 500000000000000000000; - // chai.request(server) - // .get(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it('Should fail to get a role by id if the id is out of range', (done) => { + const id = 500000000000000000000; + request(server) + .get(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/PUT/:id Role', () => { it('Should update a role by id if the user has admin access', (done) => { @@ -231,39 +218,38 @@ describe('Roles', () => { done(); }); }); - // it(`Should fail to update a role by - // id if the admin enters an id that is out range`, - // (done) => { - // const id = 2000000000000000; - // chai.request(server) - // .put(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .send({ title: 'regular' }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it(`Should fail to update a role by id if the + admin enters an id that is out range`, (done) => { + const id = 2000000000000000; + request(server) + .put(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .send({ title: 'regular' }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); }); describe('/DELETE/:id Role', () => { it('Should delete a role given the user has admin access', (done) => { const id = 3; - chai.request(server) + request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(204); expect(res.body).to.be.a('object'); + expect(res.body.message).to.be.eql('Role deleted successfully'); }); done(); }); it('Should fail to delete a role given the user has no admin access', (done) => { const id = 3; - chai.request(server) + request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -273,32 +259,32 @@ describe('Roles', () => { done(); }); }); - // it('Should fail to delete a role given the admin enters an invalid input', - // (done) => { - // const id = 300; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.equal('Role not found'); - // done(); - // }); - // }); - // it(`Should fail to delete a role given - // the admin enters an input that is out of range`, (done) => { - // const id = 3000000000000000; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); + it(`Should fail to delete a role + given the admin enters an id that is not found`, + (done) => { + const id = 300; + request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('Role not found'); + done(); + }); + }); + it(`Should fail to delete a role given the admin + enters an input that is out of range`, (done) => { + const id = 3000000000000000; + request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(400); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.equal('out of range for type integer'); + done(); + }); + }); }); }); diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index ed89bfb..a502c07 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -84,11 +84,9 @@ describe('Search', () => { .set({ authorization: adminToken }) .end((err, res) => { expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); expect(res.body.document[0].title).to.equal('John Doe'); expect(res.body.document[0].content).to.equal('eze goes to school'); expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); done(); }); }); diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index cc593d6..3547f8a 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -223,7 +223,7 @@ describe('Users', () => { .end((err, res) => { expect(res.status).to.equal(400); expect(res.body).to.have.property('message') - .to.equal(`value "${id}" is out of range for type integer`); + .to.equal('out of range'); done(); }); }); From b76587b4032e03af5ec2bcbdf4c510c060df28e7 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Wed, 2 Aug 2017 15:44:44 +0100 Subject: [PATCH 42/98] feat(test): resolve gulp coverage -ensure coverage is showing. --- .babelrc | 9 ++- coverage/document-manager/index.html | 10 +-- coverage/document-manager/index.js.html | 8 +-- .../server/config/config.js.html | 2 +- .../server/config/express.js.html | 16 ++--- .../document-manager/server/config/index.html | 10 +-- .../server/controllers/documents.js.html | 40 +++++------ .../server/controllers/index.html | 42 +++++------ .../server/controllers/roles.js.html | 14 ++-- .../server/controllers/search.js.html | 26 +++---- .../server/controllers/users.js.html | 40 +++++------ .../server/helpers/helper.js.html | 2 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 12 ++-- .../server/middlewares/index.html | 20 +++--- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 20 +++--- .../server/models/index.js.html | 16 ++--- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 12 ++-- .../document-manager/server/routes/index.html | 26 +++---- .../server/routes/index.js.html | 16 ++--- .../server/routes/roles.js.html | 12 ++-- .../server/routes/search.js.html | 12 ++-- .../server/routes/users.js.html | 12 ++-- .../test/controllers/document.spec.js.html | 2 +- .../server/test/controllers/index.html | 2 +- .../server/test/controllers/mockData.js.html | 2 +- .../server/test/controllers/role.spec.js.html | 2 +- .../test/controllers/search.spec.js.html | 2 +- .../server/test/controllers/user.spec.js.html | 2 +- coverage/index.html | 69 ++++++++----------- dist/gulpfile.babel.js | 41 +++++------ gulpfile.babel.js | 35 +++------- package.json | 22 +++++- 36 files changed, 279 insertions(+), 285 deletions(-) diff --git a/.babelrc b/.babelrc index 3c078e9..26abaf8 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,12 @@ { "presets": [ "es2015" - ] + ], + "env": { + "test": { + "plugins": [ + "istanbul" + ] + } + } } diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index 6f90394..e12963d 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -22,7 +22,7 @@

100% Statements - 4/4 + 3/3
100% @@ -37,7 +37,7 @@

100% Lines - 4/4 + 3/3

@@ -62,13 +62,13 @@

index.js
100%4/43/3 100% 2/2 100% 1/1 100%4/43/3
1x +10    1x   @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index e8cf1d8..5906f8a 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -124,7 +124,7 @@

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index e0ca8c5..17cea69 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -22,7 +22,7 @@

100% Statements - 20/20 + 15/15
100% @@ -37,7 +37,7 @@

100% Lines - 19/19 + 14/14

@@ -73,11 +73,11 @@

28 29 30 -31

1x -1x -1x -1x -1x +31  +  +  +  +    1x   @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index 89116f6..4df71ae 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -22,7 +22,7 @@

100% Statements - 21/21 + 16/16
100% @@ -37,7 +37,7 @@

100% Lines - 20/20 + 15/15

@@ -75,13 +75,13 @@

express.js
100%20/2015/15 100% 2/2 100% 2/2 100%19/1914/14
- - - - + + + + - - + + @@ -86,28 +86,28 @@

- - - + + + - - + + - - - + + + - - + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index d38538d..5fb948d 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -349,11 +349,11 @@

message: 'Role successfully created', role }); - }).catch((error) => { + }).catch((error) => { res.json(error.errors); }); } - }).catch(error => res.json(error)); + }).catch(error => res.json(error)); } }   @@ -367,7 +367,7 @@

return Role .findAll() .then(role => res.status(200).json(role)) - .catch(error => res.json(error)); + .catch(error => res.json(error)); }   /** @@ -418,13 +418,13 @@

} return role .update({ - title: req.body.title || role.title + title: req.body.title || role.title }) .then(() => res.status(200).json({ message: 'Role updated successfully', role })) - .catch(error => res.status(400).json(error)); + .catch(error => res.status(400).json(error)); }).catch(() => res.status(400).json({ message: 'out of range for type integer' })); @@ -450,7 +450,7 @@

} return role .destroy() - .then(() => res.status(204).send({ + .then(() => res.status(204).send({ message: 'Role deleted successfully' })) .catch(error => res.status(400).send(error)); @@ -466,7 +466,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index af6d002..717f82d 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -20,9 +20,9 @@

- 82.86% + 80% Statements - 29/35 + 24/30
71.43% @@ -35,9 +35,9 @@

5/8

- 82.86% + 80% Lines - 29/35 + 24/30
@@ -172,8 +172,8 @@

127 128 129 -130

- - - + + + - - + + @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 5247eb1..5de7ab7 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -133,7 +133,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 763d5a3..1db7ace 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -20,9 +20,9 @@

- 97.5% + 97.44% Statements - 39/40 + 38/39
66.67% @@ -35,9 +35,9 @@

9/9

- 97.5% + 97.44% Lines - 39/40 + 38/39
@@ -73,15 +73,15 @@

- - - + + + - - + + @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index d5dd340..879b5a8 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -20,9 +20,9 @@

- 95.83% + 95.65% Statements - 23/24 + 22/23
66.67% @@ -35,9 +35,9 @@

3/3

- 95.83% + 95.65% Lines - 23/24 + 22/23
@@ -98,7 +98,7 @@

  1x   -1x +  1x     @@ -109,8 +109,8 @@

  1x   -4x   +4x       @@ -138,7 +138,7 @@

const Sequelize = require('sequelize');   const basename = path.basename(module.filename); -const env = process.env.NODE_ENV || 'development'; +const env = process.env.NODE_ENV || 'development'; const config = require('../config/config.js')[env];   const db = {}; @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index 5c0a78c..abac66e 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 761a76e..076d4e6 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -166,7 +166,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index ce87407..e031203 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -22,7 +22,7 @@

100% Statements - 6/6 + 3/3
100% @@ -37,7 +37,7 @@

100% Lines - 6/6 + 3/3

@@ -67,9 +67,9 @@

22 23 24 -25

- + - + - + - + - + - + - + - + - + - + @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index 7f5f6a9..e514fdc 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -22,7 +22,7 @@

100% Statements - 10/10 + 5/5
100% @@ -37,7 +37,7 @@

100% Lines - 10/10 + 5/5

@@ -59,11 +59,11 @@

14 15 16 -17

- + - + - + - + - - - + + + - - + + @@ -112,54 +112,41 @@

- - - + + + - - + + - - - + + + - - + + - + - - - - - - - - - - - - - - + @@ -168,7 +155,7 @@

diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js index f697f6b..ad0581b 100644 --- a/dist/gulpfile.babel.js +++ b/dist/gulpfile.babel.js @@ -12,9 +12,13 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path); -var _gulpExit = require('gulp-exit'); +var _gulpInjectModules = require('gulp-inject-modules'); -var _gulpExit2 = _interopRequireDefault(_gulpExit); +var _gulpInjectModules2 = _interopRequireDefault(_gulpInjectModules); + +var _gulpCoveralls = require('gulp-coveralls'); + +var _gulpCoveralls2 = _interopRequireDefault(_gulpCoveralls); var _gulpIstanbul = require('gulp-istanbul'); @@ -24,15 +28,20 @@ var _gulpMocha = require('gulp-mocha'); var _gulpMocha2 = _interopRequireDefault(_gulpMocha); +var _gulpExit = require('gulp-exit'); + +var _gulpExit2 = _interopRequireDefault(_gulpExit); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Load the gulp plugins into the `plugins` variable var plugins = (0, _gulpLoadPlugins2.default)(); -_gulp2.default.task('tests', function () { - _gulp2.default.src('./server/tests/*.js').pipe(plugins.babel()).pipe((0, _gulpMocha2.default)()).pipe((0, _gulpExit2.default)()); +_gulp2.default.task('mochaTest', function () { + _gulp2.default.src(['dist/server/test/**/*.js']).pipe((0, _gulpMocha2.default)({ + reporter: 'spec' + })); }); - // Compile all Babel Javascript into ES5 and place in dist folder var paths = { js: ['./**/*.js', '!dist/**', '!node_modules/**'] @@ -43,22 +52,14 @@ _gulp2.default.task('babel', function () { return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); }); -_gulp2.default.task('pre-test', function () { - return _gulp2.default.src(['server/**/*.js', '!server/test/', '!gulpfile.js']) - // Covering files - .pipe((0, _gulpIstanbul2.default)({ includeUntested: true })).pipe(_gulpIstanbul2.default.hookRequire()); +_gulp2.default.task('coverage', function (cb) { + _gulp2.default.src('./dist/controllers/*.js').pipe((0, _gulpIstanbul2.default)()).pipe(_gulpIstanbul2.default.hookRequire()).on('finish', function () { + _gulp2.default.src('dist/sertest/*.js').pipe(plugins.babel()).pipe((0, _gulpInjectModules2.default)()).pipe((0, _gulpMocha2.default)()).pipe(_gulpIstanbul2.default.writeReports()).pipe(_gulpIstanbul2.default.enforceThresholds({ thresholds: { global: 30 } })).on('end', cb).pipe((0, _gulpExit2.default)()); + }); }); -_gulp2.default.task('test', ['pre-test'], function () { - return _gulp2.default.src(['test/**/*spec.js']).pipe((0, _gulpMocha2.default)({ - reporter: 'mochawesome' - })) - // Creating the reports after tests ran - .pipe(_gulpIstanbul2.default.writeReports({ - dir: './server/unit-test-coverage', - reporters: ['html'], - reportOpts: { dir: './unit-test-coverage' } - })).pipe(_gulpIstanbul2.default.enforceThresholds({ thresholds: { global: 90 } })); +_gulp2.default.task('coveralls', function () { + return _gulp2.default.src('./coverage/lcov').pipe((0, _gulpCoveralls2.default)()); }); // Restart server with on every changes made to file @@ -71,6 +72,6 @@ _gulp2.default.task('nodemon', ['babel'], function () { }); }); -_gulp2.default.task('test', ['tests']); +_gulp2.default.task('test', ['mochaTest']); _gulp2.default.task('default', ['nodemon']); _gulp2.default.task('production', ['babel']); \ No newline at end of file diff --git a/gulpfile.babel.js b/gulpfile.babel.js index a3fb131..db8f8c4 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,21 +1,12 @@ import gulp from 'gulp'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; -import injectModules from 'gulp-inject-modules'; import coveralls from 'gulp-coveralls'; -import istanbul from 'gulp-istanbul'; -import mocha from 'gulp-mocha'; -import exit from 'gulp-exit'; +import shell from 'gulp-shell'; // Load the gulp plugins into the `plugins` variable const plugins = loadPlugins(); -gulp.task('mochaTest', () => { - gulp.src(['dist/server/test/**/*.js']) - .pipe(mocha({ - reporter: 'spec', - })); -}); // Compile all Babel Javascript into ES5 and place in dist folder const paths = { js: ['./**/*.js', '!dist/**', '!node_modules/**'] @@ -28,21 +19,13 @@ gulp.task('babel', () => .pipe(gulp.dest('dist')) ); -gulp.task('coverage', (cb) => { - gulp.src('dist/server/test/controllers/*.js') - .pipe(istanbul()) - .pipe(istanbul.hookRequire()) - .on('finish', () => { - gulp.src('dist/server/test/*.js') - .pipe(plugins.babel()) - .pipe(injectModules()) - .pipe(mocha()) - .pipe(istanbul.writeReports()) - .pipe(istanbul.enforceThresholds({ thresholds: { global: 30 } })) - .on('end', cb) - .pipe(exit()); - }); -}); +gulp.task('migrate', shell.task([ + 'cross-env NODE_ENV=test sequelize db:migrate', +])); + +gulp.task('coverage', shell.task([ + 'cross-env NODE_ENV=test nyc mocha ./server/test/**/*.js', +])); gulp.task('coveralls', () => gulp.src('./coverage/lcov') .pipe(coveralls())); @@ -58,6 +41,6 @@ gulp.task('nodemon', ['babel'], () => }) ); -gulp.task('test', ['mochaTest']); +gulp.task('test', ['migrate', 'coverage']); gulp.task('default', ['nodemon']); gulp.task('production', ['babel']); diff --git a/package.json b/package.json index 13e44a3..82890ed 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,23 @@ "dev": "node node_modules/gulp/bin/gulp", "pretest": "npm run cleardb && NODE_ENV=test sequelize db:migrate && NODE_ENV=test sequelize db:seed:all", "test": "NODE_ENV=test node node_modules/gulp/bin/gulp test", - "devtest": "NODE_ENV=test gulp test", - "eslint": "eslint index.js", "cleardb": "NODE_ENV=test sequelize db:migrate:undo:all" }, + "nyc": { + "require": [ + "babel-register" + ], + "reporter": [ + "lcov", + "text", + "html" + ], + "sourceMap": false, + "instrument": false, + "exclude": [ + "server/test" + ] + }, "repository": { "type": "git", "url": "git+https://github.com/iakhator/document-manager.git" @@ -25,13 +38,15 @@ "homepage": "https://github.com/iakhator/document-manager#readme", "dependencies": { "babel": "^6.23.0", - "babel-core": "^6.25.0", "babel-cli": "^6.24.1", + "babel-core": "^6.25.0", "babel-plugin-istanbul": "^4.1.4", "babel-preset-es2015": "^6.24.1", + "babel-preset-stage-2": "^6.24.1", "babel-register": "^6.24.1", "bcrypt": "^1.0.2", "body-parser": "^1.17.2", + "cross-env": "^5.0.2", "dotenv": "^4.0.0", "eslint": "^3.19.0", "eslint-config-airbnb": "^15.0.2", @@ -44,6 +59,7 @@ "gulp-load-plugins": "^1.5.0", "gulp-mocha": "^4.3.1", "gulp-nodemon": "^2.2.1", + "gulp-shell": "^0.6.3", "jsonwebtoken": "^7.4.1", "mocha": "^3.4.2", "morgan": "^1.8.2", From c571cd5c7ffb384cdaa95e9f53078bb3cadad71b Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 16:07:54 +0100 Subject: [PATCH 43/98] feat(testing):testing - ensure all tests are passing - ensure tests follow proper guide [Finishes #149632847] --- .coveralls.yml | 1 + .env | 1 + .gitignore | 5 +- .travis.yml | 10 + README.md | 4 +- codeclimate.yml | 7 + coverage/document-manager/index.html | 2 +- coverage/document-manager/index.js.html | 2 +- .../server/config/config.js.html | 16 +- .../server/config/express.js.html | 16 +- .../document-manager/server/config/index.html | 10 +- .../server/controllers/documents.js.html | 2 +- .../server/controllers/index.html | 2 +- .../server/controllers/roles.js.html | 12 +- .../server/controllers/search.js.html | 2 +- .../server/controllers/users.js.html | 28 +- .../server/helpers/helper.js.html | 2 +- .../server/helpers/index.html | 2 +- .../server/middlewares/auth.js.html | 18 +- .../server/middlewares/index.html | 2 +- .../server/models/document.js.html | 2 +- .../document-manager/server/models/index.html | 2 +- .../server/models/index.js.html | 2 +- .../server/models/role.js.html | 2 +- .../server/models/user.js.html | 2 +- .../server/routes/documents.js.html | 2 +- .../document-manager/server/routes/index.html | 2 +- .../server/routes/index.js.html | 2 +- .../server/routes/roles.js.html | 2 +- .../server/routes/search.js.html | 2 +- .../server/routes/users.js.html | 2 +- coverage/index.html | 14 +- dist/coverage/prettify.js | 363 ------------------ dist/coverage/sorter.js | 169 -------- dist/gulpfile.babel.js | 77 ---- dist/index.js | 19 - dist/server/config/config.js | 27 -- dist/server/config/express.js | 51 --- dist/server/controllers/documents.js | 241 ------------ dist/server/controllers/roles.js | 148 ------- dist/server/controllers/search.js | 148 ------- dist/server/controllers/users.js | 302 --------------- dist/server/helpers/helper.js | 12 - dist/server/middlewares/auth.js | 44 --- .../migrations/20170709115213-create-role.js | 30 -- .../migrations/20170709115254-create-user.js | 54 --- .../20170709120158-create-document.js | 46 --- dist/server/models/document.js | 29 -- dist/server/models/index.js | 41 -- dist/server/models/role.js | 17 - dist/server/models/user.js | 41 -- dist/server/routes/documents.js | 40 -- dist/server/routes/index.js | 37 -- dist/server/routes/roles.js | 40 -- dist/server/routes/search.js | 31 -- dist/server/routes/users.js | 48 --- .../seeders/20170727152600-sample-roles.js | 23 -- .../seeders/20170727153559-sample-users.js | 38 -- .../20170727153641-sample-documents.js | 32 -- dist/server/test/controllers/document.spec.js | 325 ---------------- dist/server/test/controllers/mockData.js | 63 --- dist/server/test/controllers/role.spec.js | 230 ----------- dist/server/test/controllers/search.spec.js | 102 ----- dist/server/test/controllers/user.spec.js | 306 --------------- server/config/config.js | 9 +- server/controllers/roles.js | 4 +- server/test/controllers/document.spec.js | 16 +- server/test/controllers/role.spec.js | 60 ++- server/test/controllers/search.spec.js | 14 +- server/test/controllers/user.spec.js | 6 - 70 files changed, 139 insertions(+), 3324 deletions(-) create mode 100644 .coveralls.yml create mode 100644 .travis.yml create mode 100644 codeclimate.yml delete mode 100644 dist/coverage/prettify.js delete mode 100644 dist/coverage/sorter.js delete mode 100644 dist/gulpfile.babel.js delete mode 100644 dist/index.js delete mode 100644 dist/server/config/config.js delete mode 100644 dist/server/config/express.js delete mode 100644 dist/server/controllers/documents.js delete mode 100644 dist/server/controllers/roles.js delete mode 100644 dist/server/controllers/search.js delete mode 100644 dist/server/controllers/users.js delete mode 100644 dist/server/helpers/helper.js delete mode 100644 dist/server/middlewares/auth.js delete mode 100644 dist/server/migrations/20170709115213-create-role.js delete mode 100644 dist/server/migrations/20170709115254-create-user.js delete mode 100644 dist/server/migrations/20170709120158-create-document.js delete mode 100644 dist/server/models/document.js delete mode 100644 dist/server/models/index.js delete mode 100644 dist/server/models/role.js delete mode 100644 dist/server/models/user.js delete mode 100644 dist/server/routes/documents.js delete mode 100644 dist/server/routes/index.js delete mode 100644 dist/server/routes/roles.js delete mode 100644 dist/server/routes/search.js delete mode 100644 dist/server/routes/users.js delete mode 100644 dist/server/seeders/20170727152600-sample-roles.js delete mode 100644 dist/server/seeders/20170727153559-sample-users.js delete mode 100644 dist/server/seeders/20170727153641-sample-documents.js delete mode 100644 dist/server/test/controllers/document.spec.js delete mode 100644 dist/server/test/controllers/mockData.js delete mode 100644 dist/server/test/controllers/role.spec.js delete mode 100644 dist/server/test/controllers/search.spec.js delete mode 100644 dist/server/test/controllers/user.spec.js diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..f1836d6 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +repo_token: XfNKTpzGyMpLobup5VwEThnBUw1sre4NX diff --git a/.env b/.env index 3ab0297..ff9a3ea 100644 --- a/.env +++ b/.env @@ -3,3 +3,4 @@ TEST_ADMIN_PASSWORD=pass123 TEST_FELLOW_PASSWORD=pass123 TEST_FACILITATOR_PASSWORD=pass123 PASSWORD=pass123 +TEST_DB=postgres://qvugccno:lEPRlNKRx7zt50Ua_qH7JvCDf7Lt5xEt@babar.elephantsql.com:5432/qvugccno diff --git a/.gitignore b/.gitignore index ae8e603..c1c6e73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ node_modules/ -coverage/ -.nyc_output/ +coverage +.nyc_output .DS_Store .env dist/ .coverdata/ +.coverrun npm-debug.log diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..114ca44 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: node_js +node_js: +- '6' +before_script: +- npm install -g gulp-cli +script: npm test +after_success: +- npm install -g codeclimate-test-reporter +- codeclimate-test-reporter < ./coverage/lcov.info +- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/README.md b/README.md index 1462989..ba8dd7e 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# document-manager \ No newline at end of file +# document-manager +[![Coverage Status](https://coveralls.io/repos/github/iakhator/document-manager/badge.svg?branch=staging)](https://coveralls.io/github/iakhator/document-manager?branch=staging) +[![Code [![Code Climate](https://codeclimate.com/github/iakhator/Document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) diff --git a/codeclimate.yml b/codeclimate.yml new file mode 100644 index 0000000..a287ac0 --- /dev/null +++ b/codeclimate.yml @@ -0,0 +1,7 @@ +engines: + duplication: + enabled: false + config: + languages: + javascript: + mass_threshold: 20 diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html index e12963d..f38a538 100644 --- a/coverage/document-manager/index.html +++ b/coverage/document-manager/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html index 2ccb50a..97543a5 100644 --- a/coverage/document-manager/index.js.html +++ b/coverage/document-manager/index.js.html @@ -76,7 +76,7 @@

diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html index 5906f8a..46da18d 100644 --- a/coverage/document-manager/server/config/config.js.html +++ b/coverage/document-manager/server/config/config.js.html @@ -22,7 +22,7 @@

100% Statements - 1/1 + 2/2
100% @@ -37,7 +37,7 @@

100% Lines - 1/1 + 2/2

@@ -68,8 +68,11 @@

23 24 25 -26

- + - + @@ -90,7 +90,7 @@

diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html index bc4ed32..a3f2bee 100644 --- a/coverage/document-manager/server/controllers/documents.js.html +++ b/coverage/document-manager/server/controllers/documents.js.html @@ -727,7 +727,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index f9ed5d0..a7e62cf 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html index 5fb948d..d59d69c 100644 --- a/coverage/document-manager/server/controllers/roles.js.html +++ b/coverage/document-manager/server/controllers/roles.js.html @@ -298,18 +298,18 @@

      -2x +3x       -2x +3x   2x 1x       -2x +1x       @@ -444,7 +444,7 @@

return Role.findById(req.params.id) .then((role) => { if (!role) { - res.status(404).json({ + return res.status(404).json({ message: 'Role not found' }); } @@ -453,7 +453,7 @@

.then(() => res.status(204).send({ message: 'Role deleted successfully' })) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }).catch(() => res.status(400).json({ message: 'out of range for type integer' })); @@ -466,7 +466,7 @@

diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html index 717f82d..597b68a 100644 --- a/coverage/document-manager/server/controllers/search.js.html +++ b/coverage/document-manager/server/controllers/search.js.html @@ -436,7 +436,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index b5e4bac..46bbbbe 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -415,38 +415,38 @@

      -15x -15x -15x +13x +13x +13x   -15x +13x   -15x +13x     -15x +13x       -15x -15x +13x +13x 1x     -14x -14x +12x +12x   -13x +11x             -13x +11x     -13x +11x       @@ -904,7 +904,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index 2cef2dd..71d1146 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index b708132..1d955e8 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index 11c30ee..e8ec699 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -84,14 +84,14 @@

      -67x -67x -63x -63x +68x +68x +64x +64x     -63x -63x +64x +64x       @@ -103,8 +103,8 @@

      -22x -16x +23x +17x   6x   @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index a49ae60..71d0a8c 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html index 5de7ab7..f71df09 100644 --- a/coverage/document-manager/server/models/document.js.html +++ b/coverage/document-manager/server/models/document.js.html @@ -133,7 +133,7 @@

diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html index 1db7ace..8be4e8e 100644 --- a/coverage/document-manager/server/models/index.html +++ b/coverage/document-manager/server/models/index.html @@ -116,7 +116,7 @@

diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html index 879b5a8..33122f1 100644 --- a/coverage/document-manager/server/models/index.js.html +++ b/coverage/document-manager/server/models/index.js.html @@ -184,7 +184,7 @@

diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html index abac66e..730f82d 100644 --- a/coverage/document-manager/server/models/role.js.html +++ b/coverage/document-manager/server/models/role.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html index 076d4e6..2ae394f 100644 --- a/coverage/document-manager/server/models/user.js.html +++ b/coverage/document-manager/server/models/user.js.html @@ -166,7 +166,7 @@

diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html index e031203..2ac7df4 100644 --- a/coverage/document-manager/server/routes/documents.js.html +++ b/coverage/document-manager/server/routes/documents.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index 9acaf25..0ab127b 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html index e514fdc..a945750 100644 --- a/coverage/document-manager/server/routes/index.js.html +++ b/coverage/document-manager/server/routes/index.js.html @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index 638133e..0b7a702 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index b213d87..a229dd2 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index d7a9982..08999fc 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -145,7 +145,7 @@

diff --git a/coverage/index.html b/coverage/index.html index 886022a..d3d8787 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,9 +20,9 @@

- 86.36% + 86.41% Statements - 266/308 + 267/309
81.02% @@ -35,9 +35,9 @@

73/100

- 86.27% + 86.32% Lines - 264/306 + 265/307
@@ -75,13 +75,13 @@

- + - + @@ -155,7 +155,7 @@

diff --git a/dist/coverage/prettify.js b/dist/coverage/prettify.js deleted file mode 100644 index 17e401d..0000000 --- a/dist/coverage/prettify.js +++ /dev/null @@ -1,363 +0,0 @@ -"use strict"; - -window.PR_SHOULD_USE_CONTINUATION = true;(function () { - var h = ["break,continue,do,else,for,if,return,while"];var u = [h, "auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p = [u, "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l = [p, "alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x = [p, "abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R = [x, "as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r = "all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w = [p, "debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I = [h, "and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f = [h, "alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H = [h, "case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A = [l, R, w, s + I, f, H];var e = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C = "str";var z = "kwd";var j = "com";var O = "typ";var G = "lit";var L = "pun";var F = "pln";var m = "tag";var E = "dec";var J = "src";var P = "atn";var n = "atv";var N = "nocode";var M = "(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z) { - var ad = 0;var S = false;var ac = false;for (var V = 0, U = Z.length; V < U; ++V) { - var ae = Z[V];if (ae.ignoreCase) { - ac = true; - } else { - if (/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ""))) { - S = true;ac = false;break; - } - } - }var Y = { b: 8, t: 9, n: 10, v: 11, f: 12, r: 13 };function ab(ah) { - var ag = ah.charCodeAt(0);if (ag !== 92) { - return ag; - }var af = ah.charAt(1);ag = Y[af];if (ag) { - return ag; - } else { - if ("0" <= af && af <= "7") { - return parseInt(ah.substring(1), 8); - } else { - if (af === "u" || af === "x") { - return parseInt(ah.substring(2), 16); - } else { - return ah.charCodeAt(1); - } - } - } - }function T(af) { - if (af < 32) { - return (af < 16 ? "\\x0" : "\\x") + af.toString(16); - }var ag = String.fromCharCode(af);if (ag === "\\" || ag === "-" || ag === "[" || ag === "]") { - ag = "\\" + ag; - }return ag; - }function X(am) { - var aq = am.substring(1, am.length - 1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));var ak = [];var af = [];var ao = aq[0] === "^";for (var ar = ao ? 1 : 0, aj = aq.length; ar < aj; ++ar) { - var ah = aq[ar];if (/\\[bdsw]/i.test(ah)) { - ak.push(ah); - } else { - var ag = ab(ah);var al;if (ar + 2 < aj && "-" === aq[ar + 1]) { - al = ab(aq[ar + 2]);ar += 2; - } else { - al = ag; - }af.push([ag, al]);if (!(al < 65 || ag > 122)) { - if (!(al < 65 || ag > 90)) { - af.push([Math.max(65, ag) | 32, Math.min(al, 90) | 32]); - }if (!(al < 97 || ag > 122)) { - af.push([Math.max(97, ag) & ~32, Math.min(al, 122) & ~32]); - } - } - } - }af.sort(function (av, au) { - return av[0] - au[0] || au[1] - av[1]; - });var ai = [];var ap = [NaN, NaN];for (var ar = 0; ar < af.length; ++ar) { - var at = af[ar];if (at[0] <= ap[1] + 1) { - ap[1] = Math.max(ap[1], at[1]); - } else { - ai.push(ap = at); - } - }var an = ["["];if (ao) { - an.push("^"); - }an.push.apply(an, ak);for (var ar = 0; ar < ai.length; ++ar) { - var at = ai[ar];an.push(T(at[0]));if (at[1] > at[0]) { - if (at[1] + 1 > at[0]) { - an.push("-"); - }an.push(T(at[1])); - } - }an.push("]");return an.join(""); - }function W(al) { - var aj = al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g"));var ah = aj.length;var an = [];for (var ak = 0, am = 0; ak < ah; ++ak) { - var ag = aj[ak];if (ag === "(") { - ++am; - } else { - if ("\\" === ag.charAt(0)) { - var af = +ag.substring(1);if (af && af <= am) { - an[af] = -1; - } - } - } - }for (var ak = 1; ak < an.length; ++ak) { - if (-1 === an[ak]) { - an[ak] = ++ad; - } - }for (var ak = 0, am = 0; ak < ah; ++ak) { - var ag = aj[ak];if (ag === "(") { - ++am;if (an[am] === undefined) { - aj[ak] = "(?:"; - } - } else { - if ("\\" === ag.charAt(0)) { - var af = +ag.substring(1);if (af && af <= am) { - aj[ak] = "\\" + an[am]; - } - } - } - }for (var ak = 0, am = 0; ak < ah; ++ak) { - if ("^" === aj[ak] && "^" !== aj[ak + 1]) { - aj[ak] = ""; - } - }if (al.ignoreCase && S) { - for (var ak = 0; ak < ah; ++ak) { - var ag = aj[ak];var ai = ag.charAt(0);if (ag.length >= 2 && ai === "[") { - aj[ak] = X(ag); - } else { - if (ai !== "\\") { - aj[ak] = ag.replace(/[a-zA-Z]/g, function (ao) { - var ap = ao.charCodeAt(0);return "[" + String.fromCharCode(ap & ~32, ap | 32) + "]"; - }); - } - } - } - }return aj.join(""); - }var aa = [];for (var V = 0, U = Z.length; V < U; ++V) { - var ae = Z[V];if (ae.global || ae.multiline) { - throw new Error("" + ae); - }aa.push("(?:" + W(ae) + ")"); - }return new RegExp(aa.join("|"), ac ? "gi" : "g"); - }function a(V) { - var U = /(?:^|\s)nocode(?:\s|$)/;var X = [];var T = 0;var Z = [];var W = 0;var S;if (V.currentStyle) { - S = V.currentStyle.whiteSpace; - } else { - if (window.getComputedStyle) { - S = document.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); - } - }var Y = S && "pre" === S.substring(0, 3);function aa(ab) { - switch (ab.nodeType) {case 1: - if (U.test(ab.className)) { - return; - }for (var ae = ab.firstChild; ae; ae = ae.nextSibling) { - aa(ae); - }var ad = ab.nodeName;if ("BR" === ad || "LI" === ad) { - X[W] = "\n";Z[W << 1] = T++;Z[W++ << 1 | 1] = ab; - }break;case 3:case 4: - var ac = ab.nodeValue;if (ac.length) { - if (!Y) { - ac = ac.replace(/[ \t\r\n]+/g, " "); - } else { - ac = ac.replace(/\r\n?/g, "\n"); - }X[W] = ac;Z[W << 1] = T;T += ac.length;Z[W++ << 1 | 1] = ab; - }break;} - }aa(V);return { sourceCode: X.join("").replace(/\n$/, ""), spans: Z }; - }function B(S, U, W, T) { - if (!U) { - return; - }var V = { sourceCode: U, basePos: S };W(V);T.push.apply(T, V.decorations); - }var v = /\S/;function o(S) { - var V = undefined;for (var U = S.firstChild; U; U = U.nextSibling) { - var T = U.nodeType;V = T === 1 ? V ? S : U : T === 3 ? v.test(U.nodeValue) ? S : V : V; - }return V === S ? undefined : V; - }function g(U, T) { - var S = {};var V;(function () { - var ad = U.concat(T);var ah = [];var ag = {};for (var ab = 0, Z = ad.length; ab < Z; ++ab) { - var Y = ad[ab];var ac = Y[3];if (ac) { - for (var ae = ac.length; --ae >= 0;) { - S[ac.charAt(ae)] = Y; - } - }var af = Y[1];var aa = "" + af;if (!ag.hasOwnProperty(aa)) { - ah.push(af);ag[aa] = null; - } - }ah.push(/[\0-\uffff]/);V = k(ah); - })();var X = T.length;var W = function W(ah) { - var Z = ah.sourceCode, - Y = ah.basePos;var ad = [Y, F];var af = 0;var an = Z.match(V) || [];var aj = {};for (var ae = 0, aq = an.length; ae < aq; ++ae) { - var ag = an[ae];var ap = aj[ag];var ai = void 0;var am;if (typeof ap === "string") { - am = false; - } else { - var aa = S[ag.charAt(0)];if (aa) { - ai = ag.match(aa[1]);ap = aa[0]; - } else { - for (var ao = 0; ao < X; ++ao) { - aa = T[ao];ai = ag.match(aa[1]);if (ai) { - ap = aa[0];break; - } - }if (!ai) { - ap = F; - } - }am = ap.length >= 5 && "lang-" === ap.substring(0, 5);if (am && !(ai && typeof ai[1] === "string")) { - am = false;ap = J; - }if (!am) { - aj[ag] = ap; - } - }var ab = af;af += ag.length;if (!am) { - ad.push(Y + ab, ap); - } else { - var al = ai[1];var ak = ag.indexOf(al);var ac = ak + al.length;if (ai[2]) { - ac = ag.length - ai[2].length;ak = ac - al.length; - }var ar = ap.substring(5);B(Y + ab, ag.substring(0, ak), W, ad);B(Y + ab + ak, al, q(ar, al), ad);B(Y + ab + ac, ag.substring(ac), W, ad); - } - }ah.decorations = ad; - };return W; - }function i(T) { - var W = [], - S = [];if (T.tripleQuotedStrings) { - W.push([C, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, null, "'\""]); - } else { - if (T.multiLineStrings) { - W.push([C, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, null, "'\"`"]); - } else { - W.push([C, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, "\"'"]); - } - }if (T.verbatimStrings) { - S.push([C, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]); - }var Y = T.hashComments;if (Y) { - if (T.cStyleComments) { - if (Y > 1) { - W.push([j, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, "#"]); - } else { - W.push([j, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, "#"]); - }S.push([C, /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, null]); - } else { - W.push([j, /^#[^\r\n]*/, null, "#"]); - } - }if (T.cStyleComments) { - S.push([j, /^\/\/[^\r\n]*/, null]);S.push([j, /^\/\*[\s\S]*?(?:\*\/|$)/, null]); - }if (T.regexLiterals) { - var X = "/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/";S.push(["lang-regex", new RegExp("^" + M + "(" + X + ")")]); - }var V = T.types;if (V) { - S.push([O, V]); - }var U = ("" + T.keywords).replace(/^ | $/g, "");if (U.length) { - S.push([z, new RegExp("^(?:" + U.replace(/[\s,]+/g, "|") + ")\\b"), null]); - }W.push([F, /^\s+/, null, " \r\n\t\xA0"]);S.push([G, /^@[a-z_$][a-z_$@0-9]*/i, null], [O, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null], [F, /^[a-z_$][a-z_$@0-9]*/i, null], [G, new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*", "i"), null, "0123456789"], [F, /^\\[\s\S]?/, null], [L, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);return g(W, S); - }var K = i({ keywords: A, hashComments: true, cStyleComments: true, multiLineStrings: true, regexLiterals: true });function Q(V, ag) { - var U = /(?:^|\s)nocode(?:\s|$)/;var ab = /\r\n?|\n/;var ac = V.ownerDocument;var S;if (V.currentStyle) { - S = V.currentStyle.whiteSpace; - } else { - if (window.getComputedStyle) { - S = ac.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); - } - }var Z = S && "pre" === S.substring(0, 3);var af = ac.createElement("LI");while (V.firstChild) { - af.appendChild(V.firstChild); - }var W = [af];function ae(al) { - switch (al.nodeType) {case 1: - if (U.test(al.className)) { - break; - }if ("BR" === al.nodeName) { - ad(al);if (al.parentNode) { - al.parentNode.removeChild(al); - } - } else { - for (var an = al.firstChild; an; an = an.nextSibling) { - ae(an); - } - }break;case 3:case 4: - if (Z) { - var am = al.nodeValue;var aj = am.match(ab);if (aj) { - var ai = am.substring(0, aj.index);al.nodeValue = ai;var ah = am.substring(aj.index + aj[0].length);if (ah) { - var ak = al.parentNode;ak.insertBefore(ac.createTextNode(ah), al.nextSibling); - }ad(al);if (!ai) { - al.parentNode.removeChild(al); - } - } - }break;} - }function ad(ak) { - while (!ak.nextSibling) { - ak = ak.parentNode;if (!ak) { - return; - } - }function ai(al, ar) { - var aq = ar ? al.cloneNode(false) : al;var ao = al.parentNode;if (ao) { - var ap = ai(ao, 1);var an = al.nextSibling;ap.appendChild(aq);for (var am = an; am; am = an) { - an = am.nextSibling;ap.appendChild(am); - } - }return aq; - }var ah = ai(ak.nextSibling, 0);for (var aj; (aj = ah.parentNode) && aj.nodeType === 1;) { - ah = aj; - }W.push(ah); - }for (var Y = 0; Y < W.length; ++Y) { - ae(W[Y]); - }if (ag === (ag | 0)) { - W[0].setAttribute("value", ag); - }var aa = ac.createElement("OL");aa.className = "linenums";var X = Math.max(0, ag - 1 | 0) || 0;for (var Y = 0, T = W.length; Y < T; ++Y) { - af = W[Y];af.className = "L" + (Y + X) % 10;if (!af.firstChild) { - af.appendChild(ac.createTextNode("\xA0")); - }aa.appendChild(af); - }V.appendChild(aa); - }function D(ac) { - var aj = /\bMSIE\b/.test(navigator.userAgent);var am = /\n/g;var al = ac.sourceCode;var an = al.length;var V = 0;var aa = ac.spans;var T = aa.length;var ah = 0;var X = ac.decorations;var Y = X.length;var Z = 0;X[Y] = an;var ar, aq;for (aq = ar = 0; aq < Y;) { - if (X[aq] !== X[aq + 2]) { - X[ar++] = X[aq++];X[ar++] = X[aq++]; - } else { - aq += 2; - } - }Y = ar;for (aq = ar = 0; aq < Y;) { - var at = X[aq];var ab = X[aq + 1];var W = aq + 2;while (W + 2 <= Y && X[W + 1] === ab) { - W += 2; - }X[ar++] = at;X[ar++] = ab;aq = W; - }Y = X.length = ar;var ae = null;while (ah < T) { - var af = aa[ah];var S = aa[ah + 2] || an;var ag = X[Z];var ap = X[Z + 2] || an;var W = Math.min(S, ap);var ak = aa[ah + 1];var U;if (ak.nodeType !== 1 && (U = al.substring(V, W))) { - if (aj) { - U = U.replace(am, "\r"); - }ak.nodeValue = U;var ai = ak.ownerDocument;var ao = ai.createElement("SPAN");ao.className = X[Z + 1];var ad = ak.parentNode;ad.replaceChild(ao, ak);ao.appendChild(ak);if (V < S) { - aa[ah + 1] = ak = ai.createTextNode(al.substring(W, S));ad.insertBefore(ak, ao.nextSibling); - } - }V = W;if (V >= S) { - ah += 2; - }if (V >= ap) { - Z += 2; - } - } - }var t = {};function c(U, V) { - for (var S = V.length; --S >= 0;) { - var T = V[S];if (!t.hasOwnProperty(T)) { - t[T] = U; - } else { - if (window.console) { - console.warn("cannot override language handler %s", T); - } - } - } - }function q(T, S) { - if (!(T && t.hasOwnProperty(T))) { - T = /^\s*]*(?:>|$)/], [j, /^<\!--[\s\S]*?(?:-\->|$)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], [L, /^(?:<[%?]|[%?]>)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i]]), ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"]);c(g([[F, /^[\s]+/, null, " \t\r\n"], [n, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, "\"'"]], [[m, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i], [P, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i], ["lang-uq.val", /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/], [L, /^[=<>\/]+/], ["lang-js", /^on\w+\s*=\s*\"([^\"]+)\"/i], ["lang-js", /^on\w+\s*=\s*\'([^\']+)\'/i], ["lang-js", /^on\w+\s*=\s*([^\"\'>\s]+)/i], ["lang-css", /^style\s*=\s*\"([^\"]+)\"/i], ["lang-css", /^style\s*=\s*\'([^\']+)\'/i], ["lang-css", /^style\s*=\s*([^\"\'>\s]+)/i]]), ["in.tag"]);c(g([], [[n, /^[\s\S]+/]]), ["uq.val"]);c(i({ keywords: l, hashComments: true, cStyleComments: true, types: e }), ["c", "cc", "cpp", "cxx", "cyc", "m"]);c(i({ keywords: "null,true,false" }), ["json"]);c(i({ keywords: R, hashComments: true, cStyleComments: true, verbatimStrings: true, types: e }), ["cs"]);c(i({ keywords: x, cStyleComments: true }), ["java"]);c(i({ keywords: H, hashComments: true, multiLineStrings: true }), ["bsh", "csh", "sh"]);c(i({ keywords: I, hashComments: true, multiLineStrings: true, tripleQuotedStrings: true }), ["cv", "py"]);c(i({ keywords: s, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["perl", "pl", "pm"]);c(i({ keywords: f, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["rb"]);c(i({ keywords: w, cStyleComments: true, regexLiterals: true }), ["js"]);c(i({ keywords: r, hashComments: 3, cStyleComments: true, multilineStrings: true, tripleQuotedStrings: true, regexLiterals: true }), ["coffee"]);c(g([], [[C, /^[\s\S]+/]]), ["regex"]);function d(V) { - var U = V.langExtension;try { - var S = a(V.sourceNode);var T = S.sourceCode;V.sourceCode = T;V.spans = S.spans;V.basePos = 0;q(U, T)(V);D(V); - } catch (W) { - if ("console" in window) { - console.log(W && W.stack ? W.stack : W); - } - } - }function y(W, V, U) { - var S = document.createElement("PRE");S.innerHTML = W;if (U) { - Q(S, U); - }var T = { langExtension: V, numberLines: U, sourceNode: S };d(T);return S.innerHTML; - }function b(ad) { - function Y(af) { - return document.getElementsByTagName(af); - }var ac = [Y("pre"), Y("code"), Y("xmp")];var T = [];for (var aa = 0; aa < ac.length; ++aa) { - for (var Z = 0, V = ac[aa].length; Z < V; ++Z) { - T.push(ac[aa][Z]); - } - }ac = null;var W = Date;if (!W.now) { - W = { now: function now() { - return +new Date(); - } }; - }var X = 0;var S;var ab = /\blang(?:uage)?-([\w.]+)(?!\S)/;var ae = /\bprettyprint\b/;function U() { - var ag = window.PR_SHOULD_USE_CONTINUATION ? W.now() + 250 : Infinity;for (; X < T.length && W.now() < ag; X++) { - var aj = T[X];var ai = aj.className;if (ai.indexOf("prettyprint") >= 0) { - var ah = ai.match(ab);var am;if (!ah && (am = o(aj)) && "CODE" === am.tagName) { - ah = am.className.match(ab); - }if (ah) { - ah = ah[1]; - }var al = false;for (var ak = aj.parentNode; ak; ak = ak.parentNode) { - if ((ak.tagName === "pre" || ak.tagName === "code" || ak.tagName === "xmp") && ak.className && ak.className.indexOf("prettyprint") >= 0) { - al = true;break; - } - }if (!al) { - var af = aj.className.match(/\blinenums\b(?::(\d+))?/);af = af ? af[1] && af[1].length ? +af[1] : true : false;if (af) { - Q(aj, af); - }S = { langExtension: ah, sourceNode: aj, numberLines: af };d(S); - } - } - }if (X < T.length) { - setTimeout(U, 250); - } else { - if (ad) { - ad(); - } - } - }U(); - }window.prettyPrintOne = y;window.prettyPrint = b;window.PR = { createSimpleLexer: g, registerLangHandler: c, sourceDecorator: i, PR_ATTRIB_NAME: P, PR_ATTRIB_VALUE: n, PR_COMMENT: j, PR_DECLARATION: E, PR_KEYWORD: z, PR_LITERAL: G, PR_NOCODE: N, PR_PLAIN: F, PR_PUNCTUATION: L, PR_SOURCE: J, PR_STRING: C, PR_TAG: m, PR_TYPE: O }; -})();PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_DECLARATION, /^]*(?:>|$)/], [PR.PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/], [PR.PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-handlebars", /^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i], [PR.PR_DECLARATION, /^{{[#^>/]?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{&?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{{>?\s*[\w.][^}]*}}}/], [PR.PR_COMMENT, /^{{![^}]*}}/]]), ["handlebars", "hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN, /^[ \t\r\n\f]+/, null, " \t\r\n\f"]], [[PR.PR_STRING, /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null], [PR.PR_STRING, /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null], ["lang-css-str", /^url\(([^\)\"\']*)\)/i], [PR.PR_KEYWORD, /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i, null], ["lang-css-kw", /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i], [PR.PR_COMMENT, /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], [PR.PR_COMMENT, /^(?:)/], [PR.PR_LITERAL, /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], [PR.PR_LITERAL, /^#(?:[0-9a-f]{3}){1,2}/i], [PR.PR_PLAIN, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i], [PR.PR_PUNCTUATION, /^[^\s\w\'\"]+/]]), ["css"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_KEYWORD, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]), ["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_STRING, /^[^\)\"\']+/]]), ["css-str"]); \ No newline at end of file diff --git a/dist/coverage/sorter.js b/dist/coverage/sorter.js deleted file mode 100644 index 9519297..0000000 --- a/dist/coverage/sorter.js +++ /dev/null @@ -1,169 +0,0 @@ -'use strict'; - -var addSorting = function () { - "use strict"; - - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function sorter(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function finalSorter(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -}(); - -window.addEventListener('load', addSorting); \ No newline at end of file diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js deleted file mode 100644 index ad0581b..0000000 --- a/dist/gulpfile.babel.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -var _gulp = require('gulp'); - -var _gulp2 = _interopRequireDefault(_gulp); - -var _gulpLoadPlugins = require('gulp-load-plugins'); - -var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); - -var _path = require('path'); - -var _path2 = _interopRequireDefault(_path); - -var _gulpInjectModules = require('gulp-inject-modules'); - -var _gulpInjectModules2 = _interopRequireDefault(_gulpInjectModules); - -var _gulpCoveralls = require('gulp-coveralls'); - -var _gulpCoveralls2 = _interopRequireDefault(_gulpCoveralls); - -var _gulpIstanbul = require('gulp-istanbul'); - -var _gulpIstanbul2 = _interopRequireDefault(_gulpIstanbul); - -var _gulpMocha = require('gulp-mocha'); - -var _gulpMocha2 = _interopRequireDefault(_gulpMocha); - -var _gulpExit = require('gulp-exit'); - -var _gulpExit2 = _interopRequireDefault(_gulpExit); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Load the gulp plugins into the `plugins` variable -var plugins = (0, _gulpLoadPlugins2.default)(); - -_gulp2.default.task('mochaTest', function () { - _gulp2.default.src(['dist/server/test/**/*.js']).pipe((0, _gulpMocha2.default)({ - reporter: 'spec' - })); -}); -// Compile all Babel Javascript into ES5 and place in dist folder -var paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**'] -}; - -// Compile all Babel Javascript into ES5 and put it into the dist dir -_gulp2.default.task('babel', function () { - return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); -}); - -_gulp2.default.task('coverage', function (cb) { - _gulp2.default.src('./dist/controllers/*.js').pipe((0, _gulpIstanbul2.default)()).pipe(_gulpIstanbul2.default.hookRequire()).on('finish', function () { - _gulp2.default.src('dist/sertest/*.js').pipe(plugins.babel()).pipe((0, _gulpInjectModules2.default)()).pipe((0, _gulpMocha2.default)()).pipe(_gulpIstanbul2.default.writeReports()).pipe(_gulpIstanbul2.default.enforceThresholds({ thresholds: { global: 30 } })).on('end', cb).pipe((0, _gulpExit2.default)()); - }); -}); - -_gulp2.default.task('coveralls', function () { - return _gulp2.default.src('./coverage/lcov').pipe((0, _gulpCoveralls2.default)()); -}); - -// Restart server with on every changes made to file -_gulp2.default.task('nodemon', ['babel'], function () { - return plugins.nodemon({ - script: _path2.default.join('dist', 'index.js'), - ignore: ['README.md', 'node_modules/**/*.js', 'dist/**/*.js'], - ext: 'js', - tasks: ['babel'] - }); -}); - -_gulp2.default.task('test', ['mochaTest']); -_gulp2.default.task('default', ['nodemon']); -_gulp2.default.task('production', ['babel']); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 80c5176..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('./server/config/express'); - -var _express2 = _interopRequireDefault(_express); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var port = process.env.PORT || 3000; - -var server = _express2.default.listen(port, function () { - console.log('API Server started and listening on port 3000'); -}); - -exports.default = server; \ No newline at end of file diff --git a/dist/server/config/config.js b/dist/server/config/config.js deleted file mode 100644 index d3ec778..0000000 --- a/dist/server/config/config.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -module.exports = { - development: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-dev', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' - }, - test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' - }, - production: { - username: 'root', - password: null, - database: 'database_production', - host: '127.0.0.1', - dialect: 'postgres' - } -}; \ No newline at end of file diff --git a/dist/server/config/express.js b/dist/server/config/express.js deleted file mode 100644 index 40c9b7c..0000000 --- a/dist/server/config/express.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _bodyParser = require('body-parser'); - -var _bodyParser2 = _interopRequireDefault(_bodyParser); - -var _morgan = require('morgan'); - -var _morgan2 = _interopRequireDefault(_morgan); - -var _expressValidator = require('express-validator'); - -var _expressValidator2 = _interopRequireDefault(_expressValidator); - -var _routes = require('../routes'); - -var _routes2 = _interopRequireDefault(_routes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var app = (0, _express2.default)(); - -app.use((0, _morgan2.default)('dev')); - -app.use(_bodyParser2.default.json()); -app.use(_bodyParser2.default.urlencoded({ extended: false })); -app.use((0, _expressValidator2.default)()); - -app.use(function (req, res, next) { - var send = res.send; - var sent = false; - res.send = function (data) { - if (sent) return; - send.bind(res)(data); - sent = true; - }; - next(); -}); - -// mount all routes on /api path -app.use('/api/v1', _routes2.default); - -exports.default = app; \ No newline at end of file diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js deleted file mode 100644 index 04f90f1..0000000 --- a/dist/server/controllers/documents.js +++ /dev/null @@ -1,241 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var User = _models2.default.User; -var Document = _models2.default.Document; -var metaData = _helper2.default.paginationMetaData; - -/** - * Create documents for users - * @param {object} req - document to be created - * @param {object} res - created document - * @returns {object} - created document - */ -function createDocument(req, res) { - req.check('title', 'Title is required').notEmpty(); - req.check('content', 'Content is required').notEmpty(); - req.check('access', 'accessType is required').notEmpty(); - - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - Document.findAll({ - where: { - title: req.body.title - } - }).then(function (document) { - if (document.length === 0) { - return Document.create({ - title: req.body.title, - content: req.body.content, - access: req.body.value, - userId: req.body.userId - }).then(function (documentResponse) { - return res.status(200).send(documentResponse); - }).catch(function (error) { - return res.status(400).send(error); - }); - } - return res.status(403).json({ - message: 'Document already exists' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Update user document. - * @param {number} req - request id of the document to be updated - * @param {object} res - object of the updated document - * @returns {object} - updated document - */ -function updateDocument(req, res) { - if (isNaN(req.params.id)) { - return res.status(400); - } - var docId = Number(req.params.id); - return Document.findById(docId).then(function (document) { - if (!document) { - return res.status(404).send({ - message: 'Document Not Found' - }); - } - if (Number(document.userId) !== Number(req.decoded.id)) { - return res.status(401).json({ - message: 'You are not authorized to edit this document' - }); - } - return document.update({ - title: req.body.title || document.title, - content: req.body.content || document.content, - access: req.body.value || document.access, - userId: req.body.userId || document.userId - }).then(function () { - return res.status(200).send(document); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Get all documents - * @param {object} req - contains an object of the query, limits and offset - * @param {array} res - array of documents with pagination - * @returns {array} - array of documents - */ -function getAllDocument(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - access: { - $ne: 'private' - } - }, - include: [{ - model: User, - attributes: ['userName', 'roleId'] - }] - }).then(function (_ref) { - var document = _ref.rows, - count = _ref.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - include: [{ - model: User, - attributes: ['userName', 'roleId'], - where: { - roleId: req.decoded.roleId - } - }], - where: { - access: { - $ne: 'private' - } - } - - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Find a document by Id - * @param {number} req - id of the requested document - * @param {object} res - object containg the requested document - * @returns {object} requested document - */ -function findDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - res.status(404).json({ message: 'Document not found' }); - } - if (req.decoded.roleId === 1) { - return document; - } - if (document.access === 'public') { - return res.status(200).send(document); - } - if (document.access === 'private') { - if (document.userId !== req.decoded.id) { - return res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - } - if (document.access === 'role') { - return _models2.default.User.findById(document.userId).then(function (documentOwner) { - if (Number(documentOwner.roleId) !== Number(req.decoded.roleId)) { - return res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - }).catch(function (error) { - return res.status(400).send(error); - }); - } - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Delete a document by Id - * @param {number} req - id of the requested document - * @param {object} res - message - * @returns {object} - message - */ -function deleteDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - return res.status(404).send({ - message: 'Document Not Found' - }); - } - if (req.decoded.roleId !== 1 && Number(document.userId) !== Number(req.decoded.id)) { - return res.status(401).json({ - message: 'You are not authorized to delete this document' - }); - } - return document.destroy().then(function () { - return res.status(204).send({ - message: 'Document successfully deleted' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -exports.default = { - createDocument: createDocument, - updateDocument: updateDocument, - getAllDocument: getAllDocument, - findDocument: findDocument, - deleteDocument: deleteDocument }; \ No newline at end of file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js deleted file mode 100644 index a386967..0000000 --- a/dist/server/controllers/roles.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var models = require('../models'); - -var Role = models.Role; - -/** - * Creates a new Role. - * @param {object} req - role to be created - * @param {object} res - new created role - * @returns {object} - newly created role - */ -function createRole(req, res) { - req.check('title', 'Title is required').notEmpty(); - - var errors = req.validationErrors(); - if (errors) { - res.status(400).json({ errors: errors }); - } else { - Role.findAll({ - where: { title: req.body.title } - }).then(function (err, existingRole) { - if (!existingRole) { - Role.create({ - title: req.body.title - }).then(function (role) { - res.status(201).send({ - message: 'Role successfully created', - role: role - }); - }).catch(function (error) { - res.json(error.errors); - }); - } - }).catch(function (error) { - return res.json(error); - }); - } -} - -/** - * Get all roles. - * @param {void} req - no request body attached - * @param {array} res - an array of roles and their id - * @returns {array} array of roles - */ -function getRoles(req, res) { - return Role.findAll().then(function (role) { - return res.status(200).json(role); - }).catch(function (error) { - return res.json(error); - }); -} - -/** - * Find roles by Id. - * @param {number} req - requested role - * @param {object} res - role found by id - * @returns {object} - role found by id - */ -function findRole(req, res) { - if (isNaN(req.params.id)) { - res.status(401).json({ - message: 'invalid input syntax for integer: "' + req.params.id + '"' - }); - } else { - Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(function () { - return res.status(400).json({ - message: 'out of range for type integer' - }); - }); - } -} - -/** - * Update role. - * @param {number} req - requested role by id - * @param {object} res - updated role - * @returns {object} - updated role status - */ -function updateRole(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized' }); - } - return Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - return role.update({ - title: req.body.title || role.title - }).then(function () { - return res.status(200).json({ - message: 'Role updated successfully', - role: role - }); - }).catch(function (error) { - return res.status(400).json(error); - }); - }).catch(function () { - return res.status(400).json({ - message: 'out of range for type integer' - }); - }); -} - -/** - * Delete roles by Id. - * @param {number} req - role to be deleted by id - * @param {object} res - deleted role - * @returns {object} - message - */ -function deleteRole(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized' }); - } - return Role.findById(req.params.id).then(function (role) { - if (!role) { - res.status(404).json({ - message: 'Role not found' - }); - } - return role.destroy().then(function () { - return res.status(204).send({ - message: 'Role deleted successfully' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function () { - return res.status(400).json({ - message: 'out of range for type integer' - }); - }); -} - -exports.default = { createRole: createRole, getRoles: getRoles, findRole: findRole, updateRole: updateRole, deleteRole: deleteRole }; \ No newline at end of file diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js deleted file mode 100644 index fa9f13b..0000000 --- a/dist/server/controllers/search.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var Document = _models2.default.Document; -var User = _models2.default.User; -var metaData = _helper2.default.paginationMetaData; - -/** - * Search for user using a query string - * @param {string} req - search query of string - * @param {array} res - array of users - * @returns {array} - array users searched - */ -function searchUser(req, res) { - var searchQuery = req.query.q, - limit = req.query.limit, - offset = req.query.offset; - if (!searchQuery) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - return User.findAndCountAll({ - limit: limit, - offset: offset, - attributes: { exclude: ['password'] }, - where: { - userName: { - $like: '%' + searchQuery + '%' - } - } - }).then(function (_ref) { - var user = _ref.rows, - count = _ref.count; - - if (count === 0) { - return res.status(404).json({ message: 'User not found' }); - } - res.status(200).send({ - user: user, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * - * Search for documents by title - * @param {string} req - an object containing the query, offset and limit - * @param {array} res - an array containing searched document - * @returns {array} - searched document - */ -function searchDocuments(req, res) { - var limit = req.query.limit, - offset = req.query.offset, - queryString = req.query.q; - if (!queryString) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - }, - include: [{ - model: User, - attributes: ['userName', 'roleId'] - }] - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - if (count === 0) { - return res.status(404).json({ - message: 'Document not found' - }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - include: [{ - model: User, - attributes: ['userName', 'roleId'], - where: { - roleId: req.decoded.roleId - } - }], - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - } - - }).then(function (_ref3) { - var document = _ref3.rows, - count = _ref3.count; - - if (count === 0) { - return res.status(404).json({ - message: 'Document not found' - }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js deleted file mode 100644 index c935cf8..0000000 --- a/dist/server/controllers/users.js +++ /dev/null @@ -1,302 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _bcrypt = require('bcrypt'); - -var _bcrypt2 = _interopRequireDefault(_bcrypt); - -var _jsonwebtoken = require('jsonwebtoken'); - -var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -require('dotenv').config(); - -var jwtSecret = process.env.JWT_SECRET; -var Document = _models2.default.Document; -var User = _models2.default.User; -var metaData = _helper2.default.paginationMetaData; - -/** - * Get all users - * @param {number} req - limit and offset for getting all user - * @param {array} res - array of users or error - * @returns {array} - an array of users - */ -function getUsers(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - return User.findAndCountAll({ limit: limit, - offset: offset, - attributes: { exclude: ['password'] } - }).then(function (_ref) { - var user = _ref.rows, - count = _ref.count; - - res.status(200).send({ - user: user, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Create a user - * @param {object} req - request from user - * @param {object} res - newly created user or error - * @returns {object} - an object of a created user - */ -function createUser(req, res) { - req.check('fullName', 'FullName is required').notEmpty(); - req.check('userName', 'userName is required').notEmpty(); - req.check('email', 'Email is required').notEmpty(); - req.check('email', 'Please put a valid email').isEmail(); - req.check('password', 'Password is required').notEmpty(); - req.check('password', 'Password must be a mininum of 4 character').isLength(4, 50); - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - User.findAll({ - where: { email: req.body.email } - }).then(function (err, user) { - if (!user) { - User.create({ - fullName: req.body.fullName, - userName: req.body.userName, - email: req.body.email, - password: _bcrypt2.default.hashSync(req.body.password, _bcrypt2.default.genSaltSync(10)), - roleId: req.body.roleId || 2 - }).then(function (userDetails) { - res.status(200).json({ - userDetails: userDetails, - success: true, - message: 'You have successfully registered.' - }); - }).catch(function (error) { - res.status(400).json(error); - }); - } - }); - } -} - -/** - * Log In user with JWT - * @param {object} req - request from log in user - * @param {object} res - authenicated user details - * @returns {object} - an object of the logged in user and a token - */ -function login(req, res) { - req.check('email', 'Email is required').notEmpty(); - req.check('email', 'Please put a valid email').isEmail(); - req.check('password', 'Password is required').notEmpty(); - - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - User.findAll({ - where: { email: req.body.email } - }).then(function (user) { - var existingUser = user[0]; - if (!existingUser) { - res.status(400).json({ - success: false, - message: 'Authentication failed. User not found.' }); - } else if (existingUser) { - if (_bcrypt2.default.compareSync(req.body.password, existingUser.password)) { - var payLoad = { - email: existingUser.email, - id: existingUser.id, - fullName: existingUser.fullName, - roleId: existingUser.roleId - }; - var token = _jsonwebtoken2.default.sign(payLoad, jwtSecret, { - expiresIn: 60 * 60 * 24 - }); - res.status(201).json({ - success: true, - token: token - }); - } else { - res.status(401).json({ - success: false, - message: 'Authentication failed. Wrong password.' - }); - } - } - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Find a user by Id - * @param {number} req - request for user using the id of the user - * @param {object} res - an object of the user(s) found or error - * @returns {object} - an object of found user - */ -function findUser(req, res) { - var userQuery = Number(req.params.id); - if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { - return res.status(401).json({ - message: 'Unauthorized Access' - }); - } - if (isNaN(userQuery)) { - return res.status(401).json({ - message: 'invalid input syntax for integer: "' + req.params.id + '"' - }); - } - return User.findAll({ - where: { - id: req.params.id - }, - attributes: { exclude: ['password'] } - }).then(function (user) { - if (!user.length) { - res.status(404).json({ message: 'User not found' }); - } - res.status(200).send(user); - }).catch(function () { - return res.status(400).send({ - message: 'out of range' - }); - }); -} - -/** - *Update a user by Id - * @param {object} req - updated user object - * @param {object} res - updated user object or error - * @returns {object} - return an object of the updated user - */ -function updateUser(req, res) { - if (Number(req.decoded.id) !== Number(req.params.id)) { - return res.status(401).json({ - message: 'You are not authorized to access this user' - }); - } - var userId = Number(req.params.id); - _bcrypt2.default.genSalt(10, function (err, salt) { - _bcrypt2.default.hash(req.body.password, salt, function (err, hash) { - User.findById(userId).then(function (user) { - if (!user) { - return res.status(404).json({ message: 'User not found' }); - } - return user.update({ - fullName: req.body.fullName || user.fullName, - userName: req.body.userName || user.userName, - email: req.body.email || user.email, - password: hash || user.password, - roleId: req.body.roleId || user.roleId - }).then(function (updatedUser) { - res.status(200).send({ - id: updatedUser.id, - fullName: updatedUser.fullName, - userName: updatedUser.userName, - email: updatedUser.email, - roleId: updatedUser.roleId, - message: 'Details successfully updated.' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }); - }); -} - -/** - * Delete a user by Id - * @param {number} req - delete user with an id - * @param {object} res - message - * @returns {object} - null - */ -function deleteUser(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ - message: 'You are not authorized to access this field' - }); - } - return User.findById(req.params.id).then(function (user) { - if (!user) { - return res.status(404).json({ message: 'User not found' }); - } - return user.destroy().then(function () { - return res.status(204).json({ - message: 'User has been deleted successfully' }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Get documents for specific user - * @param {object} req - request object containing limit query and offset - * @param {array} res - array of documents for the requested user - * @return {array} - array of requested user's document - */ -function getUserDocuments(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - User.findById(req.params.id).then(function (user) { - if (!user) { - return res.status(404).json({ - message: 'User not found' - }); - } - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - userId: user.id - } - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -exports.default = { - getUsers: getUsers, - createUser: createUser, - login: login, - findUser: findUser, - updateUser: updateUser, - deleteUser: deleteUser, - getUserDocuments: getUserDocuments -}; \ No newline at end of file diff --git a/dist/server/helpers/helper.js b/dist/server/helpers/helper.js deleted file mode 100644 index 9669f87..0000000 --- a/dist/server/helpers/helper.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -var paginationMetaData = function paginationMetaData(count, limit, offset) { - return { - totalCount: count, - pageCount: Math.ceil(count / limit), - page: Math.floor(offset / limit) + 1, - pageSize: limit - }; -}; - -module.exports.paginationMetaData = paginationMetaData; \ No newline at end of file diff --git a/dist/server/middlewares/auth.js b/dist/server/middlewares/auth.js deleted file mode 100644 index 7e0eb35..0000000 --- a/dist/server/middlewares/auth.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _jsonwebtoken = require('jsonwebtoken'); - -var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var jwtSecret = process.env.JWT_SECRET; - -function verifyToken(req, res, next) { - var token = req.headers.authorization || req.headers['x-access-token']; - if (token) { - _jsonwebtoken2.default.verify(token, jwtSecret, function (err, decoded) { - if (err) { - res.json({ success: false, message: 'Failed to authenticate token.' }); - } else { - req.decoded = decoded; - next(); - } - }); - } else { - return res.status(403).send({ - success: false, - message: 'No token provided.' - }); - } -} - -function adminAccess(req, res, next) { - if (req.decoded.roleId === 1) { - next(); - } else { - return res.status(401).json({ - message: 'You are not authorized' - }); - } -} - -exports.default = { verifyToken: verifyToken, adminAccess: adminAccess }; \ No newline at end of file diff --git a/dist/server/migrations/20170709115213-create-role.js b/dist/server/migrations/20170709115213-create-role.js deleted file mode 100644 index faafbd0..0000000 --- a/dist/server/migrations/20170709115213-create-role.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Roles', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Roles'); - } -}; \ No newline at end of file diff --git a/dist/server/migrations/20170709115254-create-user.js b/dist/server/migrations/20170709115254-create-user.js deleted file mode 100644 index 51491fa..0000000 --- a/dist/server/migrations/20170709115254-create-user.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Users', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - fullName: { - type: Sequelize.STRING, - allowNull: false - }, - userName: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - email: { - type: Sequelize.STRING, - allowNull: false, - unique: true, - validate: { isEmail: true } - }, - password: { - type: Sequelize.STRING, - allowNull: false - }, - roleId: { - type: Sequelize.INTEGER, - references: { - model: 'Roles', - key: 'id', - as: 'roleId' - }, - allowNull: false, - defaultValue: 2 - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Users'); - } -}; \ No newline at end of file diff --git a/dist/server/migrations/20170709120158-create-document.js b/dist/server/migrations/20170709120158-create-document.js deleted file mode 100644 index 9c83e45..0000000 --- a/dist/server/migrations/20170709120158-create-document.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Documents', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false - }, - content: { - type: Sequelize.STRING, - allowNull: false - }, - access: { - type: Sequelize.ENUM('public', 'private', 'role'), - defaultValue: 'public', - allowNull: false - }, - userId: { - type: Sequelize.INTEGER, - references: { - model: 'Users', - key: 'id', - as: 'userId' - } - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Documents'); - } -}; \ No newline at end of file diff --git a/dist/server/models/document.js b/dist/server/models/document.js deleted file mode 100644 index d204122..0000000 --- a/dist/server/models/document.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var Document = sequelize.define('Document', { - title: { - type: DataTypes.STRING, - allowNull: false - }, - content: { - type: DataTypes.TEXT, - allowNull: false - }, - userId: { - type: DataTypes.INTEGER, - unique: true, - allowNull: false - }, - access: { - type: DataTypes.ENUM, - values: ['public', 'private', 'role'] - } - }); - Document.associate = function (models) { - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - }; - return Document; -}; \ No newline at end of file diff --git a/dist/server/models/index.js b/dist/server/models/index.js deleted file mode 100644 index d5e98bf..0000000 --- a/dist/server/models/index.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var path = require('path'); -var Sequelize = require('sequelize'); - -var basename = path.basename(module.filename); -var env = process.env.NODE_ENV || 'development'; -var config = require('../config/config.js')[env]; - -var db = {}; - -var sequelize = void 0; -if (config.use_env_variable) { - sequelize = new Sequelize(process.env[config.use_env_variable]); -} else { - sequelize = new Sequelize(config.database, config.username, config.password, config); -} - -fs.readdirSync(__dirname).filter(function (file) { - return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'; -}).forEach(function (file) { - var model = sequelize.import(path.join(__dirname, file)); - db[model.name] = model; -}); - -Object.keys(db).forEach(function (modelName) { - if (db[modelName].associate) { - db[modelName].associate(db); - } -}); - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; \ No newline at end of file diff --git a/dist/server/models/role.js b/dist/server/models/role.js deleted file mode 100644 index 4979353..0000000 --- a/dist/server/models/role.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var Role = sequelize.define('Role', { - title: { - type: DataTypes.STRING, - allowNull: false, - unique: true - } - }); - Role.associate = function (models) { - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - }; - return Role; -}; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js deleted file mode 100644 index def997e..0000000 --- a/dist/server/models/user.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var User = sequelize.define('User', { - fullName: { - type: DataTypes.STRING, - allowNull: false - }, - userName: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - email: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - password: { - type: DataTypes.STRING, - allowNull: false - }, - roleId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultvalue: 2 - } - }); - User.associate = function (models) { - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - }; - return User; -}; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js deleted file mode 100644 index f57376c..0000000 --- a/dist/server/routes/documents.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _documents = require('../controllers/documents'); - -var _documents2 = _interopRequireDefault(_documents); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/v1/documents - Get all documents */ -.get(_auth2.default.verifyToken, _documents2.default.getAllDocument) - -/** POST /api/v1/documents - Create document */ -.post(_auth2.default.verifyToken, _documents2.default.createDocument); - -router.route('/:id') -/** PUT /api/v1/documents/id - Create document */ -.put(_auth2.default.verifyToken, _documents2.default.updateDocument) - -/** GET /api/v1/documents/id - get document */ -.get(_auth2.default.verifyToken, _documents2.default.findDocument) - -/** DELETE /api/v1/documents/id - delete document */ -.delete(_auth2.default.verifyToken, _documents2.default.deleteDocument); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js deleted file mode 100644 index 1f4a3ec..0000000 --- a/dist/server/routes/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _users = require('./users'); - -var _users2 = _interopRequireDefault(_users); - -var _search = require('./search'); - -var _search2 = _interopRequireDefault(_search); - -var _documents = require('./documents'); - -var _documents2 = _interopRequireDefault(_documents); - -var _roles = require('./roles'); - -var _roles2 = _interopRequireDefault(_roles); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -/** GET /api-status - Check service status **/ -router.use('/users', _users2.default); -router.use('/search', _search2.default); -router.use('/documents', _documents2.default); -router.use('/roles', _roles2.default); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/roles.js b/dist/server/routes/roles.js deleted file mode 100644 index 63ea87b..0000000 --- a/dist/server/routes/roles.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _roles = require('../controllers/roles'); - -var _roles2 = _interopRequireDefault(_roles); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/roles - Get list of roles */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.getRoles) - -/** POST /api/roles - Create roles */ -.post(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.createRole); - -router.route('/:id') -/** GET /api/users/roles - Find roles */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.findRole) - -/** PUT /api/users/id - update roles */ -.put(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.updateRole) - -/** DELETE /api/users/id - delete roles */ -.delete(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.deleteRole); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js deleted file mode 100644 index ea6c0e2..0000000 --- a/dist/server/routes/search.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _search = require('../controllers/search'); - -var _search2 = _interopRequireDefault(_search); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/users') -/** GET /api/v1/users - search list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); - -router.route('/documents') -/** GET /api/v1/search - search list of documents */ -.get(_auth2.default.verifyToken, _search2.default.searchDocuments); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js deleted file mode 100644 index 4eb365a..0000000 --- a/dist/server/routes/users.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _users = require('../controllers/users'); - -var _users2 = _interopRequireDefault(_users); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/users - Get list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _users2.default.getUsers) - -/** POST /api/users - Create/Signup users */ -.post(_users2.default.createUser); - -router.route('/login') -/** POST /api/users/login - Login users */ -.post(_users2.default.login); - -router.route('/:id') -/** GET /api/users/id - Find users */ -.get(_auth2.default.verifyToken, _users2.default.findUser) - -/** PUT /api/users/id - update users */ -.put(_auth2.default.verifyToken, _users2.default.updateUser) - -/** DELETE /api/users/id - delete users */ -.delete(_auth2.default.verifyToken, _users2.default.deleteUser); - -router.route('/:id/documents') -/** GET /api/users/id/documents - Find documents of a specific user*/ -.get(_auth2.default.verifyToken, _users2.default.getUserDocuments); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/seeders/20170727152600-sample-roles.js b/dist/server/seeders/20170727152600-sample-roles.js deleted file mode 100644 index 790d10f..0000000 --- a/dist/server/seeders/20170727152600-sample-roles.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface) { - return queryInterface.bulkInsert('Roles', [{ - title: 'admin', - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'facilitator', - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'fellow', - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface) { - return queryInterface.bulkDelete('Roles', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153559-sample-users.js b/dist/server/seeders/20170727153559-sample-users.js deleted file mode 100644 index 6c8bde8..0000000 --- a/dist/server/seeders/20170727153559-sample-users.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var bcrypt = require('bcrypt'); -require('dotenv').config(); - -module.exports = { - up: function up(queryInterface) { - return queryInterface.bulkInsert('Users', [{ - userName: 'bank', - fullName: 'Baas Bank', - email: 'baas@test.com', - password: bcrypt.hashSync(process.env.TEST_ADMIN_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, { - userName: 'john', - fullName: 'John Bosco', - email: 'john@test.com', - password: bcrypt.hashSync(process.env.TEST_FELLOW_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - userName: 'blessing', - fullName: 'Blessing Philip', - email: 'blessing@test.com', - password: bcrypt.hashSync(process.env.TEST_FACILITATOR_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 3, - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface) { - return queryInterface.bulkDelete('Users', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153641-sample-documents.js b/dist/server/seeders/20170727153641-sample-documents.js deleted file mode 100644 index caf5e98..0000000 --- a/dist/server/seeders/20170727153641-sample-documents.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.bulkInsert('Documents', [{ - title: 'John Doe', - content: 'eze goes to school', - access: 'public', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'John naddddd', - content: 'John watches american gods regularly', - access: 'private', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'James Hannn', - content: 'Han is a bad guy', - access: 'role', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface, Sequelize) { - return queryInterface.bulkDelete('Documents', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/test/controllers/document.spec.js b/dist/server/test/controllers/document.spec.js deleted file mode 100644 index 4654b83..0000000 --- a/dist/server/test/controllers/document.spec.js +++ /dev/null @@ -1,325 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Documents', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST Document', function () { - it('should add a new document if the user is authenticated', function (done) { - var document = { - title: 'hey yo!', - content: 'Andela is really fun!!', - access: 'public', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('hey yo!'); - expect(res.body.content).to.eql('Andela is really fun!!'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - - it('Should fail if document already exist', function () { - var document = { - title: 'John team', - content: 'eze goes to school', - access: 'public' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body.message).to.eql('Document already exists'); - }); - }); - it('should fail to add a new document if the user is not authenticated', function (done) { - var document = { - title: 'boromir-team', - content: 'Andela is really awesome !!!', - value: 'private', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - it('should fail to add a new document if the access field is missing', function (done) { - var document = { - title: 'boromir-team', - content: 'Andela is really awesome!!!', - access: '', - userId: 1 - }; - _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.errors[0].msg).to.be.equal('accessType is required'); - done(); - }); - }); - it('should fail to add a new document if the title field is missing', function (done) { - var document = { - title: '', - content: 'Andela is really awesome!!!', - value: 'public', - userId: 2 - }; - _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.errors[0].msg).to.be.equal('Title is required'); - done(); - }); - }); - it('should fail to add a new document if the content field is missing', function (done) { - var document = { - title: 'boromir-team', - content: '', - value: 'public', - userId: 2 - }; - _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.errors[0].msg).to.be.equal('Content is required'); - done(); - }); - }); - }); - - describe('/GET Documents', function () { - it('Should get all documents for the user that is authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['document', 'pagination']); - done(); - }); - }); - it('should fail to get all documents if the user is not authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).be.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get all documents with correct limit as a query', function (done) { - var limit = 1; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + limit).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - it('Should get all documents with correct offset as a query', function (done) { - var offset = 0; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + offset).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - }); - - describe('/GET/:id Document', function () { - it('Should fail to get document if it doesn`t exist', function (done) { - var documentId = 8; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); - done(); - }); - }); - it('Should get all public regardless of id', function (done) { - var documentId = 4; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('hey yo!'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - it('Should fail to get a private document if the requester does not own it', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a private document the where the requester is the owner', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.access).to.eql('private'); - expect(res.body.title).to.eql('John naddddd'); - expect(res.body.id).to.eql(2); - expect(res.body.userId).to.eql(2); - done(); - }); - }); - it('Should fail get a role document if the users are not on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a role document if the users are on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - done(); - }); - }); - it('Should get a role document if the user is an admin', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - }); - done(); - }); - }); - - describe('/PUT/:id, Document', function () { - it('Should update a document by id if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'wreck it ralph' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.title).to.eql('wreck it ralph'); - done(); - }); - }); - it('Should fail to update a document by\n id if the user does not have the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).send({ title: 'spiderman Homecoming' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to edit this document'); - done(); - }); - }); - it('Should not update a document by id if the user has admin access', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: adminToken }).send({ title: 'wreck it' }).end(function (err, res) { - expect(res.status).to.equal(401); - done(); - }); - }); - it('Should fail to update a document by id if the document does not exist', function (done) { - var id = 10; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'Deadpool' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document Not Found'); - done(); - }); - }); - }); - - describe('DELETE/:id Document', function () { - it('Should delete a document if the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should delete a document if the user is the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete the document given the user is not the owner', function (done) { - var id = 1; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to delete this document'); - done(); - }); - }); - it('Should fail to delete if the document does not exist', function (done) { - var id = 234; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document Not Found'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/mockData.js b/dist/server/test/controllers/mockData.js deleted file mode 100644 index 34d40d9..0000000 --- a/dist/server/test/controllers/mockData.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _dotenv = require('dotenv'); - -var _dotenv2 = _interopRequireDefault(_dotenv); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_dotenv2.default.config(); - -exports.default = { - admin: { - email: 'baas@test.com', - password: process.env.TEST_ADMIN_PASSWORD - }, - fellow: { - email: 'john@test.com', - password: process.env.TEST_FELLOW_PASSWORD - }, - faciliatator: { - email: 'blessing@test.com', - password: process.env.TEST_FACILITATOR_PASSWORD - }, - user2: { - email: 'baas@test.com', - password: 'test' - }, - user1: { - email: 'test@test123.com', - password: 'test' - }, - fakeBass: { - fullName: 'Baasbank Adams', - userName: 'tiaandela', - email: 'name@example.com', - password: 'pass123', - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, - Baas: { - fullName: 'Baas Bank', - userName: 'bank', - email: 'baas@test.com', - password: 'pass123', - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, - fakeUserDetails: { - fullName: 'Daniel Cfh', - userName: 'cfh', - email: 'cfh@example.com', - password: 'pass123', - roleId: 2, - createdAt: 'date', - updatedAt: new Date() - } -}; \ No newline at end of file diff --git a/dist/server/test/controllers/role.spec.js b/dist/server/test/controllers/role.spec.js deleted file mode 100644 index 53a0fd7..0000000 --- a/dist/server/test/controllers/role.spec.js +++ /dev/null @@ -1,230 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Roles', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST Role', function () { - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'boromir' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - expect(res.body.role).to.have.property('title').to.equal('boromir'); - }); - done(); - }); - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'king' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - }); - done(); - }); - it('Should fail if a non-admin wants to add a new role', function (done) { - var role = { - title: 'boromir-team' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/roles/').set({ authorization: userToken }).send(role).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - }); - - describe('/GET Role', function () { - it('Should get all the roles if the user is an admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.length(5); - expect(res.body).to.be.a('array'); - expect(res.body[0].id).to.eql(1); - expect(res.body[0].title).to.eql('admin'); - expect(res.body[1].id).to.eql(2); - expect(res.body[1].title).to.eql('facilitator'); - done(); - }); - }); - it('Should fail to get the roles if the user is not admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - }); - - describe('/GET/:id Role', function () { - it('Should get a role by id if the user is an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.title).to.eql('facilitator'); - expect(res.body.id).to.equal(2); - done(); - }); - }); - it('Should fail to get a role by id if the user is not an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get a role by id if the user enters an invalid input', function (done) { - var id = 'fddjsdcdjn'; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('Should fail to get a role by id if the role does not exist', function (done) { - var id = 250; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body.message).to.eql('Role not found'); - done(); - }); - }); - it('Should fail to get a role by id if the id is out of range', function (done) { - var id = 500000000000000000000; - (0, _supertest2.default)(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('out of range for type integer'); - done(); - }); - }); - }); - describe('/PUT/:id Role', function () { - it('Should update a role by id if the user has admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'boromir-team' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role updated successfully'); - expect(res.body).to.have.property('role'); - done(); - }); - }); - it('Should fail to update a role by id if the user has no admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: userToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to update a\n role by id if the admin enters an invalid input', function (done) { - var id = 200; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it('Should fail to update a role by id if the\n admin enters an id that is out range', function (done) { - var id = 2000000000000000; - (0, _supertest2.default)(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'regular' }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('out of range for type integer'); - done(); - }); - }); - }); - describe('/DELETE/:id Role', function () { - it('Should delete a role given the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.be.eql('Role deleted successfully'); - }); - done(); - }); - it('Should fail to delete a role given the user has no admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to delete a role\n given the admin enters an id that is not found', function (done) { - var id = 300; - (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - it('Should fail to delete a role given the admin\n enters an input that is out of range', function (done) { - var id = 3000000000000000; - (0, _supertest2.default)(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('out of range for type integer'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/search.spec.js b/dist/server/test/controllers/search.spec.js deleted file mode 100644 index 23970d1..0000000 --- a/dist/server/test/controllers/search.spec.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow, - Baas = _mockData2.default.Baas; - - -describe('Search', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/SEARCH/users/?q={name}', function () { - it('Should return an error if no querystring is provided', function (done) { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - done(); - }); - }); - it('Should return a search list response of the required search input', function (done) { - var query = Baas.userName; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body.user[0].fullName).to.eql(Baas.fullName); - expect(res.body.user[0].userName).to.equal(Baas.userName); - done(); - }); - }); - }); - describe('/SEARCH/documents/?q=', function () { - it('Should return an error if no querystring is provided', function (done) { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - done(); - }); - }); - it('Should return a search list of the required search input', function (done) { - var query = 'John'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body.document[0].title).to.equal('John Doe'); - expect(res.body.document[0].content).to.equal('eze goes to school'); - expect(res.body).to.have.property('pagination'); - done(); - }); - }); - it('Should throw an error if the searched document is not found', function (done) { - var query = 'jk'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body.message).to.equal('Document not found'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/user.spec.js b/dist/server/test/controllers/user.spec.js deleted file mode 100644 index f3eabb8..0000000 --- a/dist/server/test/controllers/user.spec.js +++ /dev/null @@ -1,306 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fakeBass = _mockData2.default.fakeBass, - fellow = _mockData2.default.fellow, - user1 = _mockData2.default.user1, - user2 = _mockData2.default.user2; - - -describe('Users', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST User login', function () { - it('Should fail if the user enters incorrect crendentials upon login', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user1).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. User not found.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('Should fail if the user provide a wrong password', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user2).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. Wrong password.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('should log in a user and return a token', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.have.keys(['success', 'token']); - expect(res.body.success).to.eql(true); - done(); - }); - }); - - describe('/POST User Signup', function () { - it('should create a new user', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/').send(fakeBass).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.keys(['message', 'success', 'userDetails']); - expect(res.body.success).to.eql(true); - expect(res.body.message).to.eql('You have successfully registered.'); - done(); - }); - }); - }); - - describe('#GET Users', function () { - it('Should get all users if the user is an admin ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['user', 'pagination']); - done(); - }); - }); - it('Should fail to get all users if the user has no admin access ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get all users if no token was provided', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - it('Should get all users with correct limit as a query', function (done) { - var limit = 1; - _chai2.default.request(_index2.default).get('/api/v1/users?limit=' + limit).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.user[0].fullName).to.equal('Baas Bank'); - expect(res.body.user[0].userName).to.equal('bank'); - done(); - }); - }); - }); - describe('#GET User by Id', function () { - it('Should get a user if the user is an admin', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).to.eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should get the user if the requested user is the current user', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should fail to get a user if an invalid input is entered', function (done) { - var id = 'fddjsdcdjn'; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.property('message').to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('should fail to get the user if the requester is not the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('api/users/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message']); - expect(res.body.message).to.eql('Unauthorized access'); - }); - done(); - }); - it('Should fail to get a user if the user does not exist', function (done) { - var id = 250; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.have.property('message'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get a user if the id is out of range', function (done) { - var id = 500000000000000000; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('out of range'); - done(); - }); - }); - }); - describe('#PUT Update user by Id', function () { - it('Should update a user`s full name if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ fullName: 'jake doe' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.fullName).to.eql('jake doe'); - done(); - }); - }); - it('Should update a user`s email if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.email).to.eql('jakedoe@andela.com'); - done(); - }); - }); - it('Should update a user`s username if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ userName: 'jakedoe12' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.userName).to.eql('jakedoe12'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user does not have the same user id', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user enters an invalid user id', function (done) { - var id = 2302; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - }); - describe('#DELETE /:id Users', function () { - it('Should delete a user given the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete a user if the user has no admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized to access this field'); - done(); - }); - }); - it('Should give a User not found if user don\'t exist', function (done) { - var id = 23; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - }); - describe('/GET/users/:id/documents Documents', function () { - it('Should fail to get documents if the user does not exist', function (done) { - var userId = 9; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get documents if there is no token present', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get documents for the user with its unique userId', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('hey yo!'); - expect(res.body.document[1].content).to.eql('Andela is really fun!!'); - done(); - }); - }); - }); - }); -}); \ No newline at end of file diff --git a/server/config/config.js b/server/config/config.js index 5edaa1c..c0da612 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -1,3 +1,5 @@ +require('dotenv').config(); + module.exports = { development: { username: 'andeladeveloper', @@ -8,12 +10,7 @@ module.exports = { dialect: 'postgres' }, test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' + use_env_variable: 'TEST_DB' }, production: { username: 'root', diff --git a/server/controllers/roles.js b/server/controllers/roles.js index c8a8158..5946210 100644 --- a/server/controllers/roles.js +++ b/server/controllers/roles.js @@ -121,7 +121,7 @@ function deleteRole(req, res) { return Role.findById(req.params.id) .then((role) => { if (!role) { - res.status(404).json({ + return res.status(404).json({ message: 'Role not found' }); } @@ -130,7 +130,7 @@ function deleteRole(req, res) { .then(() => res.status(204).send({ message: 'Role deleted successfully' })) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }).catch(() => res.status(400).json({ message: 'out of range for type integer' })); diff --git a/server/test/controllers/document.spec.js b/server/test/controllers/document.spec.js index 422caa9..4810302 100644 --- a/server/test/controllers/document.spec.js +++ b/server/test/controllers/document.spec.js @@ -16,19 +16,13 @@ describe('Documents', () => { .send(admin) .end((err, res) => { adminToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send(fellow) .end((err, res) => { userToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send({ email: 'blessing@test.com', password: 'pass123' }) @@ -101,7 +95,7 @@ describe('Documents', () => { access: '', userId: 1, }; - chai.request(server) + request(server) .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -120,7 +114,7 @@ describe('Documents', () => { value: 'public', userId: 2, }; - chai.request(server) + request(server) .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -139,7 +133,7 @@ describe('Documents', () => { value: 'public', userId: 2, }; - chai.request(server) + request(server) .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -387,7 +381,7 @@ describe('Documents', () => { it('Should fail to delete the document given the user is not the owner', (done) => { const id = 1; - chai.request(server) + request(server) .delete(`/api/v1/documents/${id}`) .set({ authorization: sampleUserToken }) .end((err, res) => { @@ -400,7 +394,7 @@ describe('Documents', () => { }); it('Should fail to delete if the document does not exist', (done) => { const id = 234; - chai.request(server) + request(server) .delete(`/api/v1/documents/${id}`) .set({ authorization: userToken }) .end((err, res) => { diff --git a/server/test/controllers/role.spec.js b/server/test/controllers/role.spec.js index d24b448..fa4ecdb 100644 --- a/server/test/controllers/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -6,7 +6,7 @@ import data from './mockData'; const expect = chai.expect; chai.use(http); -let userToken, adminToken, sampleUserToken; +let userToken, adminToken; const { admin, fellow } = data; describe('Roles', () => { @@ -16,10 +16,7 @@ describe('Roles', () => { .send(admin) .end((err, res) => { adminToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send(fellow) @@ -28,15 +25,6 @@ describe('Roles', () => { done(); }); }); - before((done) => { - request(server) - .post('/api/v1/users/login') - .send({ email: 'blessing@test.com', password: 'pass123' }) - .end((err, res) => { - sampleUserToken = res.body.token; - done(); - }); - }); describe('/POST Role', () => { it('should add a new role if the user is an admin', (done) => { @@ -195,7 +183,7 @@ describe('Roles', () => { chai.request(server) .put(`/api/v1/roles/${id}`) .set({ authorization: userToken }) - .send({ title: 'kiba' }) + .send({ title: 'boromir' }) .end((err, res) => { expect(res.status).to.equal(401); expect(res.body).to.be.a('object'); @@ -214,7 +202,7 @@ describe('Roles', () => { .end((err, res) => { expect(res.status).to.equal(404); expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); + expect(res.body.message).to.eql('Role not found'); done(); }); }); @@ -234,21 +222,9 @@ describe('Roles', () => { }); }); describe('/DELETE/:id Role', () => { - it('Should delete a role given the user has admin access', (done) => { - const id = 3; - request(server) - .delete(`/api/v1/roles/${id}`) - .set({ authorization: adminToken }) - .end((err, res) => { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.be.eql('Role deleted successfully'); - }); - done(); - }); it('Should fail to delete a role given the user has no admin access', (done) => { - const id = 3; + const id = 2; request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: userToken }) @@ -259,19 +235,17 @@ describe('Roles', () => { done(); }); }); - it(`Should fail to delete a role - given the admin enters an id that is not found`, - (done) => { - const id = 300; + it('Should delete a role given the user has admin access', (done) => { + const id = 3; request(server) .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { - expect(res.status).to.equal(404); + expect(res.status).to.equal(204); expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); + expect(res.body.message).to.be.eql('Role deleted successfully'); }); + done(); }); it(`Should fail to delete a role given the admin enters an input that is out of range`, (done) => { @@ -282,7 +256,21 @@ describe('Roles', () => { .end((err, res) => { expect(res.status).to.equal(400); expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('out of range for type integer'); + expect(res.body.message).to.eql('out of range for type integer'); + done(); + }); + }); + it(`Should fail to delete a role + given the admin enters an id that is not found`, + (done) => { + const id = -3; + request(server) + .delete(`/api/v1/roles/${id}`) + .set({ authorization: adminToken }) + .end((err, res) => { + expect(res.status).to.equal(404); + expect(res.body).to.be.a('object'); + expect(res.body.message).to.eql('Role not found'); done(); }); }); diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index a502c07..740d4a1 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -7,7 +7,7 @@ import data from './mockData'; const expect = chai.expect; chai.use(http); -let userToken, adminToken, sampleUserToken; +let userToken, adminToken; const { admin, fellow, Baas } = data; describe('Search', () => { @@ -17,10 +17,7 @@ describe('Search', () => { .send(admin) .end((err, res) => { adminToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send(fellow) @@ -29,15 +26,6 @@ describe('Search', () => { done(); }); }); - before((done) => { - request(server) - .post('/api/v1/users/login') - .send({ email: 'blessing@test.com', password: 'pass123' }) - .end((err, res) => { - sampleUserToken = res.body.token; - done(); - }); - }); describe('/SEARCH/users/?q={name}', () => { it('Should return an error if no querystring is provided', (done) => { diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index 3547f8a..1fb064b 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -16,19 +16,13 @@ describe('Users', () => { .send(admin) .end((err, res) => { adminToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send(fellow) .end((err, res) => { userToken = res.body.token; - done(); }); - }); - before((done) => { request(server) .post('/api/v1/users/login') .send({ email: 'blessing@test.com', password: 'pass123' }) From aa3df81c4775e632d30798239968e0842920de1a Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:22:37 +0100 Subject: [PATCH 44/98] remove coverage --- coverage/base.css | 212 --- coverage/document-manager/index.html | 93 -- coverage/document-manager/index.js.html | 92 -- .../server/config/config.js.html | 146 -- .../server/config/express.js.html | 155 -- .../document-manager/server/config/index.html | 106 -- .../server/controllers/documents.js.html | 743 ---------- .../server/controllers/index.html | 132 -- .../server/controllers/roles.js.html | 482 ------ .../server/controllers/search.js.html | 452 ------ .../server/controllers/users.js.html | 920 ------------ .../server/helpers/helper.js.html | 89 -- .../server/helpers/index.html | 93 -- .../server/middlewares/auth.js.html | 170 --- .../server/middlewares/index.html | 93 -- .../server/models/document.js.html | 149 -- .../document-manager/server/models/index.html | 132 -- .../server/models/index.js.html | 200 --- .../server/models/role.js.html | 113 -- .../server/models/user.js.html | 182 --- .../server/routes/documents.js.html | 137 -- .../document-manager/server/routes/index.html | 145 -- .../server/routes/index.js.html | 113 -- .../server/routes/roles.js.html | 137 -- .../server/routes/search.js.html | 110 -- .../server/routes/users.js.html | 161 -- .../test/controllers/document.spec.js.html | 1307 ----------------- .../server/test/controllers/index.html | 145 -- .../server/test/controllers/mockData.js.html | 224 --- .../server/test/controllers/role.spec.js.html | 935 ------------ .../test/controllers/search.spec.js.html | 383 ----- .../server/test/controllers/user.spec.js.html | 1232 ---------------- coverage/index.html | 171 --- coverage/prettify.css | 1 - coverage/prettify.js | 1 - coverage/sort-arrow-sprite.png | Bin 209 -> 0 bytes coverage/sorter.js | 158 -- 37 files changed, 10114 deletions(-) delete mode 100644 coverage/base.css delete mode 100644 coverage/document-manager/index.html delete mode 100644 coverage/document-manager/index.js.html delete mode 100644 coverage/document-manager/server/config/config.js.html delete mode 100644 coverage/document-manager/server/config/express.js.html delete mode 100644 coverage/document-manager/server/config/index.html delete mode 100644 coverage/document-manager/server/controllers/documents.js.html delete mode 100644 coverage/document-manager/server/controllers/index.html delete mode 100644 coverage/document-manager/server/controllers/roles.js.html delete mode 100644 coverage/document-manager/server/controllers/search.js.html delete mode 100644 coverage/document-manager/server/controllers/users.js.html delete mode 100644 coverage/document-manager/server/helpers/helper.js.html delete mode 100644 coverage/document-manager/server/helpers/index.html delete mode 100644 coverage/document-manager/server/middlewares/auth.js.html delete mode 100644 coverage/document-manager/server/middlewares/index.html delete mode 100644 coverage/document-manager/server/models/document.js.html delete mode 100644 coverage/document-manager/server/models/index.html delete mode 100644 coverage/document-manager/server/models/index.js.html delete mode 100644 coverage/document-manager/server/models/role.js.html delete mode 100644 coverage/document-manager/server/models/user.js.html delete mode 100644 coverage/document-manager/server/routes/documents.js.html delete mode 100644 coverage/document-manager/server/routes/index.html delete mode 100644 coverage/document-manager/server/routes/index.js.html delete mode 100644 coverage/document-manager/server/routes/roles.js.html delete mode 100644 coverage/document-manager/server/routes/search.js.html delete mode 100644 coverage/document-manager/server/routes/users.js.html delete mode 100644 coverage/document-manager/server/test/controllers/document.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/index.html delete mode 100644 coverage/document-manager/server/test/controllers/mockData.js.html delete mode 100644 coverage/document-manager/server/test/controllers/role.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/search.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/user.spec.js.html delete mode 100644 coverage/index.html delete mode 100644 coverage/prettify.css delete mode 100644 coverage/prettify.js delete mode 100644 coverage/sort-arrow-sprite.png delete mode 100644 coverage/sorter.js diff --git a/coverage/base.css b/coverage/base.css deleted file mode 100644 index 417c7ad..0000000 --- a/coverage/base.css +++ /dev/null @@ -1,212 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } - -.cbranch-no { background: yellow !important; color: #111; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html deleted file mode 100644 index f38a538..0000000 --- a/coverage/document-manager/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager - - - - - - - -
-
-

- All files document-manager -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 3/3 -
-
-
-
-
-

1 2 @@ -269,8 +269,8 @@

224 225 226 -227

1x -1x +227  +    1x 1x @@ -375,7 +375,7 @@

      -  +        @@ -402,7 +402,7 @@

      -6x +  3x     @@ -531,12 +531,12 @@

userId: req.body.userId }) .then(documentResponse => res.status(200).send(documentResponse)) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } return res.status(403).json({ message: 'Document already exists' }); - }).catch(error => res.status(400).send(error)); + }).catch(error => res.status(400).send(error)); } }   @@ -571,9 +571,9 @@

userId: req.body.userId || document.userId }) .then(() => res.status(200).send(document)) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   /** @@ -601,13 +601,13 @@

} ] }) - .then(({ rows: document, count }) => { + .then(({ rows: document, count }) => { res.status(200).send({ document, pagination: metaData(count, limit, offset), }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } else Eif (req.decoded.roleId !== 1) { return Document.findAndCountAll({ limit, @@ -634,7 +634,7 @@

pagination: metaData(count, limit, offset), }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } }   @@ -677,7 +677,7 @@

} return res.status(200).send(document); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } }) .catch(error => res.status(400).send(error)); @@ -710,9 +710,9 @@

.then(() => res.status(204).send({ message: 'Document successfully deleted' })) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   export default { @@ -727,7 +727,7 @@

diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html index 2f73bc1..f9ed5d0 100644 --- a/coverage/document-manager/server/controllers/index.html +++ b/coverage/document-manager/server/controllers/index.html @@ -20,9 +20,9 @@

- 82.25% + 81.48% Statements - 190/231 + 176/216
81.03% @@ -35,9 +35,9 @@

57/84

- 82.25% + 81.48% Lines - 190/231 + 176/216
@@ -59,16 +59,16 @@

documents.js
79.71%55/69documents.js
80%52/65 85.71% 36/42 60% 15/2579.71%55/6980%52/65
search.js
82.86%29/35
80%24/30 71.43% 10/14 62.5% 5/882.86%29/3580%24/30
users.js
85.06%74/87
83.95%68/81 83.33% 35/42 70% 21/3085.06%74/8783.95%68/81
1x -1x +130  +    1x 1x @@ -204,7 +204,7 @@

      -2x +  1x     @@ -250,7 +250,7 @@

      -2x +  1x     @@ -285,7 +285,7 @@

      -2x +  1x 1x   @@ -341,7 +341,7 @@

user, pagination: metaData(count, limit, offset) }); - }).catch(error => res.status(400).send(error)); + }).catch(error => res.status(400).send(error)); }   /** @@ -390,7 +390,7 @@

pagination: metaData(count, limit, offset), }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } else Eif (req.decoded.roleId !== 1) { return Document.findAndCountAll({ limit, @@ -425,7 +425,7 @@

pagination: metaData(count, limit, offset), }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); } }   @@ -436,7 +436,7 @@

diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html index fdf2c72..b5e4bac 100644 --- a/coverage/document-manager/server/controllers/users.js.html +++ b/coverage/document-manager/server/controllers/users.js.html @@ -20,9 +20,9 @@

- 85.06% + 83.95% Statements - 74/87 + 68/81
83.33% @@ -35,9 +35,9 @@

21/30

- 85.06% + 83.95% Lines - 74/87 + 68/81
@@ -328,11 +328,11 @@

283 284 285 -286

1x -1x +286  +  +  +    -1x -1x   1x   @@ -356,7 +356,7 @@

      -4x +  2x     @@ -593,7 +593,7 @@

      -2x +  1x     @@ -647,7 +647,7 @@

pagination: metaData(count, limit, offset) }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   /** @@ -685,7 +685,7 @@

success: true, message: 'You have successfully registered.' }); - }).catch((error) => { + }).catch((error) => { res.status(400).json(error); }); } @@ -742,7 +742,7 @@

}); } } - }).catch(error => res.status(400).send(error)); + }).catch(error => res.status(400).send(error)); } }   @@ -821,9 +821,9 @@

message: 'Details successfully updated.' }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }); }); } @@ -850,9 +850,9 @@

.destroy() .then(() => res.status(204).json({ message: 'User has been deleted successfully' })) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   /** @@ -884,9 +884,9 @@

pagination: metaData(count, limit, offset), }); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }) - .catch(error => res.status(400).send(error)); + .catch(error => res.status(400).send(error)); }   export default { @@ -904,7 +904,7 @@

diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html index 8850d18..2cef2dd 100644 --- a/coverage/document-manager/server/helpers/helper.js.html +++ b/coverage/document-manager/server/helpers/helper.js.html @@ -73,7 +73,7 @@

diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html index 91ef423..b708132 100644 --- a/coverage/document-manager/server/helpers/index.html +++ b/coverage/document-manager/server/helpers/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html index 90c32a2..11c30ee 100644 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ b/coverage/document-manager/server/middlewares/auth.js.html @@ -20,9 +20,9 @@

- 92.31% + 91.67% Statements - 12/13 + 11/12
87.5% @@ -35,9 +35,9 @@

3/3

- 92.31% + 91.67% Lines - 12/13 + 11/12
@@ -78,7 +78,7 @@

33 34 35 -36

1x +36    1x   @@ -154,7 +154,7 @@

diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html index 00c29e1..a49ae60 100644 --- a/coverage/document-manager/server/middlewares/index.html +++ b/coverage/document-manager/server/middlewares/index.html @@ -20,9 +20,9 @@

- 92.31% + 91.67% Statements - 12/13 + 11/12
87.5% @@ -35,9 +35,9 @@

3/3

- 92.31% + 91.67% Lines - 12/13 + 11/12
@@ -60,15 +60,15 @@

auth.js
92.31%12/13
91.67%11/12 87.5% 7/8 100% 3/392.31%12/1391.67%11/12
index.js
95.83%23/24
95.65%22/23 66.67% 6/9 100% 3/395.83%23/2495.65%22/23
1x -1x -1x +25  +  +    1x   @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html index 43260a1..9acaf25 100644 --- a/coverage/document-manager/server/routes/index.html +++ b/coverage/document-manager/server/routes/index.html @@ -22,7 +22,7 @@

100% Statements - 36/36 + 19/19
100% @@ -37,7 +37,7 @@

100% Lines - 36/36 + 19/19

@@ -62,65 +62,65 @@

documents.js
100%6/63/3 100% 0/0 100% 0/0 100%6/63/3
index.js
100%10/105/5 100% 0/0 100% 0/0 100%10/105/5
roles.js
100%6/63/3 100% 0/0 100% 0/0 100%6/63/3
search.js
100%6/63/3 100% 0/0 100% 0/0 100%6/63/3
users.js
100%8/85/5 100% 0/0 100% 0/0 100%8/85/5
1x -1x -1x -1x -1x +17  +  +  +  +      1x @@ -97,7 +97,7 @@

diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html index 74c82f6..638133e 100644 --- a/coverage/document-manager/server/routes/roles.js.html +++ b/coverage/document-manager/server/routes/roles.js.html @@ -22,7 +22,7 @@

100% Statements - 6/6 + 3/3
100% @@ -37,7 +37,7 @@

100% Lines - 6/6 + 3/3

@@ -67,9 +67,9 @@

22 23 24 -25

1x -1x -1x +25  +  +    1x   @@ -121,7 +121,7 @@

diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html index 154e391..b213d87 100644 --- a/coverage/document-manager/server/routes/search.js.html +++ b/coverage/document-manager/server/routes/search.js.html @@ -22,7 +22,7 @@

100% Statements - 6/6 + 3/3
100% @@ -37,7 +37,7 @@

100% Lines - 6/6 + 3/3

@@ -58,9 +58,9 @@

13 14 15 -16

1x -1x -1x +16  +  +    1x   @@ -94,7 +94,7 @@

diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html index 8dacf45..d7a9982 100644 --- a/coverage/document-manager/server/routes/users.js.html +++ b/coverage/document-manager/server/routes/users.js.html @@ -22,7 +22,7 @@

100% Statements - 8/8 + 5/5
100% @@ -37,7 +37,7 @@

100% Lines - 8/8 + 5/5

@@ -75,9 +75,9 @@

30 31 32 -33

1x -1x -1x +33  +  +    1x   @@ -145,7 +145,7 @@

diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html index 34d1a28..8ad3422 100644 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ b/coverage/document-manager/server/test/controllers/document.spec.js.html @@ -1291,7 +1291,7 @@

diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html index f84569d..c8eef21 100644 --- a/coverage/document-manager/server/test/controllers/index.html +++ b/coverage/document-manager/server/test/controllers/index.html @@ -129,7 +129,7 @@

diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html index 8605e19..c9ba712 100644 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ b/coverage/document-manager/server/test/controllers/mockData.js.html @@ -208,7 +208,7 @@

diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html index 2d2b09c..d917843 100644 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ b/coverage/document-manager/server/test/controllers/role.spec.js.html @@ -919,7 +919,7 @@

diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html index a5d34e9..1af9d46 100644 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ b/coverage/document-manager/server/test/controllers/search.spec.js.html @@ -367,7 +367,7 @@

diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html index 19ee730..e39f0a1 100644 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ b/coverage/document-manager/server/test/controllers/user.spec.js.html @@ -1216,7 +1216,7 @@

diff --git a/coverage/index.html b/coverage/index.html index c633d74..886022a 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,9 +20,9 @@

- 93.66% + 86.36% Statements - 916/978 + 266/308
81.02% @@ -30,14 +30,14 @@

111/137

- 89.76% + 73% Functions - 263/293 + 73/100
- 93.6% + 86.27% Lines - 906/968 + 264/306
@@ -62,39 +62,39 @@

document-manager
100%4/43/3 100% 2/2 100% 1/1 100%4/43/3
document-manager/server/config
100%21/2116/16 100% 2/2 100% 2/2 100%20/2015/15
document-manager/server/controllers
82.25%190/231
81.48%176/216 81.03% 94/116 67.86% 57/8482.25%190/23181.48%176/216
document-manager/server/middlewares
92.31%12/13
91.67%11/12 87.5% 7/8 100% 3/392.31%12/1391.67%11/12
document-manager/server/models
97.5%39/40
97.44%38/39 66.67% 6/9 100% 9/997.5%39/4097.44%38/39
document-manager/server/routes
100%36/3619/19 100% 0/0 100% 0/0 100%36/36
document-manager/server/test/controllers
96.98%611/630100%0/098.45%190/19396.95%603/62219/19
1x +26 +27 +281x   +1x       @@ -93,7 +96,10 @@

      - 

module.exports = {
+ 
+ 
require('dotenv').config();
+ 
+module.exports = {
   development: {
     username: 'andeladeveloper',
     password: null,
@@ -124,7 +130,7 @@ 

diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html index 17cea69..1bba21b 100644 --- a/coverage/document-manager/server/config/express.js.html +++ b/coverage/document-manager/server/config/express.js.html @@ -88,14 +88,14 @@

1x   1x -83x -83x -83x -115x -112x -112x +82x +82x +82x +113x +111x +111x   -83x +82x       @@ -139,7 +139,7 @@

diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html index 4df71ae..950308c 100644 --- a/coverage/document-manager/server/config/index.html +++ b/coverage/document-manager/server/config/index.html @@ -22,7 +22,7 @@

100% Statements - 16/16 + 17/17
100% @@ -37,7 +37,7 @@

100% Lines - 15/15 + 16/16

@@ -62,13 +62,13 @@

config.js
100%1/12/2 100% 0/0 100% 0/0 100%1/12/2
document-manager/server/config
100%16/1617/17 100% 2/2 100% 2/2 100%15/1516/16
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
index.js
100%3/3100%2/2100%1/1100%3/3
-
- - - - - - - - diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html deleted file mode 100644 index 97543a5..0000000 --- a/coverage/document-manager/index.js.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Code coverage report for document-manager/index.js - - - - - - - -
-
-

- All files / document-manager index.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 3/3 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10  -  -1x -  -1x -1x -  -  -  - 
import app from './server/config/express';
- 
-const port = process.env.PORT || 3000;
- 
-const server = app.listen(port, () => {
-  console.log('API Server started and listening on port 3000');
-});
- 
-export default server;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html deleted file mode 100644 index 46da18d..0000000 --- a/coverage/document-manager/server/config/config.js.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - Code coverage report for document-manager/server/config/config.js - - - - - - - -
-
-

- All files / document-manager/server/config config.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -281x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
require('dotenv').config();
- 
-module.exports = {
-  development: {
-    username: 'andeladeveloper',
-    password: null,
-    database: 'docmanager-dev',
-    host: '127.0.0.1',
-    port: 5432,
-    dialect: 'postgres'
-  },
-  test: {
-    username: 'andeladeveloper',
-    password: null,
-    database: 'docmanager-test',
-    host: '127.0.0.1',
-    port: 5432,
-    dialect: 'postgres'
-  },
-  production: {
-    username: 'root',
-    password: null,
-    database: 'database_production',
-    host: '127.0.0.1',
-    dialect: 'postgres'
-  }
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html deleted file mode 100644 index 1bba21b..0000000 --- a/coverage/document-manager/server/config/express.js.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - Code coverage report for document-manager/server/config/express.js - - - - - - - -
-
-

- All files / document-manager/server/config express.js -

-
-
- 100% - Statements - 15/15 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 14/14 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31  -  -  -  -  -  -1x -  -1x -  -1x -1x -1x -  -1x -82x -82x -82x -113x -111x -111x -  -82x -  -  -  -1x -  -  -  - 
import express from 'express';
-import bodyParser from 'body-parser';
-import logger from 'morgan';
-import expressValidator from 'express-validator';
-import routes from '../routes';
- 
-const app = express();
- 
-app.use(logger('dev'));
- 
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: false }));
-app.use(expressValidator());
- 
-app.use((req, res, next) => {
-  const send = res.send;
-  let sent = false;
-  res.send = (data) => {
-    if (sent) return;
-    send.bind(res)(data);
-    sent = true;
-  };
-  next();
-});
- 
-// mount all routes on /api path
-app.use('/api/v1', routes);
- 
- 
-export default app;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html deleted file mode 100644 index 950308c..0000000 --- a/coverage/document-manager/server/config/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - Code coverage report for document-manager/server/config - - - - - - - -
-
-

- All files document-manager/server/config -

-
-
- 100% - Statements - 17/17 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 16/16 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
config.js
100%2/2100%0/0100%0/0100%2/2
express.js
100%15/15100%2/2100%2/2100%14/14
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html deleted file mode 100644 index a3f2bee..0000000 --- a/coverage/document-manager/server/controllers/documents.js.html +++ /dev/null @@ -1,743 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/documents.js - - - - - - - -
-
-

- All files / document-manager/server/controllers documents.js -

-
-
- 80% - Statements - 52/65 -
-
- 85.71% - Branches - 36/42 -
-
- 60% - Functions - 15/25 -
-
- 80% - Lines - 52/65 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227  -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -5x -5x -5x -  -5x -  -5x -4x -  -1x -  -  -  -  -1x -1x -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -4x -  -  -4x -4x -  -4x -1x -  -  -  -3x -2x -  -  -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -  -7x -1x -  -7x -1x -  -6x -1x -  -4x -2x -1x -  -  -  -1x -  -2x -2x -  -  -2x -  -  -1x -  -  -  -1x -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -4x -  -4x -1x -  -  -  -3x -  -  -  -1x -  -  -  -2x -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const User = models.User;
-const Document = models.Document;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Create documents for users
- * @param {object} req - document to be created
- * @param {object} res - created document
- * @returns {object} - created document
- */
-function createDocument(req, res) {
-  req.check('title', 'Title is required').notEmpty();
-  req.check('content', 'Content is required').notEmpty();
-  req.check('access', 'accessType is required').notEmpty();
- 
-  const errors = req.validationErrors();
- 
-  if (errors) {
-    res.status(400).json({ errors });
-  } else {
-    Document.findAll({
-      where: {
-        title: req.body.title
-      }
-    }).then((document) => {
-      Eif (document.length === 0) {
-        return Document.create({
-          title: req.body.title,
-          content: req.body.content,
-          access: req.body.value,
-          userId: req.body.userId
-        })
-      .then(documentResponse => res.status(200).send(documentResponse))
-      .catch(error => res.status(400).send(error));
-      }
-      return res.status(403).json({
-        message: 'Document already exists'
-      });
-    }).catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
- * Update user document.
- * @param {number} req - request id of the document to be updated
- * @param {object} res - object of the updated document
- * @returns {object} - updated document
- */
-function updateDocument(req, res) {
-  Iif (isNaN(req.params.id)) {
-    return res.status(400);
-  }
-  const docId = Number(req.params.id);
-  return Document.findById(docId)
-    .then((document) => {
-      if (!document) {
-        return res.status(404).send({
-          message: 'Document Not Found'
-        });
-      }
-      if (Number(document.userId) !== Number(req.decoded.id)) {
-        return res.status(401).json({
-          message: 'You are not authorized to edit this document'
-        });
-      }
-      return document
-        .update({
-          title: req.body.title || document.title,
-          content: req.body.content || document.content,
-          access: req.body.value || document.access,
-          userId: req.body.userId || document.userId
-        })
-        .then(() => res.status(200).send(document))
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-/**
- *  Get all documents
- * @param {object} req - contains an object of the query, limits and offset
- * @param {array} res - array of documents with pagination
- * @returns {array} - array of documents
- */
-function getAllDocument(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  Iif (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else Eif (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
-   * Find a document by Id
-   * @param {number} req - id of the requested document
-   * @param {object} res - object containg the requested document
-   * @returns {object} requested document
-   */
-function findDocument(req, res) {
-  return Document.findById(req.params.id)
-    .then((document) => {
-      if (!document) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      if (req.decoded.roleId === 1) {
-        return document;
-      }
-      if (document.access === 'public') {
-        return res.status(200).send(document);
-      }
-      if (document.access === 'private') {
-        if (document.userId !== req.decoded.id) {
-          return res.status(401).json({
-            message: 'You are not authorized to view this document'
-          });
-        }
-        return res.status(200).send(document);
-      }
-      Eif (document.access === 'role') {
-        return models.User
-          .findById(document.userId)
-          .then((documentOwner) => {
-            if (
-              Number(documentOwner.roleId) !== Number(req.decoded.roleId)
-            ) {
-              return res.status(401).json({
-                message: 'You are not authorized to view this document'
-              });
-            }
-            return res.status(200).send(document);
-          })
-          .catch(error => res.status(400).send(error));
-      }
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Delete a document by Id
- * @param {number} req - id of the requested document
- * @param {object} res - message
- * @returns {object} - message
- */
-function deleteDocument(req, res) {
-  return Document.findById(req.params.id)
-    .then((document) => {
-      if (!document) {
-        return res.status(404).send({
-          message: 'Document Not Found'
-        });
-      }
-      if (
-        req.decoded.roleId !== 1 &&
-        Number(document.userId) !== Number(req.decoded.id)
-      ) {
-        return res.status(401).json({
-          message: 'You are not authorized to delete this document'
-        });
-      }
-      return document
-        .destroy()
-        .then(() => res.status(204).send({
-          message: 'Document successfully deleted'
-        }))
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-export default {
-  createDocument,
-  updateDocument,
-  getAllDocument,
-  findDocument,
-  deleteDocument };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html deleted file mode 100644 index a7e62cf..0000000 --- a/coverage/document-manager/server/controllers/index.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers - - - - - - - -
-
-

- All files document-manager/server/controllers -

-
-
- 81.48% - Statements - 176/216 -
-
- 81.03% - Branches - 94/116 -
-
- 67.86% - Functions - 57/84 -
-
- 81.48% - Lines - 176/216 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
documents.js
80%52/6585.71%36/4260%15/2580%52/65
roles.js
80%32/4072.22%13/1876.19%16/2180%32/40
search.js
80%24/3071.43%10/1462.5%5/880%24/30
users.js
83.95%68/8183.33%35/4270%21/3083.95%68/81
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html deleted file mode 100644 index d59d69c..0000000 --- a/coverage/document-manager/server/controllers/roles.js.html +++ /dev/null @@ -1,482 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/roles.js - - - - - - - -
-
-

- All files / document-manager/server/controllers roles.js -

-
-
- 80% - Statements - 32/40 -
-
- 72.22% - Branches - 13/18 -
-
- 76.19% - Functions - 16/21 -
-
- 80% - Lines - 32/40 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -1401x -  -1x -  -  -  -  -  -  -  -  -2x -  -2x -2x -  -  -2x -  -  -2x -2x -  -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -1x -  -  -  -  -  -  -  -  -  -  -4x -1x -  -  -  -3x -  -  -2x -1x -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -3x -  -  -  -3x -  -  -2x -1x -  -  -  -1x -  -  -  -1x -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -3x -  -  -  -3x -  -2x -1x -  -  -  -1x -  -  -  -  -1x -1x -  -  -  -  -  - 
const models = require('../models');
- 
-const Role = models.Role;
- 
-/**
- * Creates a new Role.
- * @param {object} req - role to be created
- * @param {object} res - new created role
- * @returns {object} - newly created role
- */
-function createRole(req, res) {
-  req.check('title', 'Title is required').notEmpty();
- 
-  const errors = req.validationErrors();
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    Role.findAll({
-      where: { title: req.body.title }
-    }).then((err, existingRole) => {
-      Eif (!existingRole) {
-        Role.create({
-          title: req.body.title
-        }).then((role) => {
-          res.status(201).send({
-            message: 'Role successfully created',
-            role
-          });
-        }).catch((error) => {
-          res.json(error.errors);
-        });
-      }
-    }).catch(error => res.json(error));
-  }
-}
- 
-/**
- * Get all roles.
- * @param {void} req - no request body attached
- * @param {array} res - an array of roles and their id
- * @returns {array} array of roles
- */
-function getRoles(req, res) {
-  return Role
-    .findAll()
-    .then(role => res.status(200).json(role))
-    .catch(error => res.json(error));
-}
- 
-/**
- * Find roles by Id.
- * @param {number} req - requested role
- * @param {object} res - role found by id
- * @returns {object} - role found by id
- */
-function findRole(req, res) {
-  if (isNaN(req.params.id)) {
-    res.status(401).json({
-      message: `invalid input syntax for integer: "${req.params.id}"`
-    });
-  } else {
-    Role
-      .findById(req.params.id)
-      .then((role) => {
-        if (!role) {
-          return res.status(404).json({
-            message: 'Role not found'
-          });
-        }
-        res.status(200).json(role);
-      }).catch(() => res.status(400).json({
-        message: 'out of range for type integer'
-      }));
-  }
-}
- 
-/**
- * Update role.
- * @param {number} req - requested role by id
- * @param {object} res - updated role
- * @returns {object} - updated role status
- */
-function updateRole(req, res) {
-  Iif (req.decoded.roleId !== 1) {
-    return res.status(401)
-      .json({ message: 'You are not authorized' });
-  }
-  return Role
-    .findById(req.params.id)
-    .then((role) => {
-      if (!role) {
-        return res.status(404).json({
-          message: 'Role not found'
-        });
-      }
-      return role
-        .update({
-          title: req.body.title || role.title
-        })
-        .then(() => res.status(200).json({
-          message: 'Role updated successfully',
-          role
-        }))
-        .catch(error => res.status(400).json(error));
-    }).catch(() => res.status(400).json({
-      message: 'out of range for type integer'
-    }));
-}
- 
-/**
- * Delete roles by Id.
- * @param {number} req - role to be deleted by id
- * @param {object} res - deleted role
- * @returns {object} - message
- */
-function deleteRole(req, res) {
-  Iif (req.decoded.roleId !== 1) {
-    return res.status(401)
-      .json({ message: 'You are not authorized' });
-  }
-  return Role.findById(req.params.id)
-    .then((role) => {
-      if (!role) {
-        return res.status(404).json({
-          message: 'Role not found'
-        });
-      }
-      return role
-        .destroy()
-        .then(() => res.status(204).send({
-          message: 'Role deleted successfully'
-        }))
-        .catch(error => res.status(400).send(error));
-    }).catch(() => res.status(400).json({
-      message: 'out of range for type integer'
-    }));
-}
- 
-export default { createRole, getRoles, findRole, updateRole, deleteRole };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html deleted file mode 100644 index 597b68a..0000000 --- a/coverage/document-manager/server/controllers/search.js.html +++ /dev/null @@ -1,452 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/search.js - - - - - - - -
-
-

- All files / document-manager/server/controllers search.js -

-
-
- 80% - Statements - 24/30 -
-
- 71.43% - Branches - 10/14 -
-
- 62.5% - Functions - 5/8 -
-
- 80% - Lines - 24/30 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130  -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -2x -2x -2x -2x -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -3x -3x -1x -  -  -  -2x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -1x -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Search for user using a query string
- * @param {string} req - search query of string
- * @param {array} res - array of users
- * @returns {array} - array users searched
- */
-function searchUser(req, res) {
-  const searchQuery = req.query.q,
-    limit = req.query.limit,
-    offset = req.query.offset;
-  if (!searchQuery) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  return User
-  .findAndCountAll({
-    limit,
-    offset,
-    attributes: { exclude: ['password'] },
-    where: {
-      userName: {
-        $like: `%${searchQuery}%`,
-      }
-    }
-  }).then(({ rows: user, count }) => {
-    Iif (count === 0) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  }).catch(error => res.status(400).send(error));
-}
- 
-/**
-   *
-   * Search for documents by title
-   * @param {string} req - an object containing the query, offset and limit
-   * @param {array} res - an array containing searched document
-   * @returns {array} - searched document
-   */
-function searchDocuments(req, res) {
-  const limit = req.query.limit,
-    offset = req.query.offset,
-    queryString = req.query.q;
-  if (!queryString) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  if (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      Iif (count === 0) {
-        return res.status(404).json({
-          message: 'Document not found'
-        });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else Eif (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      Eif (count === 0) {
-        return res.status(404).json({
-          message: 'Document not found'
-        });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-export default { searchUser, searchDocuments };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html deleted file mode 100644 index 46bbbbe..0000000 --- a/coverage/document-manager/server/controllers/users.js.html +++ /dev/null @@ -1,920 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/users.js - - - - - - - -
-
-

- All files / document-manager/server/controllers users.js -

-
-
- 83.95% - Statements - 68/81 -
-
- 83.33% - Branches - 35/42 -
-
- 70% - Functions - 21/30 -
-
- 83.95% - Lines - 68/81 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286  -  -  -  -  -  -1x -  -1x -1x -1x -1x -  -  -  -  -  -  -  -  -2x -2x -2x -  -  -  -  -  -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -1x -1x -1x -  -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -13x -13x -13x -  -13x -  -13x -  -  -13x -  -  -  -13x -13x -1x -  -  -12x -12x -  -11x -  -  -  -  -  -  -11x -  -  -11x -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -5x -5x -  -  -  -  -5x -1x -  -  -  -4x -  -  -  -  -  -  -  -3x -1x -  -3x -  -1x -  -  -  -  -  -  -  -  -  -  -  -5x -2x -  -  -  -3x -3x -3x -3x -  -  -3x -  -  -3x -  -  -  -  -  -  -  -  -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -1x -  -  -  -2x -  -  -2x -1x -  -1x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -2x -2x -  -2x -1x -  -  -  -1x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import bcrypt from 'bcrypt';
-import jwt from 'jsonwebtoken';
- 
-import helper from '../helpers/helper';
-import models from '../models';
- 
-require('dotenv').config();
- 
-const jwtSecret = process.env.JWT_SECRET;
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Get all users
- * @param {number} req - limit and offset for getting all user
- * @param {array} res - array of users or error
- * @returns {array} - an array of users
- */
-function getUsers(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  return User
-  .findAndCountAll(
-    { limit,
-      offset,
-      attributes: { exclude: ['password'] }
-    })
-  .then(({ rows: user, count }) => {
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  })
-  .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Create a user
- * @param {object} req - request from user
- * @param {object} res - newly created user or error
- * @returns {object} - an object of a created user
- */
-function createUser(req, res) {
-  req.check('fullName', 'FullName is required').notEmpty();
-  req.check('userName', 'userName is required').notEmpty();
-  req.check('email', 'Email is required').notEmpty();
-  req.check('email', 'Please put a valid email').isEmail();
-  req.check('password', 'Password is required').notEmpty();
-  req.check('password', 'Password must be a mininum of 4 character')
-  .isLength(4, 50);
-  const errors = req.validationErrors();
- 
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    User.findAll({
-      where: { email: req.body.email }
-    }).then((err, user) => {
-      Eif (!user) {
-        User.create({
-          fullName: req.body.fullName,
-          userName: req.body.userName,
-          email: req.body.email,
-          password: bcrypt.hashSync(req.body.password, bcrypt.genSaltSync(10)),
-          roleId: req.body.roleId || 2
-        }).then((userDetails) => {
-          res.status(200).json({
-            userDetails,
-            success: true,
-            message: 'You have successfully registered.'
-          });
-        }).catch((error) => {
-          res.status(400).json(error);
-        });
-      }
-    });
-  }
-}
- 
-/**
- * Log In user with JWT
- * @param {object} req - request from log in user
- * @param {object} res - authenicated user details
- * @returns {object} - an object of the logged in user and a token
- */
-function login(req, res) {
-  req.check('email', 'Email is required').notEmpty();
-  req.check('email', 'Please put a valid email').isEmail();
-  req.check('password', 'Password is required').notEmpty();
- 
-  const errors = req.validationErrors();
- 
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    User.findAll({
-      where: { email: req.body.email }
-    })
-    .then((user) => {
-      const existingUser = user[0];
-      if (!existingUser) {
-        res.status(400).json({
-          success: false,
-          message: 'Authentication failed. User not found.' });
-      } else Eif (existingUser) {
-        if (bcrypt.compareSync(req.body.password, existingUser.password)) {
-          const payLoad = (
-            {
-              email: existingUser.email,
-              id: existingUser.id,
-              fullName: existingUser.fullName,
-              roleId: existingUser.roleId,
-            }
-          );
-          const token = jwt.sign(payLoad, jwtSecret, {
-            expiresIn: 60 * 60 * 24
-          });
-          res.status(201).json({
-            success: true,
-            token,
-          });
-        } else {
-          res.status(401).json({
-            success: false,
-            message: 'Authentication failed. Wrong password.'
-          });
-        }
-      }
-    }).catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
- * Find a user by Id
- * @param {number} req - request for user using the id of the user
- * @param {object} res - an object of the user(s) found or error
- * @returns {object} - an object of found user
- */
-function findUser(req, res) {
-  const userQuery = Number(req.params.id);
-  Iif ((req.decoded.id !== userQuery) && (req.decoded.roleId !== 1)) {
-    return res.status(401).json({
-      message: 'Unauthorized Access'
-    });
-  }
-  if (isNaN(userQuery)) {
-    return res.status(401).json({
-      message: `invalid input syntax for integer: "${req.params.id}"`
-    });
-  }
-  return User
-    .findAll({
-      where: {
-        id: req.params.id,
-      },
-      attributes: { exclude: ['password'] }
-    })
-    .then((user) => {
-      if (!user.length) {
-        res.status(404).json({ message: 'User not found' });
-      }
-      res.status(200).send(user);
-    })
-    .catch(() => res.status(400).send({
-      message: 'out of range'
-    }));
-}
- 
-/**
- *Update a user by Id
- * @param {object} req - updated user object
- * @param {object} res - updated user object or error
- * @returns {object} - return an object of the updated user
- */
-function updateUser(req, res) {
-  if (Number(req.decoded.id) !== Number(req.params.id)) {
-    return res.status(401).json({
-      message: 'You are not authorized to access this user'
-    });
-  }
-  const userId = Number(req.params.id);
-  bcrypt.genSalt(10, (err, salt) => {
-    bcrypt.hash(req.body.password, salt, (err, hash) => {
-      User
-      .findById(userId)
-      .then((user) => {
-        Iif (!user) {
-          return res.status(404).json({ message: 'User not found' });
-        }
-        return user
-          .update({
-            fullName: req.body.fullName || user.fullName,
-            userName: req.body.userName || user.userName,
-            email: req.body.email || user.email,
-            password: hash || user.password,
-            roleId: req.body.roleId || user.roleId
-          })
-          .then((updatedUser) => {
-            res.status(200).send({
-              id: updatedUser.id,
-              fullName: updatedUser.fullName,
-              userName: updatedUser.userName,
-              email: updatedUser.email,
-              roleId: updatedUser.roleId,
-              message: 'Details successfully updated.'
-            });
-          })
-          .catch(error => res.status(400).send(error));
-      })
-      .catch(error => res.status(400).send(error));
-    });
-  });
-}
- 
-/**
- * Delete a user by Id
- * @param {number} req - delete user with an id
- * @param {object} res - message
- * @returns {object} - null
- */
-function deleteUser(req, res) {
-  if (req.decoded.roleId !== 1) {
-    return res.status(401).json({
-      message: 'You are not authorized to access this field'
-    });
-  }
-  return User
-  .findById(req.params.id)
-  .then((user) => {
-    if (!user) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    return user
-      .destroy()
-      .then(() => res.status(204).json({
-        message: 'User has been deleted successfully' }))
-      .catch(error => res.status(400).send(error));
-  })
-  .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Get documents for specific user
- * @param {object} req - request object containing limit query and offset
- * @param {array} res - array of documents for the requested user
- * @return {array} - array of requested user's document
- */
-function getUserDocuments(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  User.findById(req.params.id)
-    .then((user) => {
-      if (!user) {
-        return res.status(404).json({
-          message: 'User not found'
-        });
-      }
-      return Document.findAndCountAll({
-        limit,
-        offset,
-        where: {
-          userId: user.id
-        }
-      })
-        .then(({ rows: document, count }) => {
-          res.status(200).send({
-            document,
-            pagination: metaData(count, limit, offset),
-          });
-        })
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-export default {
-  getUsers,
-  createUser,
-  login,
-  findUser,
-  updateUser,
-  deleteUser,
-  getUserDocuments
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html deleted file mode 100644 index 71d1146..0000000 --- a/coverage/document-manager/server/helpers/helper.js.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Code coverage report for document-manager/server/helpers/helper.js - - - - - - - -
-
-

- All files / document-manager/server/helpers helper.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -98x -  -  -  -  -  -  -1x - 
const paginationMetaData = (count, limit, offset) => ({
-  totalCount: count,
-  pageCount: Math.ceil(count / limit),
-  page: Math.floor(offset / limit) + 1,
-  pageSize: limit
-});
- 
-module.exports.paginationMetaData = paginationMetaData;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html deleted file mode 100644 index 1d955e8..0000000 --- a/coverage/document-manager/server/helpers/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/helpers - - - - - - - -
-
-

- All files document-manager/server/helpers -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
helper.js
100%3/3100%0/0100%1/1100%2/2
-
-
- - - - - - - diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html deleted file mode 100644 index e8ec699..0000000 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - Code coverage report for document-manager/server/middlewares/auth.js - - - - - - - -
-
-

- All files / document-manager/server/middlewares auth.js -

-
-
- 91.67% - Statements - 11/12 -
-
- 87.5% - Branches - 7/8 -
-
- 100% - Functions - 3/3 -
-
- 91.67% - Lines - 11/12 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36  -  -1x -  -  -  -68x -68x -64x -64x -  -  -64x -64x -  -  -  -4x -  -  -  -  -  -  -  -23x -17x -  -6x -  -  -  -  -  -  - 
import jwt from 'jsonwebtoken';
- 
-const jwtSecret = process.env.JWT_SECRET;
- 
- 
-function verifyToken(req, res, next) {
-  const token = req.headers.authorization || req.headers['x-access-token'];
-  if (token) {
-    jwt.verify(token, jwtSecret, (err, decoded) => {
-      Iif (err) {
-        res.json({ success: false, message: 'Failed to authenticate token.' });
-      } else {
-        req.decoded = decoded;
-        next();
-      }
-    });
-  } else {
-    return res.status(403).send({
-      success: false,
-      message: 'No token provided.'
-    });
-  }
-}
- 
-function adminAccess(req, res, next) {
-  if (req.decoded.roleId === 1) {
-    next();
-  } else {
-    return res.status(401).json({
-      message: 'You are not authorized',
-    });
-  }
-}
- 
-export default { verifyToken, adminAccess };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html deleted file mode 100644 index 71d0a8c..0000000 --- a/coverage/document-manager/server/middlewares/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/middlewares - - - - - - - -
-
-

- All files document-manager/server/middlewares -

-
-
- 91.67% - Statements - 11/12 -
-
- 87.5% - Branches - 7/8 -
-
- 100% - Functions - 3/3 -
-
- 91.67% - Lines - 11/12 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
auth.js
91.67%11/1287.5%7/8100%3/391.67%11/12
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html deleted file mode 100644 index f71df09..0000000 --- a/coverage/document-manager/server/models/document.js.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - Code coverage report for document-manager/server/models/document.js - - - - - - - -
-
-

- All files / document-manager/server/models document.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -1x -  - 
 
-module.exports = (sequelize, DataTypes) => {
-  const Document = sequelize.define('Document', {
-    title: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    content: {
-      type: DataTypes.TEXT,
-      allowNull: false
-    },
-    userId: {
-      type: DataTypes.INTEGER,
-      unique: true,
-      allowNull: false
-    },
-    access: {
-      type: DataTypes.ENUM,
-      values: ['public', 'private', 'role']
-    }
-  });
-  Document.associate = (models) => {
-    Document.belongsTo(models.User, {
-      foreignKey: 'userId'
-    });
-  };
-  return Document;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html deleted file mode 100644 index 8be4e8e..0000000 --- a/coverage/document-manager/server/models/index.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - Code coverage report for document-manager/server/models - - - - - - - -
-
-

- All files document-manager/server/models -

-
-
- 97.44% - Statements - 38/39 -
-
- 66.67% - Branches - 6/9 -
-
- 100% - Functions - 9/9 -
-
- 97.44% - Lines - 38/39 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.js
100%5/5100%0/0100%2/2100%5/5
index.js
95.65%22/2366.67%6/9100%3/395.65%22/23
role.js
100%5/5100%0/0100%2/2100%5/5
user.js
100%6/6100%0/0100%2/2100%6/6
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html deleted file mode 100644 index 33122f1..0000000 --- a/coverage/document-manager/server/models/index.js.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - Code coverage report for document-manager/server/models/index.js - - - - - - - -
-
-

- All files / document-manager/server/models index.js -

-
-
- 95.65% - Statements - 22/23 -
-
- 66.67% - Branches - 6/9 -
-
- 100% - Functions - 3/3 -
-
- 95.65% - Lines - 22/23 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -461x -1x -1x -  -1x -1x -1x -  -1x -  -  -1x -  -  -1x -  -  -  -  -1x -  -  -4x -  -  -  -3x -3x -  -  -1x -3x -3x -  -  -  -1x -1x -  -1x -  -1x -1x -  -1x - 
const fs = require('fs');
-const path = require('path');
-const Sequelize = require('sequelize');
- 
-const basename = path.basename(module.filename);
-const env = process.env.NODE_ENV || 'development';
-const config = require('../config/config.js')[env];
- 
-const db = {};
- 
-let sequelize;
-Iif (config.use_env_variable) {
-  sequelize = new Sequelize(process.env[config.use_env_variable]);
-} else {
-  sequelize = new Sequelize(
-    config.database, config.username, config.password, config
-  );
-}
- 
-fs
-  .readdirSync(__dirname)
-  .filter(file =>
-    (file.indexOf('.') !== 0) &&
-    (file !== basename) &&
-    (file.slice(-3) === '.js'))
-  .forEach((file) => {
-    const model = sequelize.import(path.join(__dirname, file));
-    db[model.name] = model;
-  });
- 
-Object.keys(db).forEach((modelName) => {
-  Eif (db[modelName].associate) {
-    db[modelName].associate(db);
-  }
-});
- 
-db.sequelize = sequelize;
-db.Sequelize = Sequelize;
- 
-module.exports = db;
- 
-db.sequelize = sequelize;
-db.Sequelize = Sequelize;
- 
-module.exports = db;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html deleted file mode 100644 index 730f82d..0000000 --- a/coverage/document-manager/server/models/role.js.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Code coverage report for document-manager/server/models/role.js - - - - - - - -
-
-

- All files / document-manager/server/models role.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17  -1x -1x -  -  -  -  -  -  -1x -1x -  -  -  -1x -  - 
 
-module.exports = (sequelize, DataTypes) => {
-  const Role = sequelize.define('Role', {
-    title: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    }
-  });
-  Role.associate = (models) => {
-    Role.hasMany(models.User, {
-      foreignKey: 'roleId'
-    });
-  };
-  return Role;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html deleted file mode 100644 index 2ae394f..0000000 --- a/coverage/document-manager/server/models/user.js.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Code coverage report for document-manager/server/models/user.js - - - - - - - -
-
-

- All files / document-manager/server/models user.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -401x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  - 
module.exports = (sequelize, DataTypes) => {
-  const User = sequelize.define('User', {
-    fullName: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    userName: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    email: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    password: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    roleId: {
-      type: DataTypes.INTEGER,
-      allowNull: false,
-      defaultvalue: 2
-    }
-  });
-  User.associate = (models) => {
-    User.hasMany(models.Document, {
-      foreignKey: 'userId',
-      onDelete: 'CASCADE',
-      hooks: true
-    });
-    User.belongsTo(models.Role, {
-      foreignKey: 'roleId',
-      onDelete: 'CASCADE'
-    });
-  };
-  return User;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html deleted file mode 100644 index 2ac7df4..0000000 --- a/coverage/document-manager/server/routes/documents.js.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/documents.js - - - - - - - -
-
-

- All files / document-manager/server/routes documents.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 3/3 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25  -  -  -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  - 
import express from 'express';
-import documentController from '../controllers/documents';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/v1/documents - Get all documents */
-  .get(auth.verifyToken, documentController.getAllDocument)
- 
-  /** POST /api/v1/documents - Create document */
-  .post(auth.verifyToken, documentController.createDocument);
- 
-router.route('/:id')
-  /** PUT /api/v1/documents/id - Create document */
-  .put(auth.verifyToken, documentController.updateDocument)
- 
-  /** GET /api/v1/documents/id - get document */
-  .get(auth.verifyToken, documentController.findDocument)
- 
-  /** DELETE /api/v1/documents/id - delete document */
-  .delete(auth.verifyToken, documentController.deleteDocument);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html deleted file mode 100644 index 0ab127b..0000000 --- a/coverage/document-manager/server/routes/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/routes - - - - - - - -
-
-

- All files document-manager/server/routes -

-
-
- 100% - Statements - 19/19 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 19/19 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
documents.js
100%3/3100%0/0100%0/0100%3/3
index.js
100%5/5100%0/0100%0/0100%5/5
roles.js
100%3/3100%0/0100%0/0100%3/3
search.js
100%3/3100%0/0100%0/0100%3/3
users.js
100%5/5100%0/0100%0/0100%5/5
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html deleted file mode 100644 index a945750..0000000 --- a/coverage/document-manager/server/routes/index.js.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/index.js - - - - - - - -
-
-

- All files / document-manager/server/routes index.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17  -  -  -  -  -  -  -1x -  -  -1x -1x -1x -1x -  -  - 
import express from 'express';
-import userRoutes from './users';
-import searchRoutes from './search';
-import documentRoutes from './documents';
-import roleRoutes from './roles';
- 
- 
-const router = express.Router();
- 
-/** GET /api-status - Check service status **/
-router.use('/users', userRoutes);
-router.use('/search', searchRoutes);
-router.use('/documents', documentRoutes);
-router.use('/roles', roleRoutes);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html deleted file mode 100644 index 0b7a702..0000000 --- a/coverage/document-manager/server/routes/roles.js.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/roles.js - - - - - - - -
-
-

- All files / document-manager/server/routes roles.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 3/3 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25  -  -  -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  - 
import express from 'express';
-import roleController from '../controllers/roles';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/roles - Get list of roles */
-  .get(auth.verifyToken, auth.adminAccess, roleController.getRoles)
- 
-  /** POST /api/roles - Create roles */
-  .post(auth.verifyToken, auth.adminAccess, roleController.createRole);
- 
-router.route('/:id')
-  /** GET /api/users/roles - Find roles */
-  .get(auth.verifyToken, auth.adminAccess, roleController.findRole)
- 
-  /** PUT /api/users/id - update roles */
-  .put(auth.verifyToken, auth.adminAccess, roleController.updateRole)
- 
-  /** DELETE /api/users/id - delete roles */
-  .delete(auth.verifyToken, auth.adminAccess, roleController.deleteRole);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html deleted file mode 100644 index a229dd2..0000000 --- a/coverage/document-manager/server/routes/search.js.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/search.js - - - - - - - -
-
-

- All files / document-manager/server/routes search.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 3/3 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16  -  -  -  -1x -  -1x -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import searchController from '../controllers/search';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/users')
-  /** GET /api/v1/users - search list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
- 
-router.route('/documents')
-  /** GET /api/v1/search - search list of documents */
-  .get(auth.verifyToken, searchController.searchDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html deleted file mode 100644 index 08999fc..0000000 --- a/coverage/document-manager/server/routes/users.js.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/users.js - - - - - - - -
-
-

- All files / document-manager/server/routes users.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33  -  -  -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import userController from '../controllers/users';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/users - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, userController.getUsers)
- 
-  /** POST /api/users - Create/Signup users */
-  .post(userController.createUser);
- 
-router.route('/login')
-  /** POST /api/users/login - Login users */
-  .post(userController.login);
- 
-router.route('/:id')
-  /** GET /api/users/id - Find users */
-  .get(auth.verifyToken, userController.findUser)
- 
-  /** PUT /api/users/id - update users */
-  .put(auth.verifyToken, userController.updateUser)
- 
-  /** DELETE /api/users/id - delete users */
-  .delete(auth.verifyToken, userController.deleteUser);
- 
-router.route('/:id/documents')
-  /** GET /api/users/id/documents - Find documents of a specific user*/
-  .get(auth.verifyToken, userController.getUserDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html deleted file mode 100644 index 8ad3422..0000000 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ /dev/null @@ -1,1307 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/document.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers document.spec.js -

-
-
- 97.07% - Statements - 199/205 -
-
- 100% - Branches - 0/0 -
-
- 98.39% - Functions - 61/62 -
-
- 97.04% - Lines - 197/203 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -4151x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -1x -  -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Documents', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Document', () => {
-    it('should add a new document if the user is authenticated', (done) => {
-      const document = {
-        title: 'hey yo!',
-        content: 'Andela is really fun!!',
-        access: 'public',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('id');
-        expect(res.body.title).to.eql('hey yo!');
-        expect(res.body.content).to.eql('Andela is really fun!!');
-        expect(res.body.access).to.equal('public');
-        done();
-      });
-    });
- 
-    it('Should fail if document already exist', () => {
-      const document = {
-        title: 'John team',
-        content: 'eze goes to school',
-        access: 'public',
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body.message).to.eql('Document already exists');
-      });
-    });
-    it('should fail to add a new document if the user is not authenticated',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome !!!',
-        value: 'private',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('No token provided.');
-        done();
-      });
-    });
-    it('should fail to add a new document if the access field is missing',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome!!!',
-        access: '',
-        userId: 1,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('accessType is required');
-        done();
-      });
-    });
-    it('should fail to add a new document if the title field is missing',
-    (done) => {
-      const document = {
-        title: '',
-        content: 'Andela is really awesome!!!',
-        value: 'public',
-        userId: 2,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('Title is required');
-        done();
-      });
-    });
-    it('should fail to add a new document if the content field is missing',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: '',
-        value: 'public',
-        userId: 2,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('Content is required');
-        done();
-      });
-    });
-  });
- 
-  describe('/GET Documents', () => {
-    it('Should get all documents for the user that is authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.keys(['document', 'pagination']);
-        done();
-      });
-    });
-    it('should fail to get all documents if the user is not authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents/')
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).be.eql('No token provided.');
-        expect(res.body.success).to.eql(false);
-        done();
-      });
-    });
-    it('Should get all documents with correct limit as a query', (done) => {
-      const limit = 1;
-      request(server)
-        .get(`/api/v1/documents?limit=${limit}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-    it('Should get all documents with correct offset as a query', (done) => {
-      const offset = 0;
-      request(server)
-        .get(`/api/v1/documents?limit=${offset}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Document', () => {
-    it('Should fail to get document if it doesn`t exist', (done) => {
-      const documentId = 8;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-    it('Should get all public regardless of id', (done) => {
-      const documentId = 4;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(4);
-          expect(res.body.title).to.equal('hey yo!');
-          expect(res.body.access).to.equal('public');
-          done();
-        });
-    });
-    it('Should fail to get a private document if the requester does not own it',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a private document the where the requester is the owner',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.access).to.eql('private');
-          expect(res.body.title).to.eql('John naddddd');
-          expect(res.body.id).to.eql(2);
-          expect(res.body.userId).to.eql(2);
-          done();
-        });
-    });
-    it('Should fail get a role document if the users are not on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a role document if the users are on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-          done();
-        });
-    });
-    it('Should get a role document if the user is an admin', (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-        });
-      done();
-    });
-  });
- 
-  describe('/PUT/:id, Document', () => {
-    it('Should update a document by id if the user has the same id',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: userToken })
-          .send({ title: 'wreck it ralph' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.title).to.eql('wreck it ralph');
-            done();
-          });
-      });
-    it(`Should fail to update a document by
-      id if the user does not have the same id`,
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: sampleUserToken })
-          .send({ title: 'spiderman Homecoming' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to edit this document');
-            done();
-          });
-      });
-    it('Should not update a document by id if the user has admin access',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'wreck it' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            done();
-          });
-      });
-    it('Should fail to update a document by id if the document does not exist',
-      (done) => {
-        const id = 10;
-        request(server)
-        .put(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .send({ title: 'Deadpool' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-      });
-  });
- 
-  describe('DELETE/:id Document', () => {
-    it('Should delete a document if the user has admin access', (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should delete a document if the user is the owner', (done) => {
-      const id = 2;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should fail to delete the document given the user is not the owner',
-    (done) => {
-      const id = 1;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to delete this document');
-          done();
-        });
-    });
-    it('Should fail to delete if the document does not exist', (done) => {
-      const id = 234;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html deleted file mode 100644 index c8eef21..0000000 --- a/coverage/document-manager/server/test/controllers/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers - - - - - - - -
-
-

- All files document-manager/server/test/controllers -

-
-
- 96.98% - Statements - 611/630 -
-
- 100% - Branches - 0/0 -
-
- 98.45% - Functions - 190/193 -
-
- 96.95% - Lines - 603/622 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.spec.js
97.07%199/205100%0/098.39%61/6297.04%197/203
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
92.86%143/154100%0/095.83%46/4892.76%141/152
search.spec.js
100%58/58100%0/0100%19/19100%56/56
user.spec.js
99.05%209/211100%0/0100%64/6499.04%207/209
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html deleted file mode 100644 index c9ba712..0000000 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/mockData.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -541x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  Baas: {
-    fullName: 'Baas Bank',
-    userName: 'bank',
-    email: 'baas@test.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html deleted file mode 100644 index d917843..0000000 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ /dev/null @@ -1,935 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/role.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers role.spec.js -

-
-
- 92.86% - Statements - 143/154 -
-
- 100% - Branches - 0/0 -
-
- 95.83% - Functions - 46/48 -
-
- 92.76% - Lines - 141/152 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -2911x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Role', () => {
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'boromir' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-        expect(res.body.role).to.have.property('title').to.equal('boromir');
-      });
-      done();
-    });
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'king' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(204);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-      });
-      done();
-    });
-    it('Should fail if a non-admin wants to add a new role', (done) => {
-      const role = {
-        title: 'boromir-team'
-      };
-      request(server)
-        .post('/api/v1/roles/')
-        .set({ authorization: userToken })
-      .send(role)
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('You are not authorized');
-        done();
-      });
-    });
-  });
- 
-  describe('/GET Role', () => {
-    it('Should get all the roles if the user is an admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.length(5);
-          expect(res.body).to.be.a('array');
-          expect(res.body[0].id).to.eql(1);
-          expect(res.body[0].title).to.eql('admin');
-          expect(res.body[1].id).to.eql(2);
-          expect(res.body[1].title).to.eql('facilitator');
-          done();
-        });
-    });
-    it('Should fail to get the roles if the user is not admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql('You are not authorized');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Role', () => {
-    it('Should get a role by id if the user is an admin', (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).be.a('object');
-          expect(res.body.title).to.eql('facilitator');
-          expect(res.body.id).to.equal(2);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user is not an admin',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user enters an invalid input',
-    (done) => {
-      const id = 'fddjsdcdjn';
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql(`invalid input syntax for integer: "${id}"`);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the role does not exist', (done) => {
-      const id = 250;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body.message).to.eql('Role not found');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the id is out of range', (done) => {
-      const id = 500000000000000000000;
-      request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('out of range for type integer');
-          done();
-        });
-    });
-  });
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'boromir-team' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it(`Should fail to update a
-       role by id if the admin enters an invalid input`,
-      (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-      });
-    it(`Should fail to update a role by id if the
-       admin enters an id that is out range`, (done) => {
-      const id = 2000000000000000;
-      request(server)
-        .put(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .send({ title: 'regular' })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('out of range for type integer');
-          done();
-        });
-    });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.be.eql('Role deleted successfully');
-        });
-      done();
-    });
-    it('Should fail to delete a role given the user has no admin access',
-    (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it(`Should fail to delete a role
-      given the admin enters an id that is not found`,
-    (done) => {
-      const id = 300;
-      request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-    });
-    it(`Should fail to delete a role given the admin
-      enters an input that is out of range`, (done) => {
-      const id = 3000000000000000;
-      request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('out of range for type integer');
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html deleted file mode 100644 index 1af9d46..0000000 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ /dev/null @@ -1,383 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/search.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers search.spec.js -

-
-
- 100% - Statements - 58/58 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 19/19 -
-
- 100% - Lines - 56/56 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -1071x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow, Baas } = data;
- 
-describe('Search', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/SEARCH/users/?q={name}', () => {
-    it('Should return an error if no querystring is provided', (done) => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/users/?q=${query}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Invalid search input');
-          done();
-        });
-    });
-    it('Should return a search list response of the required search input',
-    (done) => {
-      const query = Baas.userName;
-      request(server)
-      .get(`/api/v1/search/users/?q=${query}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body.user[0].fullName).to.eql(Baas.fullName);
-        expect(res.body.user[0].userName).to.equal(Baas.userName);
-        done();
-      });
-    });
-  });
-  describe('/SEARCH/documents/?q=', () => {
-    it('Should return an error if no querystring is provided', (done) => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Invalid search input');
-          done();
-        });
-    });
-    it('Should return a search list of the required search input', (done) => {
-      const query = 'John';
-      request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body.document[0].title).to.equal('John Doe');
-          expect(res.body.document[0].content).to.equal('eze goes to school');
-          expect(res.body).to.have.property('pagination');
-          done();
-        });
-    });
-    it('Should throw an error if the searched document is not found',
-      (done) => {
-        const query = 'jk';
-        request(server)
-          .get(`/api/v1/search/documents/?q=${query}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body.message).to.equal('Document not found');
-            done();
-          });
-      });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html deleted file mode 100644 index e39f0a1..0000000 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ /dev/null @@ -1,1232 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/user.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers user.spec.js -

-
-
- 99.05% - Statements - 209/211 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 64/64 -
-
- 99.04% - Lines - 207/209 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -3901x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fakeBass, fellow, user1, user2 } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST User login', () => {
-    it('Should fail if the user enters incorrect crendentials upon login',
-    (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user1)
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. User not found.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('Should fail if the user provide a wrong password', (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user2)
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. Wrong password.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('should log in a user and return a token', (done) => {
-      request(server)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['success', 'token']);
-          expect(res.body.success).to.eql(true);
-          done();
-        });
-    });
- 
-    describe('/POST User Signup', () => {
-      it('should create a new user', (done) => {
-        request(server)
-          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body)
-              .to.have.keys(['message', 'success', 'userDetails']);
-            expect(res.body.success).to.eql(true);
-            expect(res.body.message)
-            .to.eql('You have successfully registered.');
-            done();
-          });
-      });
-    });
- 
-    describe('#GET Users', () => {
-      it('Should get all users if the user is an admin ', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body).to.have.keys(['user', 'pagination']);
-            done();
-          });
-      });
-      it('Should fail to get all users if the user has no admin access ',
-      (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('You are not authorized');
-            done();
-          });
-      });
-      it('Should fail to get all users if no token was provided', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            done();
-          });
-      });
-      it('Should get all users with correct limit as a query', (done) => {
-        const limit = 1;
-        chai.request(server)
-          .get(`/api/v1/users?limit=${limit}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.user[0].fullName).to.equal('Baas Bank');
-            expect(res.body.user[0].userName).to.equal('bank');
-            done();
-          });
-      });
-    });
-    describe('#GET User by Id', () => {
-      it('Should get a user if the user is an admin', (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).to.eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should get the user if the requested user is the current user',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should fail to get a user if an invalid input is entered',
-      (done) => {
-        const id = 'fddjsdcdjn';
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.property('message')
-            .to.eql(`invalid input syntax for integer: "${id}"`);
-            done();
-          });
-      });
-      it('should fail to get the user if the requester is not the owner',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`api/users/${id}`)
-          .set({ authorization: sampleUserToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.keys(['message']);
-            expect(res.body.message).to.eql('Unauthorized access');
-          });
-        done();
-      });
-      it('Should fail to get a user if the user does not exist',
-      (done) => {
-        const id = 250;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.have.property('message');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get a user if the id is out of range',
-      (done) => {
-        const id = 500000000000000000;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.have.property('message')
-            .to.equal('out of range');
-            done();
-          });
-      });
-    });
-    describe('#PUT Update user by Id', () => {
-      it('Should update a user`s full name if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ fullName: 'jake doe' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.fullName).to.eql('jake doe');
-              done();
-            });
-        });
-      it('Should update a user`s email if the user has the same id', (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.email).to.eql('jakedoe@andela.com');
-            done();
-          });
-      });
-      it('Should update a user`s username if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ userName: 'jakedoe12' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.userName).to.eql('jakedoe12');
-              done();
-            });
-        });
-      it(`Should fail to update a user's
-      details if the user does not have the same user id`,
-      (done) => {
-        const id = 3;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-      it(`Should fail to update a user's
-        details if the user enters an invalid user id`,
-      (done) => {
-        const id = 2302;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-    });
-    describe('#DELETE /:id Users', () => {
-      it('Should delete a user given the user has admin access', (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(204);
-            done();
-          });
-      });
-      it('Should fail to delete a user if the user has no admin access',
-      (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this field');
-            done();
-          });
-      });
-      it('Should give a User not found if user don\'t exist', (done) => {
-        const id = 23;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-    });
-    describe('/GET/users/:id/documents Documents', () => {
-      it('Should fail to get documents if the user does not exist', (done) => {
-        const userId = 9;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get documents if there is no token present',
-      (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            expect(res.body.success).to.eql(false);
-            done();
-          });
-      });
-      it('Should get documents for the user with its unique userId', (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('object');
-            expect(res.body.document[1].userId).to.eql(2);
-            expect(res.body.document[1].title).to.eql('hey yo!');
-            expect(res.body.document[1].content)
-            .to.eql('Andela is really fun!!');
-            done();
-          });
-      });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/index.html b/coverage/index.html deleted file mode 100644 index d3d8787..0000000 --- a/coverage/index.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - Code coverage report for All files - - - - - - - -
-
-

- All files -

-
-
- 86.41% - Statements - 267/309 -
-
- 81.02% - Branches - 111/137 -
-
- 73% - Functions - 73/100 -
-
- 86.32% - Lines - 265/307 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document-manager
100%3/3100%2/2100%1/1100%3/3
document-manager/server/config
100%17/17100%2/2100%2/2100%16/16
document-manager/server/controllers
81.48%176/21681.03%94/11667.86%57/8481.48%176/216
document-manager/server/helpers
100%3/3100%0/0100%1/1100%2/2
document-manager/server/middlewares
91.67%11/1287.5%7/8100%3/391.67%11/12
document-manager/server/models
97.44%38/3966.67%6/9100%9/997.44%38/39
document-manager/server/routes
100%19/19100%0/0100%0/0100%19/19
-
-
- - - - - - - diff --git a/coverage/prettify.css b/coverage/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js deleted file mode 100644 index ef51e03..0000000 --- a/coverage/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png deleted file mode 100644 index 03f704a609c6fd0dbfdac63466a7d7c958b5cbf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jii$m5978H@?Fn+^JD|Y9yzj{W`447Gxa{7*dM7nnnD-Lb z6^}Hx2)
'; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function (a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function (a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i =0 ; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); From 57ea8972db20080a1d11f6a7388be7f6dbf5113e Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:25:52 +0100 Subject: [PATCH 45/98] remove coverage --- coverage/auth.spec.js.html | 383 ----- coverage/base.css | 212 --- coverage/document-manager/index.html | 93 -- coverage/document-manager/index.js.html | 92 -- .../server/config/config.js.html | 140 -- .../server/config/express.js.html | 155 -- .../document-manager/server/config/index.html | 106 -- .../server/controllers/documents.js.html | 743 ---------- .../server/controllers/index.html | 132 -- .../server/controllers/roles.js.html | 464 ------ .../server/controllers/search.js.html | 452 ------ .../server/controllers/searches.js.html | 440 ------ .../server/controllers/users.js.html | 914 ------------ .../server/helpers/helper.js.html | 89 -- .../server/helpers/index.html | 93 -- .../server/middlewares/auth.js.html | 170 --- .../server/middlewares/index.html | 93 -- .../server/models/document.js.html | 149 -- .../document-manager/server/models/index.html | 132 -- .../server/models/index.js.html | 200 --- .../server/models/role.js.html | 113 -- .../server/models/user.js.html | 182 --- .../server/routes/documents.js.html | 137 -- .../document-manager/server/routes/index.html | 145 -- .../server/routes/index.js.html | 113 -- .../server/routes/roles.js.html | 137 -- .../server/routes/search.js.html | 110 -- .../server/routes/searches.js.html | 110 -- .../server/routes/users.js.html | 161 -- .../test/controllers/document.spec.js.html | 1307 ----------------- .../server/test/controllers/index.html | 145 -- .../server/test/controllers/mockData.js.html | 224 --- .../server/test/controllers/role.spec.js.html | 977 ------------ .../test/controllers/search.spec.js.html | 389 ----- .../server/test/controllers/user.spec.js.html | 1232 ---------------- .../server/test/document.spec.js.html | 1139 -------------- .../document-manager/server/test/index.html | 145 -- .../server/test/index.spec.js.html | 89 -- .../server/test/middlewares/auth.spec.js.html | 383 ----- .../server/test/middlewares/index.html | 93 -- .../server/test/mockData.js.html | 197 --- .../document-manager/server/test/role.js.html | 950 ------------ .../server/test/role.spec.js.html | 980 ------------ .../server/test/search.spec.js.html | 371 ----- .../server/test/user.spec.js.html | 1235 ---------------- coverage/gulpfile.babel.js.html | 182 --- coverage/index.html | 184 --- coverage/mockData.js.html | 197 --- coverage/prettify.css | 1 - coverage/prettify.js | 1 - coverage/sort-arrow-sprite.png | Bin 209 -> 0 bytes coverage/sorter.js | 158 -- coverage/user.spec.js.html | 179 --- 53 files changed, 17218 deletions(-) delete mode 100644 coverage/auth.spec.js.html delete mode 100644 coverage/base.css delete mode 100644 coverage/document-manager/index.html delete mode 100644 coverage/document-manager/index.js.html delete mode 100644 coverage/document-manager/server/config/config.js.html delete mode 100644 coverage/document-manager/server/config/express.js.html delete mode 100644 coverage/document-manager/server/config/index.html delete mode 100644 coverage/document-manager/server/controllers/documents.js.html delete mode 100644 coverage/document-manager/server/controllers/index.html delete mode 100644 coverage/document-manager/server/controllers/roles.js.html delete mode 100644 coverage/document-manager/server/controllers/search.js.html delete mode 100644 coverage/document-manager/server/controllers/searches.js.html delete mode 100644 coverage/document-manager/server/controllers/users.js.html delete mode 100644 coverage/document-manager/server/helpers/helper.js.html delete mode 100644 coverage/document-manager/server/helpers/index.html delete mode 100644 coverage/document-manager/server/middlewares/auth.js.html delete mode 100644 coverage/document-manager/server/middlewares/index.html delete mode 100644 coverage/document-manager/server/models/document.js.html delete mode 100644 coverage/document-manager/server/models/index.html delete mode 100644 coverage/document-manager/server/models/index.js.html delete mode 100644 coverage/document-manager/server/models/role.js.html delete mode 100644 coverage/document-manager/server/models/user.js.html delete mode 100644 coverage/document-manager/server/routes/documents.js.html delete mode 100644 coverage/document-manager/server/routes/index.html delete mode 100644 coverage/document-manager/server/routes/index.js.html delete mode 100644 coverage/document-manager/server/routes/roles.js.html delete mode 100644 coverage/document-manager/server/routes/search.js.html delete mode 100644 coverage/document-manager/server/routes/searches.js.html delete mode 100644 coverage/document-manager/server/routes/users.js.html delete mode 100644 coverage/document-manager/server/test/controllers/document.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/index.html delete mode 100644 coverage/document-manager/server/test/controllers/mockData.js.html delete mode 100644 coverage/document-manager/server/test/controllers/role.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/search.spec.js.html delete mode 100644 coverage/document-manager/server/test/controllers/user.spec.js.html delete mode 100644 coverage/document-manager/server/test/document.spec.js.html delete mode 100644 coverage/document-manager/server/test/index.html delete mode 100644 coverage/document-manager/server/test/index.spec.js.html delete mode 100644 coverage/document-manager/server/test/middlewares/auth.spec.js.html delete mode 100644 coverage/document-manager/server/test/middlewares/index.html delete mode 100644 coverage/document-manager/server/test/mockData.js.html delete mode 100644 coverage/document-manager/server/test/role.js.html delete mode 100644 coverage/document-manager/server/test/role.spec.js.html delete mode 100644 coverage/document-manager/server/test/search.spec.js.html delete mode 100644 coverage/document-manager/server/test/user.spec.js.html delete mode 100644 coverage/gulpfile.babel.js.html delete mode 100644 coverage/index.html delete mode 100644 coverage/mockData.js.html delete mode 100644 coverage/prettify.css delete mode 100644 coverage/prettify.js delete mode 100644 coverage/sort-arrow-sprite.png delete mode 100644 coverage/sorter.js delete mode 100644 coverage/user.spec.js.html diff --git a/coverage/auth.spec.js.html b/coverage/auth.spec.js.html deleted file mode 100644 index 0bf1156..0000000 --- a/coverage/auth.spec.js.html +++ /dev/null @@ -1,383 +0,0 @@ - - - - Code coverage report for auth.spec.js - - - - - - - -
-
-

- All files auth.spec.js -

-
-
- 12.5% - Statements - 8/64 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/20 -
-
- 12.7% - Lines - 8/63 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -1071x -1x -1x -1x -1x -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
process.NODE_ENV = 'test';
-const chai = require('chai');
-require('dotenv').config();
-const chaiHttp = require('chai-http');
-const expect = chai.expect;
-const EventEmitter = require('events').EventEmitter;
-const httpMocks = require('node-mocks-http');
-const samples = require('../apiEndpoints/mockdata');
-const server = require('../../../index');
-const auth = require('../../middlewares/auth');
- 
-chai.use(chaiHttp);
-let adminToken, userToken;
-describe('Authentication', () => {
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'johnbosco.ohia@andela.com', password: process.env.PASSWORD })
-      .end((err, res) => {
-        adminToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'testdoe@andela.com', password: 'jamestest' })
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('VerifyToken', () => {
-    it('Should check if the token is provided with request', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents',
-      });
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.verifyToken(request, response, nextCallBack);
-      expect(response._getData().message).to.equal('No token provided.');
-      done();
-    });
-  it('Should provide access if the token is provided and valid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents',
-      headers: { 'x-access-token': adminToken }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
-    expect(response._getData().message).to.equal(undefined);
-    done();
-  });
-  it('Should deny access if the token is invalid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents/',
-      headers: { 'x-access-token': 'themaniscoming' }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
- 
-    response.on('end', () => {
-      expect(response._getData().success).to.equal(false);
-    });
-    done();
-  });
-  });
-  describe('AdminAcess', () => {
-    it('Should deny access if the user is not admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': userToken }
-      });
-      request.decoded = { roleId: 2 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal('You are not authorized');
-      });
-      done();
-    });
-    it('Should grant access if the user is an admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': adminToken }
-      });
-      request.decoded = { roleId: 1 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal(undefined);
-      });
-      done();
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/base.css b/coverage/base.css deleted file mode 100644 index 417c7ad..0000000 --- a/coverage/base.css +++ /dev/null @@ -1,212 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } - -.cbranch-no { background: yellow !important; color: #111; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/document-manager/index.html b/coverage/document-manager/index.html deleted file mode 100644 index 7ae7336..0000000 --- a/coverage/document-manager/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager - - - - - - - -
-
-

- All files document-manager -

-
-
- 100% - Statements - 4/4 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 4/4 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
index.js
100%4/4100%2/2100%1/1100%4/4
-
-
- - - - - - - diff --git a/coverage/document-manager/index.js.html b/coverage/document-manager/index.js.html deleted file mode 100644 index 73226f2..0000000 --- a/coverage/document-manager/index.js.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Code coverage report for document-manager/index.js - - - - - - - -
-
-

- All files / document-manager index.js -

-
-
- 100% - Statements - 4/4 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 4/4 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -101x -  -1x -  -1x -1x -  -  -  - 
import app from './server/config/express';
- 
-const port = process.env.PORT || 3000;
- 
-const server = app.listen(port, () => {
-  console.log('API Server started and listening on port 3000');
-});
- 
-export default server;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/config.js.html b/coverage/document-manager/server/config/config.js.html deleted file mode 100644 index b11456a..0000000 --- a/coverage/document-manager/server/config/config.js.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - Code coverage report for document-manager/server/config/config.js - - - - - - - -
-
-

- All files / document-manager/server/config config.js -

-
-
- 100% - Statements - 1/1 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 1/1 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -261x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
module.exports = {
-  development: {
-    username: 'andeladeveloper',
-    password: null,
-    database: 'docmanager-dev',
-    host: '127.0.0.1',
-    port: 5432,
-    dialect: 'postgres'
-  },
-  test: {
-    username: 'andeladeveloper',
-    password: null,
-    database: 'docmanager-test',
-    host: '127.0.0.1',
-    port: 5432,
-    dialect: 'postgres'
-  },
-  production: {
-    username: 'root',
-    password: null,
-    database: 'database_production',
-    host: '127.0.0.1',
-    dialect: 'postgres'
-  }
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/express.js.html b/coverage/document-manager/server/config/express.js.html deleted file mode 100644 index cd76966..0000000 --- a/coverage/document-manager/server/config/express.js.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - Code coverage report for document-manager/server/config/express.js - - - - - - - -
-
-

- All files / document-manager/server/config express.js -

-
-
- 100% - Statements - 20/20 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 19/19 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -311x -1x -1x -1x -1x -  -1x -  -1x -  -1x -1x -1x -  -1x -81x -81x -81x -112x -110x -110x -  -81x -  -  -  -1x -  -  -  - 
import express from 'express';
-import bodyParser from 'body-parser';
-import logger from 'morgan';
-import expressValidator from 'express-validator';
-import routes from '../routes';
- 
-const app = express();
- 
-app.use(logger('dev'));
- 
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: false }));
-app.use(expressValidator());
- 
-app.use((req, res, next) => {
-  const send = res.send;
-  let sent = false;
-  res.send = (data) => {
-    if (sent) return;
-    send.bind(res)(data);
-    sent = true;
-  };
-  next();
-});
- 
-// mount all routes on /api path
-app.use('/api/v1', routes);
- 
- 
-export default app;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/config/index.html b/coverage/document-manager/server/config/index.html deleted file mode 100644 index 56b2834..0000000 --- a/coverage/document-manager/server/config/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - Code coverage report for document-manager/server/config - - - - - - - -
-
-

- All files document-manager/server/config -

-
-
- 100% - Statements - 21/21 -
-
- 100% - Branches - 2/2 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 20/20 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
config.js
100%1/1100%0/0100%0/0100%1/1
express.js
100%20/20100%2/2100%2/2100%19/19
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/documents.js.html b/coverage/document-manager/server/controllers/documents.js.html deleted file mode 100644 index 16fc973..0000000 --- a/coverage/document-manager/server/controllers/documents.js.html +++ /dev/null @@ -1,743 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/documents.js - - - - - - - -
-
-

- All files / document-manager/server/controllers documents.js -

-
-
- 79.71% - Statements - 55/69 -
-
- 85.71% - Branches - 36/42 -
-
- 60% - Functions - 15/25 -
-
- 79.71% - Lines - 55/69 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -2271x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -  -5x -5x -5x -  -5x -  -5x -4x -  -1x -  -  -  -  -1x -1x -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -4x -  -  -4x -4x -  -4x -1x -  -  -  -3x -2x -  -  -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -6x -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -7x -  -7x -1x -  -7x -1x -  -6x -1x -  -4x -2x -1x -  -  -  -1x -  -2x -2x -  -  -2x -  -  -1x -  -  -  -1x -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -4x -  -4x -1x -  -  -  -3x -  -  -  -1x -  -  -  -2x -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const User = models.User;
-const Document = models.Document;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Create documents for users
- * @param {object} req - document to be created
- * @param {object} res - created document
- * @returns {object} - created document
- */
-function createDocument(req, res) {
-  req.check('title', 'Title is required').notEmpty();
-  req.check('content', 'Content is required').notEmpty();
-  req.check('access', 'accessType is required').notEmpty();
- 
-  const errors = req.validationErrors();
- 
-  if (errors) {
-    res.status(400).json({ errors });
-  } else {
-    Document.findAll({
-      where: {
-        title: req.body.title
-      }
-    }).then((document) => {
-      Eif (document.length === 0) {
-        return Document.create({
-          title: req.body.title,
-          content: req.body.content,
-          access: req.body.value,
-          userId: req.body.userId
-        })
-      .then(documentResponse => res.status(200).send(documentResponse))
-      .catch(error => res.status(400).send(error));
-      }
-      return res.status(403).json({
-        message: 'Document already exists'
-      });
-    }).catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
- * Update user document.
- * @param {number} req - request id of the document to be updated
- * @param {object} res - object of the updated document
- * @returns {object} - updated document
- */
-function updateDocument(req, res) {
-  Iif (isNaN(req.params.id)) {
-    return res.status(400);
-  }
-  const docId = Number(req.params.id);
-  return Document.findById(docId)
-    .then((document) => {
-      if (!document) {
-        return res.status(404).send({
-          message: 'Document Not Found'
-        });
-      }
-      if (Number(document.userId) !== Number(req.decoded.id)) {
-        return res.status(401).json({
-          message: 'You are not authorized to edit this document'
-        });
-      }
-      return document
-        .update({
-          title: req.body.title || document.title,
-          content: req.body.content || document.content,
-          access: req.body.value || document.access,
-          userId: req.body.userId || document.userId
-        })
-        .then(() => res.status(200).send(document))
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-/**
- *  Get all documents
- * @param {object} req - contains an object of the query, limits and offset
- * @param {array} res - array of documents with pagination
- * @returns {array} - array of documents
- */
-function getAllDocument(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  Iif (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else Eif (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
-   * Find a document by Id
-   * @param {number} req - id of the requested document
-   * @param {object} res - object containg the requested document
-   * @returns {object} requested document
-   */
-function findDocument(req, res) {
-  return Document.findById(req.params.id)
-    .then((document) => {
-      if (!document) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      if (req.decoded.roleId === 1) {
-        return document;
-      }
-      if (document.access === 'public') {
-        return res.status(200).send(document);
-      }
-      if (document.access === 'private') {
-        if (document.userId !== req.decoded.id) {
-          return res.status(401).json({
-            message: 'You are not authorized to view this document'
-          });
-        }
-        return res.status(200).send(document);
-      }
-      Eif (document.access === 'role') {
-        return models.User
-          .findById(document.userId)
-          .then((documentOwner) => {
-            if (
-              Number(documentOwner.roleId) !== Number(req.decoded.roleId)
-            ) {
-              return res.status(401).json({
-                message: 'You are not authorized to view this document'
-              });
-            }
-            return res.status(200).send(document);
-          })
-          .catch(error => res.status(400).send(error));
-      }
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Delete a document by Id
- * @param {number} req - id of the requested document
- * @param {object} res - message
- * @returns {object} - message
- */
-function deleteDocument(req, res) {
-  return Document.findById(req.params.id)
-    .then((document) => {
-      if (!document) {
-        return res.status(404).send({
-          message: 'Document Not Found'
-        });
-      }
-      if (
-        req.decoded.roleId !== 1 &&
-        Number(document.userId) !== Number(req.decoded.id)
-      ) {
-        return res.status(401).json({
-          message: 'You are not authorized to delete this document'
-        });
-      }
-      return document
-        .destroy()
-        .then(() => res.status(204).send({
-          message: 'Document successfully deleted'
-        }))
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-export default {
-  createDocument,
-  updateDocument,
-  getAllDocument,
-  findDocument,
-  deleteDocument };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/index.html b/coverage/document-manager/server/controllers/index.html deleted file mode 100644 index 869ce22..0000000 --- a/coverage/document-manager/server/controllers/index.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers - - - - - - - -
-
-

- All files document-manager/server/controllers -

-
-
- 80.95% - Statements - 187/231 -
-
- 80.17% - Branches - 93/116 -
-
- 65.48% - Functions - 55/84 -
-
- 80.95% - Lines - 187/231 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
documents.js
79.71%55/6985.71%36/4260%15/2579.71%55/69
roles.js
72.5%29/4066.67%12/1866.67%14/2172.5%29/40
search.js
82.86%29/3571.43%10/1462.5%5/882.86%29/35
users.js
85.06%74/8783.33%35/4270%21/3085.06%74/87
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/roles.js.html b/coverage/document-manager/server/controllers/roles.js.html deleted file mode 100644 index 09611f8..0000000 --- a/coverage/document-manager/server/controllers/roles.js.html +++ /dev/null @@ -1,464 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/roles.js - - - - - - - -
-
-

- All files / document-manager/server/controllers roles.js -

-
-
- 72.5% - Statements - 29/40 -
-
- 66.67% - Branches - 12/18 -
-
- 66.67% - Functions - 14/21 -
-
- 72.5% - Lines - 29/40 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -1341x -  -1x -  -  -  -  -  -  -  -  -3x -  -3x -3x -  -  -3x -  -  -2x -2x -  -  -2x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -1x -  -1x -  -  -  -  -  -  -  -  -  -  -3x -1x -  -  -  -2x -  -  -2x -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -2x -  -  -  -2x -  -  -2x -1x -  -  -  -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -1x -  -1x -  -  -  -  -1x -  -  -  -  -1x -  -  -  -  - 
const models = require('../models');
- 
-const Role = models.Role;
- 
-/**
- * Creates a new Role.
- * @param {object} req - role to be created
- * @param {object} res - new created role
- * @returns {object} - newly created role
- */
-function createRole(req, res) {
-  req.check('title', 'Title is required').notEmpty();
- 
-  const errors = req.validationErrors();
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    Role.findAll({
-      where: { title: req.body.title }
-    }).then((err, existingRole) => {
-      Eif (!existingRole) {
-        Role.create({
-          title: req.body.title
-        }).then((role) => {
-          res.status(201).send({
-            message: 'Role successfully created',
-            role
-          });
-        }).catch((error) => {
-          res.json(error.errors);
-        });
-      }
-    }).catch(error => res.json(error));
-  }
-}
- 
-/**
- * Get all roles.
- * @param {void} req - no request body attached
- * @param {array} res - an array of roles and their id
- * @returns {array} array of roles
- */
-function getRoles(req, res) {
-  return Role
-    .findAll()
-    .then(role => res.status(200).json(role))
-    .catch(error => res.json(error));
-}
- 
-/**
- * Find roles by Id.
- * @param {number} req - requested role
- * @param {object} res - role found by id
- * @returns {object} - role found by id
- */
-function findRole(req, res) {
-  if (isNaN(req.params.id)) {
-    return res.status(401).json({
-      message: `invalid input syntax for integer: "${req.params.id}"`
-    });
-  } else {
-    Role
-      .findById(req.params.id)
-      .then((role) => {
-        if (!role) {
-          return res.status(404).json({
-            message: 'Role not found'
-          });
-        }
-        res.status(200).json(role);
-      }).catch(error => res.status(400).json(error));
-  }
-}
- 
-/**
- * Update role.
- * @param {number} req - requested role by id
- * @param {object} res - updated role
- * @returns {object} - updated role status
- */
-function updateRole(req, res) {
-  Iif (req.decoded.roleId !== 1) {
-    return res.status(401)
-      .json({ message: 'You are not authorized to access the role' });
-  }
-  return Role
-    .findById(req.params.id)
-    .then((role) => {
-      if (!role) {
-        return res.status(404).json({
-          message: 'Role not found'
-        });
-      }
-      return role
-        .update({
-          title: req.body.title || role.title
-        })
-        .then(() => res.status(200).json({
-          message: 'Role updated successfully',
-          role
-        }))
-        .catch(error => res.status(400).json(error));
-    }).catch(error => res.status(400).json(error));
-}
- 
-/**
- * Delete roles by Id.
- * @param {number} req - role to be deleted by id
- * @param {object} res - deleted role
- * @returns {object} - message
- */
-function deleteRole(req, res) {
-  Iif (req.decoded.roleId !== 1) {
-    return res.status(401)
-      .json({ message: 'You are not authorized to access the role' });
-  }
-  return Role.findById(req.params.id)
-    .then((role) => {
-      Iif (!role) {
-        res.status(404).json({
-          message: 'Role not found'
-        });
-      }
-      return role
-        .destroy()
-        .then(() => res.status(204).send({
-          message: 'Role deleted successfully'
-        }))
-          .catch(error => res.status(400).send(error));
-    }).catch(error => res.json(error));
-}
- 
-export default { createRole, getRoles, findRole, updateRole, deleteRole };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/search.js.html b/coverage/document-manager/server/controllers/search.js.html deleted file mode 100644 index f645d1b..0000000 --- a/coverage/document-manager/server/controllers/search.js.html +++ /dev/null @@ -1,452 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/search.js - - - - - - - -
-
-

- All files / document-manager/server/controllers search.js -

-
-
- 82.86% - Statements - 29/35 -
-
- 71.43% - Branches - 10/14 -
-
- 62.5% - Functions - 5/8 -
-
- 82.86% - Lines - 29/35 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -1301x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -  -2x -2x -2x -2x -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -2x -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -3x -3x -3x -1x -  -  -  -2x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -1x -  -  -  -  -1x -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Search for user using a query string
- * @param {string} req - search query of string
- * @param {array} res - array of users
- * @returns {array} - array users searched
- */
-function searchUser(req, res) {
-  const searchQuery = req.query.q,
-    limit = req.query.limit,
-    offset = req.query.offset;
-  if (!searchQuery) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  return User
-  .findAndCountAll({
-    limit,
-    offset,
-    attributes: { exclude: ['password'] },
-    where: {
-      userName: {
-        $like: `%${searchQuery}%`,
-      }
-    }
-  }).then(({ rows: user, count }) => {
-    Iif (count === 0) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  }).catch(error => res.status(400).send(error));
-}
- 
-/**
-   *
-   * Search for documents by title
-   * @param {string} req - an object containing the query, offset and limit
-   * @param {array} res - an array containing searched document
-   * @returns {array} - searched document
-   */
-function searchDocuments(req, res) {
-  const limit = req.query.limit,
-    offset = req.query.offset,
-    queryString = req.query.q;
-  if (!queryString) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  if (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      Iif (count === 0) {
-        return res.status(404).json({
-          message: 'Document not found'
-        });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else Eif (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      Eif (count === 0) {
-        return res.status(404).json({
-          message: 'Document not found'
-        });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-export default { searchUser, searchDocuments };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/searches.js.html b/coverage/document-manager/server/controllers/searches.js.html deleted file mode 100644 index 029411e..0000000 --- a/coverage/document-manager/server/controllers/searches.js.html +++ /dev/null @@ -1,440 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/searches.js - - - - - - - -
-
-

- All files / document-manager/server/controllers searches.js -

-
-
- 14.29% - Statements - 5/35 -
-
- 0% - Branches - 0/14 -
-
- 0% - Functions - 0/8 -
-
- 14.29% - Lines - 5/35 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -1261x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import helper from '../helpers/helper';
-import models from '../models';
- 
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Search for user using a query string
- * @param {string} req - search query of string
- * @param {array} res - array of users
- * @returns {array} - array users searched
- */
-function searchUser(req, res) {
-  const searchQuery = req.query.q,
-    limit = req.query.limit,
-    offset = req.query.offset;
-  if (!searchQuery) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  return User
-  .findAndCountAll({
-    limit,
-    offset,
-    attributes: { exclude: ['password'] },
-    where: {
-      userName: {
-        $like: `%${searchQuery}%`,
-      }
-    }
-  }).then(({ rows: user, count }) => {
-    if (count === 0) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  }).catch(error => res.status(400).send(error));
-}
- 
-/**
-   *
-   * Search for documents by title
-   * @param {string} req - an object containing the query, offset and limit
-   * @param {array} res - an array containing searched document
-   * @returns {array} - searched document
-   */
-function searchDocuments(req, res) {
-  const limit = req.query.limit,
-    offset = req.query.offset,
-    queryString = req.query.q;
-  if (!queryString) {
-    return res.status(400).json({
-      message: 'Invalid search input'
-    });
-  }
-  if (req.decoded.roleId === 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId']
-        }
-      ]
-    })
-    .then(({ rows: document, count }) => {
-      if (count === 0) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  } else if (req.decoded.roleId !== 1) {
-    return Document.findAndCountAll({
-      limit,
-      offset,
-      include: [
-        {
-          model: User,
-          attributes: ['userName', 'roleId'],
-          where: {
-            roleId: req.decoded.roleId
-          },
-        },
-      ],
-      where: {
-        access: {
-          $ne: 'private'
-        },
-        title: {
-          $like: `%${queryString}%`
-        }
-      },
- 
-    })
-    .then(({ rows: document, count }) => {
-      if (count === 0) {
-        res.status(404).json({ message: 'Document not found' });
-      }
-      res.status(200).send({
-        document,
-        pagination: metaData(count, limit, offset),
-      });
-    })
-    .catch(error => res.status(400).send(error));
-  }
-}
- 
-export default { searchUser, searchDocuments };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/controllers/users.js.html b/coverage/document-manager/server/controllers/users.js.html deleted file mode 100644 index 7811f53..0000000 --- a/coverage/document-manager/server/controllers/users.js.html +++ /dev/null @@ -1,914 +0,0 @@ - - - - Code coverage report for document-manager/server/controllers/users.js - - - - - - - -
-
-

- All files / document-manager/server/controllers users.js -

-
-
- 85.06% - Statements - 74/87 -
-
- 83.33% - Branches - 35/42 -
-
- 70% - Functions - 21/30 -
-
- 85.06% - Lines - 74/87 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -2841x -1x -  -1x -1x -  -1x -  -1x -1x -1x -1x -  -  -  -  -  -  -  -  -2x -2x -2x -  -  -  -  -  -4x -2x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -1x -1x -1x -  -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -15x -15x -15x -  -15x -  -15x -  -  -15x -  -  -  -15x -15x -1x -  -  -14x -14x -  -13x -  -  -  -  -  -  -13x -  -  -13x -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -5x -5x -  -  -  -  -5x -1x -  -  -  -4x -  -  -  -  -  -  -  -3x -1x -  -3x -  -1x -  -  -  -  -  -  -  -  -  -5x -2x -  -  -  -3x -3x -3x -3x -  -  -3x -  -  -3x -  -  -  -  -  -  -  -  -3x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -3x -1x -  -  -  -2x -  -  -2x -1x -  -1x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -2x -2x -  -2x -1x -  -  -  -1x -  -  -  -  -  -  -2x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import bcrypt from 'bcrypt';
-import jwt from 'jsonwebtoken';
- 
-import helper from '../helpers/helper';
-import models from '../models';
- 
-require('dotenv').config();
- 
-const jwtSecret = process.env.JWT_SECRET;
-const Document = models.Document;
-const User = models.User;
-const metaData = helper.paginationMetaData;
- 
-/**
- * Get all users
- * @param {number} req - limit and offset for getting all user
- * @param {array} res - array of users or error
- * @returns {array} - an array of users
- */
-function getUsers(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  return User
-  .findAndCountAll(
-    { limit,
-      offset,
-      attributes: { exclude: ['password'] }
-    })
-  .then(({ rows: user, count }) => {
-    res.status(200).send({
-      user,
-      pagination: metaData(count, limit, offset)
-    });
-  })
-  .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Create a user
- * @param {object} req - request from user
- * @param {object} res - newly created user or error
- * @returns {object} - an object of a created user
- */
-function createUser(req, res) {
-  req.check('fullName', 'FullName is required').notEmpty();
-  req.check('userName', 'userName is required').notEmpty();
-  req.check('email', 'Email is required').notEmpty();
-  req.check('email', 'Please put a valid email').isEmail();
-  req.check('password', 'Password is required').notEmpty();
-  req.check('password', 'Password must be a mininum of 4 character')
-  .isLength(4, 50);
-  const errors = req.validationErrors();
- 
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    User.findAll({
-      where: { email: req.body.email }
-    }).then((err, user) => {
-      Eif (!user) {
-        User.create({
-          fullName: req.body.fullName,
-          userName: req.body.userName,
-          email: req.body.email,
-          password: bcrypt.hashSync(req.body.password, bcrypt.genSaltSync(10)),
-          roleId: req.body.roleId || 2
-        }).then((userDetails) => {
-          res.status(200).json({
-            userDetails,
-            success: true,
-            message: 'You have successfully registered.'
-          });
-        }).catch((error) => {
-          res.status(400).json(error);
-        });
-      }
-    });
-  }
-}
- 
-/**
- * Log In user with JWT
- * @param {object} req - request from log in user
- * @param {object} res - authenicated user details
- * @returns {object} - an object of the logged in user and a token
- */
-function login(req, res) {
-  req.check('email', 'Email is required').notEmpty();
-  req.check('email', 'Please put a valid email').isEmail();
-  req.check('password', 'Password is required').notEmpty();
- 
-  const errors = req.validationErrors();
- 
-  Iif (errors) {
-    res.status(400).json({ errors });
-  } else {
-    User.findAll({
-      where: { email: req.body.email }
-    })
-    .then((user) => {
-      const existingUser = user[0];
-      if (!existingUser) {
-        res.status(400).json({
-          success: false,
-          message: 'Authentication failed. User not found.' });
-      } else Eif (existingUser) {
-        if (bcrypt.compareSync(req.body.password, existingUser.password)) {
-          const payLoad = (
-            {
-              email: existingUser.email,
-              id: existingUser.id,
-              fullName: existingUser.fullName,
-              roleId: existingUser.roleId,
-            }
-          );
-          const token = jwt.sign(payLoad, jwtSecret, {
-            expiresIn: 60 * 60 * 24
-          });
-          res.status(201).json({
-            success: true,
-            token,
-          });
-        } else {
-          res.status(401).json({
-            success: false,
-            message: 'Authentication failed. Wrong password.'
-          });
-        }
-      }
-    }).catch(error => res.status(400).send(error));
-  }
-}
- 
-/**
- * Find a user by Id
- * @param {number} req - request for user using the id of the user
- * @param {object} res - an object of the user(s) found or error
- * @returns {object} - an object of found user
- */
-function findUser(req, res) {
-  const userQuery = Number(req.params.id);
-  Iif ((req.decoded.id !== userQuery) && (req.decoded.roleId !== 1)) {
-    return res.status(401).json({
-      message: 'Unauthorized Access'
-    });
-  }
-  if (isNaN(userQuery)) {
-    return res.status(401).json({
-      message: `invalid input syntax for integer: "${req.params.id}"`
-    });
-  }
-  return User
-    .findAll({
-      where: {
-        id: req.params.id,
-      },
-      attributes: { exclude: ['password'] }
-    })
-    .then((user) => {
-      if (!user.length) {
-        res.status(404).json({ message: 'User not found' });
-      }
-      res.status(200).send(user);
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-/**
- *Update a user by Id
- * @param {object} req - updated user object
- * @param {object} res - updated user object or error
- * @returns {object} - return an object of the updated user
- */
-function updateUser(req, res) {
-  if (Number(req.decoded.id) !== Number(req.params.id)) {
-    return res.status(401).json({
-      message: 'You are not authorized to access this user'
-    });
-  }
-  const userId = Number(req.params.id);
-  bcrypt.genSalt(10, (err, salt) => {
-    bcrypt.hash(req.body.password, salt, (err, hash) => {
-      User
-      .findById(userId)
-      .then((user) => {
-        Iif (!user) {
-          return res.status(404).json({ message: 'User not found' });
-        }
-        return user
-          .update({
-            fullName: req.body.fullName || user.fullName,
-            userName: req.body.userName || user.userName,
-            email: req.body.email || user.email,
-            password: hash || user.password,
-            roleId: req.body.roleId || user.roleId
-          })
-          .then((updatedUser) => {
-            res.status(200).send({
-              id: updatedUser.id,
-              fullName: updatedUser.fullName,
-              userName: updatedUser.userName,
-              email: updatedUser.email,
-              roleId: updatedUser.roleId,
-              message: 'Details successfully updated.'
-            });
-          })
-          .catch(error => res.status(400).send(error));
-      })
-      .catch(error => res.status(400).send(error));
-    });
-  });
-}
- 
-/**
- * Delete a user by Id
- * @param {number} req - delete user with an id
- * @param {object} res - message
- * @returns {object} - null
- */
-function deleteUser(req, res) {
-  if (req.decoded.roleId !== 1) {
-    return res.status(401).json({
-      message: 'You are not authorized to access this field'
-    });
-  }
-  return User
-  .findById(req.params.id)
-  .then((user) => {
-    if (!user) {
-      return res.status(404).json({ message: 'User not found' });
-    }
-    return user
-      .destroy()
-      .then(() => res.status(204).json({
-        message: 'User has been deleted successfully' }))
-      .catch(error => res.status(400).send(error));
-  })
-  .catch(error => res.status(400).send(error));
-}
- 
-/**
- * Get documents for specific user
- * @param {object} req - request object containing limit query and offset
- * @param {array} res - array of documents for the requested user
- * @return {array} - array of requested user's document
- */
-function getUserDocuments(req, res) {
-  const limit = req.query.limit;
-  const offset = req.query.offset;
-  User.findById(req.params.id)
-    .then((user) => {
-      if (!user) {
-        return res.status(404).json({
-          message: 'User not found'
-        });
-      }
-      return Document.findAndCountAll({
-        limit,
-        offset,
-        where: {
-          userId: user.id
-        }
-      })
-        .then(({ rows: document, count }) => {
-          res.status(200).send({
-            document,
-            pagination: metaData(count, limit, offset),
-          });
-        })
-        .catch(error => res.status(400).send(error));
-    })
-    .catch(error => res.status(400).send(error));
-}
- 
-export default {
-  getUsers,
-  createUser,
-  login,
-  findUser,
-  updateUser,
-  deleteUser,
-  getUserDocuments
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/helpers/helper.js.html b/coverage/document-manager/server/helpers/helper.js.html deleted file mode 100644 index f296c46..0000000 --- a/coverage/document-manager/server/helpers/helper.js.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Code coverage report for document-manager/server/helpers/helper.js - - - - - - - -
-
-

- All files / document-manager/server/helpers helper.js -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -98x -  -  -  -  -  -  -1x - 
const paginationMetaData = (count, limit, offset) => ({
-  totalCount: count,
-  pageCount: Math.ceil(count / limit),
-  page: Math.floor(offset / limit) + 1,
-  pageSize: limit
-});
- 
-module.exports.paginationMetaData = paginationMetaData;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/helpers/index.html b/coverage/document-manager/server/helpers/index.html deleted file mode 100644 index dd03f54..0000000 --- a/coverage/document-manager/server/helpers/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/helpers - - - - - - - -
-
-

- All files document-manager/server/helpers -

-
-
- 100% - Statements - 3/3 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 1/1 -
-
- 100% - Lines - 2/2 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
helper.js
100%3/3100%0/0100%1/1100%2/2
-
-
- - - - - - - diff --git a/coverage/document-manager/server/middlewares/auth.js.html b/coverage/document-manager/server/middlewares/auth.js.html deleted file mode 100644 index 1778255..0000000 --- a/coverage/document-manager/server/middlewares/auth.js.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - Code coverage report for document-manager/server/middlewares/auth.js - - - - - - - -
-
-

- All files / document-manager/server/middlewares auth.js -

-
-
- 92.31% - Statements - 12/13 -
-
- 87.5% - Branches - 7/8 -
-
- 100% - Functions - 3/3 -
-
- 92.31% - Lines - 12/13 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -361x -  -1x -  -  -  -65x -65x -61x -61x -  -  -61x -61x -  -  -  -4x -  -  -  -  -  -  -  -20x -14x -  -6x -  -  -  -  -  -  - 
import jwt from 'jsonwebtoken';
- 
-const jwtSecret = process.env.JWT_SECRET;
- 
- 
-function verifyToken(req, res, next) {
-  const token = req.headers.authorization || req.headers['x-access-token'];
-  if (token) {
-    jwt.verify(token, jwtSecret, (err, decoded) => {
-      Iif (err) {
-        res.json({ success: false, message: 'Failed to authenticate token.' });
-      } else {
-        req.decoded = decoded;
-        next();
-      }
-    });
-  } else {
-    return res.status(403).send({
-      success: false,
-      message: 'No token provided.'
-    });
-  }
-}
- 
-function adminAccess(req, res, next) {
-  if (req.decoded.roleId === 1) {
-    next();
-  } else {
-    return res.status(401).json({
-      message: 'You are not authorized',
-    });
-  }
-}
- 
-export default { verifyToken, adminAccess };
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/middlewares/index.html b/coverage/document-manager/server/middlewares/index.html deleted file mode 100644 index 59391d7..0000000 --- a/coverage/document-manager/server/middlewares/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/middlewares - - - - - - - -
-
-

- All files document-manager/server/middlewares -

-
-
- 92.31% - Statements - 12/13 -
-
- 87.5% - Branches - 7/8 -
-
- 100% - Functions - 3/3 -
-
- 92.31% - Lines - 12/13 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
auth.js
92.31%12/1387.5%7/8100%3/392.31%12/13
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/document.js.html b/coverage/document-manager/server/models/document.js.html deleted file mode 100644 index 3325d86..0000000 --- a/coverage/document-manager/server/models/document.js.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - Code coverage report for document-manager/server/models/document.js - - - - - - - -
-
-

- All files / document-manager/server/models document.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -1x -  - 
 
-module.exports = (sequelize, DataTypes) => {
-  const Document = sequelize.define('Document', {
-    title: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    content: {
-      type: DataTypes.TEXT,
-      allowNull: false
-    },
-    userId: {
-      type: DataTypes.INTEGER,
-      unique: true,
-      allowNull: false
-    },
-    access: {
-      type: DataTypes.ENUM,
-      values: ['public', 'private', 'role']
-    }
-  });
-  Document.associate = (models) => {
-    Document.belongsTo(models.User, {
-      foreignKey: 'userId'
-    });
-  };
-  return Document;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/index.html b/coverage/document-manager/server/models/index.html deleted file mode 100644 index 5525493..0000000 --- a/coverage/document-manager/server/models/index.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - Code coverage report for document-manager/server/models - - - - - - - -
-
-

- All files document-manager/server/models -

-
-
- 97.5% - Statements - 39/40 -
-
- 66.67% - Branches - 6/9 -
-
- 100% - Functions - 9/9 -
-
- 97.5% - Lines - 39/40 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.js
100%5/5100%0/0100%2/2100%5/5
index.js
95.83%23/2466.67%6/9100%3/395.83%23/24
role.js
100%5/5100%0/0100%2/2100%5/5
user.js
100%6/6100%0/0100%2/2100%6/6
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/index.js.html b/coverage/document-manager/server/models/index.js.html deleted file mode 100644 index 3ba686b..0000000 --- a/coverage/document-manager/server/models/index.js.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - Code coverage report for document-manager/server/models/index.js - - - - - - - -
-
-

- All files / document-manager/server/models index.js -

-
-
- 95.83% - Statements - 23/24 -
-
- 66.67% - Branches - 6/9 -
-
- 100% - Functions - 3/3 -
-
- 95.83% - Lines - 23/24 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -461x -1x -1x -  -1x -1x -1x -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -  -4x -  -  -  -  -3x -3x -  -  -1x -3x -3x -  -  -  -1x -1x -  -1x -  -1x -1x -  -1x - 
const fs = require('fs');
-const path = require('path');
-const Sequelize = require('sequelize');
- 
-const basename = path.basename(module.filename);
-const env = process.env.NODE_ENV || 'development';
-const config = require('../config/config.js')[env];
- 
-const db = {};
- 
-let sequelize;
-Iif (config.use_env_variable) {
-  sequelize = new Sequelize(process.env[config.use_env_variable]);
-} else {
-  sequelize = new Sequelize(
-    config.database, config.username, config.password, config
-  );
-}
- 
-fs
-  .readdirSync(__dirname)
-  .filter(file =>
-    (file.indexOf('.') !== 0) &&
-    (file !== basename) &&
-    (file.slice(-3) === '.js'))
-  .forEach((file) => {
-    const model = sequelize.import(path.join(__dirname, file));
-    db[model.name] = model;
-  });
- 
-Object.keys(db).forEach((modelName) => {
-  Eif (db[modelName].associate) {
-    db[modelName].associate(db);
-  }
-});
- 
-db.sequelize = sequelize;
-db.Sequelize = Sequelize;
- 
-module.exports = db;
- 
-db.sequelize = sequelize;
-db.Sequelize = Sequelize;
- 
-module.exports = db;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/role.js.html b/coverage/document-manager/server/models/role.js.html deleted file mode 100644 index 1382e00..0000000 --- a/coverage/document-manager/server/models/role.js.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Code coverage report for document-manager/server/models/role.js - - - - - - - -
-
-

- All files / document-manager/server/models role.js -

-
-
- 100% - Statements - 5/5 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 5/5 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17  -1x -1x -  -  -  -  -  -  -1x -1x -  -  -  -1x -  - 
 
-module.exports = (sequelize, DataTypes) => {
-  const Role = sequelize.define('Role', {
-    title: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    }
-  });
-  Role.associate = (models) => {
-    Role.hasMany(models.User, {
-      foreignKey: 'roleId'
-    });
-  };
-  return Role;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/models/user.js.html b/coverage/document-manager/server/models/user.js.html deleted file mode 100644 index 51f2f7c..0000000 --- a/coverage/document-manager/server/models/user.js.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Code coverage report for document-manager/server/models/user.js - - - - - - - -
-
-

- All files / document-manager/server/models user.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 2/2 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -401x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  - 
module.exports = (sequelize, DataTypes) => {
-  const User = sequelize.define('User', {
-    fullName: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    userName: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    email: {
-      type: DataTypes.STRING,
-      allowNull: false,
-      unique: true
-    },
-    password: {
-      type: DataTypes.STRING,
-      allowNull: false
-    },
-    roleId: {
-      type: DataTypes.INTEGER,
-      allowNull: false,
-      defaultvalue: 2
-    }
-  });
-  User.associate = (models) => {
-    User.hasMany(models.Document, {
-      foreignKey: 'userId',
-      onDelete: 'CASCADE',
-      hooks: true
-    });
-    User.belongsTo(models.Role, {
-      foreignKey: 'roleId',
-      onDelete: 'CASCADE'
-    });
-  };
-  return User;
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/documents.js.html b/coverage/document-manager/server/routes/documents.js.html deleted file mode 100644 index 580e6a7..0000000 --- a/coverage/document-manager/server/routes/documents.js.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/documents.js - - - - - - - -
-
-

- All files / document-manager/server/routes documents.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -251x -1x -1x -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  - 
import express from 'express';
-import documentController from '../controllers/documents';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/v1/documents - Get all documents */
-  .get(auth.verifyToken, documentController.getAllDocument)
- 
-  /** POST /api/v1/documents - Create document */
-  .post(auth.verifyToken, documentController.createDocument);
- 
-router.route('/:id')
-  /** PUT /api/v1/documents/id - Create document */
-  .put(auth.verifyToken, documentController.updateDocument)
- 
-  /** GET /api/v1/documents/id - get document */
-  .get(auth.verifyToken, documentController.findDocument)
- 
-  /** DELETE /api/v1/documents/id - delete document */
-  .delete(auth.verifyToken, documentController.deleteDocument);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/index.html b/coverage/document-manager/server/routes/index.html deleted file mode 100644 index cbc962d..0000000 --- a/coverage/document-manager/server/routes/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/routes - - - - - - - -
-
-

- All files document-manager/server/routes -

-
-
- 100% - Statements - 36/36 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 36/36 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
documents.js
100%6/6100%0/0100%0/0100%6/6
index.js
100%10/10100%0/0100%0/0100%10/10
roles.js
100%6/6100%0/0100%0/0100%6/6
search.js
100%6/6100%0/0100%0/0100%6/6
users.js
100%8/8100%0/0100%0/0100%8/8
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/index.js.html b/coverage/document-manager/server/routes/index.js.html deleted file mode 100644 index cc22d45..0000000 --- a/coverage/document-manager/server/routes/index.js.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/index.js - - - - - - - -
-
-

- All files / document-manager/server/routes index.js -

-
-
- 100% - Statements - 10/10 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 10/10 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -171x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -1x -1x -  -  - 
import express from 'express';
-import userRoutes from './users';
-import searchRoutes from './search';
-import documentRoutes from './documents';
-import roleRoutes from './roles';
- 
- 
-const router = express.Router();
- 
-/** GET /api-status - Check service status **/
-router.use('/users', userRoutes);
-router.use('/search', searchRoutes);
-router.use('/documents', documentRoutes);
-router.use('/roles', roleRoutes);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/roles.js.html b/coverage/document-manager/server/routes/roles.js.html deleted file mode 100644 index f77e87c..0000000 --- a/coverage/document-manager/server/routes/roles.js.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/roles.js - - - - - - - -
-
-

- All files / document-manager/server/routes roles.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -251x -1x -1x -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  - 
import express from 'express';
-import roleController from '../controllers/roles';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/roles - Get list of roles */
-  .get(auth.verifyToken, auth.adminAccess, roleController.getRoles)
- 
-  /** POST /api/roles - Create roles */
-  .post(auth.verifyToken, auth.adminAccess, roleController.createRole);
- 
-router.route('/:id')
-  /** GET /api/users/roles - Find roles */
-  .get(auth.verifyToken, auth.adminAccess, roleController.findRole)
- 
-  /** PUT /api/users/id - update roles */
-  .put(auth.verifyToken, auth.adminAccess, roleController.updateRole)
- 
-  /** DELETE /api/users/id - delete roles */
-  .delete(auth.verifyToken, auth.adminAccess, roleController.deleteRole);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/search.js.html b/coverage/document-manager/server/routes/search.js.html deleted file mode 100644 index 1e66300..0000000 --- a/coverage/document-manager/server/routes/search.js.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/search.js - - - - - - - -
-
-

- All files / document-manager/server/routes search.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -161x -1x -1x -  -1x -  -1x -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import searchController from '../controllers/search';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/users')
-  /** GET /api/v1/users - search list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
- 
-router.route('/documents')
-  /** GET /api/v1/search - search list of documents */
-  .get(auth.verifyToken, searchController.searchDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/searches.js.html b/coverage/document-manager/server/routes/searches.js.html deleted file mode 100644 index 1787a66..0000000 --- a/coverage/document-manager/server/routes/searches.js.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/searches.js - - - - - - - -
-
-

- All files / document-manager/server/routes searches.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -161x -1x -1x -  -1x -  -1x -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import searchController from '../controllers/searches';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/users')
-  /** GET /api/users - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchUser);
- 
-router.route('/documents')
-  /** GET /api/documents - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, searchController.searchDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/routes/users.js.html b/coverage/document-manager/server/routes/users.js.html deleted file mode 100644 index 774a0df..0000000 --- a/coverage/document-manager/server/routes/users.js.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - Code coverage report for document-manager/server/routes/users.js - - - - - - - -
-
-

- All files / document-manager/server/routes users.js -

-
-
- 100% - Statements - 8/8 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 8/8 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -331x -1x -1x -  -1x -  -1x -  -  -  -  -  -  -1x -  -  -  -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -  - 
import express from 'express';
-import userController from '../controllers/users';
-import auth from '../middlewares/auth';
- 
-const router = express.Router();
- 
-router.route('/')
-  /** GET /api/users - Get list of users */
-  .get(auth.verifyToken, auth.adminAccess, userController.getUsers)
- 
-  /** POST /api/users - Create/Signup users */
-  .post(userController.createUser);
- 
-router.route('/login')
-  /** POST /api/users/login - Login users */
-  .post(userController.login);
- 
-router.route('/:id')
-  /** GET /api/users/id - Find users */
-  .get(auth.verifyToken, userController.findUser)
- 
-  /** PUT /api/users/id - update users */
-  .put(auth.verifyToken, userController.updateUser)
- 
-  /** DELETE /api/users/id - delete users */
-  .delete(auth.verifyToken, userController.deleteUser);
- 
-router.route('/:id/documents')
-  /** GET /api/users/id/documents - Find documents of a specific user*/
-  .get(auth.verifyToken, userController.getUserDocuments);
- 
-export default router;
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/document.spec.js.html b/coverage/document-manager/server/test/controllers/document.spec.js.html deleted file mode 100644 index f2c5cb0..0000000 --- a/coverage/document-manager/server/test/controllers/document.spec.js.html +++ /dev/null @@ -1,1307 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/document.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers document.spec.js -

-
-
- 97.07% - Statements - 199/205 -
-
- 100% - Branches - 0/0 -
-
- 98.39% - Functions - 61/62 -
-
- 97.04% - Lines - 197/203 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -391 -392 -393 -394 -395 -396 -397 -398 -399 -400 -401 -402 -403 -404 -405 -406 -407 -408 -409 -410 -411 -412 -413 -414 -4151x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -1x -  -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Documents', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Document', () => {
-    it('should add a new document if the user is authenticated', (done) => {
-      const document = {
-        title: 'hey yo!',
-        content: 'Andela is really fun!!',
-        access: 'public',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('id');
-        expect(res.body.title).to.eql('hey yo!');
-        expect(res.body.content).to.eql('Andela is really fun!!');
-        expect(res.body.access).to.equal('public');
-        done();
-      });
-    });
- 
-    it('Should fail if document already exist', () => {
-      const document = {
-        title: 'John team',
-        content: 'eze goes to school',
-        access: 'public',
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body.message).to.eql('Document already exists');
-      });
-    });
-    it('should fail to add a new document if the user is not authenticated',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome !!!',
-        value: 'private',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('No token provided.');
-        done();
-      });
-    });
-    it('should fail to add a new document if the access field is missing',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome!!!',
-        access: '',
-        userId: 1,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('accessType is required');
-        done();
-      });
-    });
-    it('should fail to add a new document if the title field is missing',
-    (done) => {
-      const document = {
-        title: '',
-        content: 'Andela is really awesome!!!',
-        value: 'public',
-        userId: 2,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('Title is required');
-        done();
-      });
-    });
-    it('should fail to add a new document if the content field is missing',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: '',
-        value: 'public',
-        userId: 2,
-      };
-      chai.request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body.errors[0].msg).to.be.equal('Content is required');
-        done();
-      });
-    });
-  });
- 
-  describe('/GET Documents', () => {
-    it('Should get all documents for the user that is authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.keys(['document', 'pagination']);
-        done();
-      });
-    });
-    it('should fail to get all documents if the user is not authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents/')
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).be.eql('No token provided.');
-        expect(res.body.success).to.eql(false);
-        done();
-      });
-    });
-    it('Should get all documents with correct limit as a query', (done) => {
-      const limit = 1;
-      request(server)
-        .get(`/api/v1/documents?limit=${limit}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-    it('Should get all documents with correct offset as a query', (done) => {
-      const offset = 0;
-      request(server)
-        .get(`/api/v1/documents?limit=${offset}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Document', () => {
-    it('Should fail to get document if it doesn`t exist', (done) => {
-      const documentId = 8;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-    it('Should get all public regardless of id', (done) => {
-      const documentId = 4;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(4);
-          expect(res.body.title).to.equal('hey yo!');
-          expect(res.body.access).to.equal('public');
-          done();
-        });
-    });
-    it('Should fail to get a private document if the requester does not own it',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a private document the where the requester is the owner',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.access).to.eql('private');
-          expect(res.body.title).to.eql('John naddddd');
-          expect(res.body.id).to.eql(2);
-          expect(res.body.userId).to.eql(2);
-          done();
-        });
-    });
-    it('Should fail get a role document if the users are not on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a role document if the users are on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-          done();
-        });
-    });
-    it('Should get a role document if the user is an admin', (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-        });
-      done();
-    });
-  });
- 
-  describe('/PUT/:id, Document', () => {
-    it('Should update a document by id if the user has the same id',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: userToken })
-          .send({ title: 'wreck it ralph' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.title).to.eql('wreck it ralph');
-            done();
-          });
-      });
-    it(`Should fail to update a document by
-      id if the user does not have the same id`,
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: sampleUserToken })
-          .send({ title: 'spiderman Homecoming' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to edit this document');
-            done();
-          });
-      });
-    it('Should not update a document by id if the user has admin access',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'wreck it' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            done();
-          });
-      });
-    it('Should fail to update a document by id if the document does not exist',
-      (done) => {
-        const id = 10;
-        request(server)
-        .put(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .send({ title: 'Deadpool' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-      });
-  });
- 
-  describe('DELETE/:id Document', () => {
-    it('Should delete a document if the user has admin access', (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should delete a document if the user is the owner', (done) => {
-      const id = 2;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should fail to delete the document given the user is not the owner',
-    (done) => {
-      const id = 1;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to delete this document');
-          done();
-        });
-    });
-    it('Should fail to delete if the document does not exist', (done) => {
-      const id = 234;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/index.html b/coverage/document-manager/server/test/controllers/index.html deleted file mode 100644 index 499c8bf..0000000 --- a/coverage/document-manager/server/test/controllers/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers - - - - - - - -
-
-

- All files document-manager/server/test/controllers -

-
-
- 97.21% - Statements - 593/610 -
-
- 100% - Branches - 0/0 -
-
- 99.47% - Functions - 186/187 -
-
- 97.18% - Lines - 585/602 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.spec.js
97.07%199/205100%0/098.39%61/6297.04%197/203
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
94.7%125/132100%0/0100%42/4294.62%123/130
search.spec.js
98.33%59/60100%0/0100%19/1998.28%57/58
user.spec.js
98.58%208/211100%0/0100%64/6498.56%206/209
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/mockData.js.html b/coverage/document-manager/server/test/controllers/mockData.js.html deleted file mode 100644 index 92d7937..0000000 --- a/coverage/document-manager/server/test/controllers/mockData.js.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/mockData.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -541x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  Baas: {
-    fullName: 'Baas Bank',
-    userName: 'bank',
-    email: 'baas@test.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/role.spec.js.html b/coverage/document-manager/server/test/controllers/role.spec.js.html deleted file mode 100644 index d98b530..0000000 --- a/coverage/document-manager/server/test/controllers/role.spec.js.html +++ /dev/null @@ -1,977 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/role.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers role.spec.js -

-
-
- 94.7% - Statements - 125/132 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 42/42 -
-
- 94.62% - Lines - 123/130 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -3051x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -  -  -1x -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Role', () => {
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'boromir' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-        expect(res.body.role).to.have.property('title').to.equal('boromir');
-      });
-      done();
-    });
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'king' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(204);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-      });
-      done();
-    });
-    it('Should fail if a non-admin wants to add a new role', (done) => {
-      const role = {
-        title: 'boromir-team'
-      };
-      request(server)
-        .post('/api/v1/roles/')
-        .set({ authorization: userToken })
-      .send(role)
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('You are not authorized');
-        done();
-      });
-    });
-    it('Should return an error if the title is not a string', (done) => {
-      chai.request(server)
-        .post('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .send({ title: 358583 })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Invalid input credentials');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET Role', () => {
-    it('Should get all the roles if the user is an admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.length(5);
-          expect(res.body).to.be.a('array');
-          expect(res.body[0].id).to.eql(1);
-          expect(res.body[0].title).to.eql('admin');
-          expect(res.body[1].id).to.eql(2);
-          expect(res.body[1].title).to.eql('facilitator');
-          done();
-        });
-    });
-    it('Should fail to get the roles if the user is not admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql('You are not authorized');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Role', () => {
-    it('Should get a role by id if the user is an admin', (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).be.a('object');
-          expect(res.body.title).to.eql('facilitator');
-          expect(res.body.id).to.equal(2);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user is not an admin',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user enters an invalid input',
-    (done) => {
-      const id = 'fddjsdcdjn';
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql(`invalid input syntax for integer: "${id}"`);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the role does not exist', (done) => {
-      const id = 250;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body.message).to.eql('Role not found');
-          done();
-        });
-    });
-    // it('Should fail to get a role by id if the id is out of range', (done) => {
-    //   const id = 500000000000000000000;
-    //   chai.request(server)
-    //     .get(`/api/v1/roles/${id}`)
-    //     .set({ authorization: adminToken })
-    //     .end((err, res) => {
-    //       expect(res.status).to.equal(400);
-    //       expect(res.body.message)
-    //       .to.eql(`value "${id}" is out of range for type integer`);
-    //       done();
-    //     });
-    // });
-  });
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'boromir-team' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it(`Should fail to update a
-       role by id if the admin enters an invalid input`,
-      (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-      });
-    // it(`Should fail to update a role by
-    //   id if the admin enters an id that is out range`,
-    //   (done) => {
-    //     const id = 2000000000000000;
-    //     chai.request(server)
-    //       .put(`/api/v1/roles/${id}`)
-    //       .set({ authorization: adminToken })
-    //       .send({ title: 'regular' })
-    //       .end((err, res) => {
-    //         expect(res.status).to.equal(400);
-    //         expect(res.body).to.be.a('object');
-    //         expect(res.body.message)
-    //         .to.eql(`value "${id}" is out of range for type integer`);
-    //         done();
-    //       });
-    //   });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-        });
-      done();
-    });
-    it('Should fail to delete a role given the user has no admin access',
-    (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    // it('Should fail to delete a role given the admin enters an invalid input',
-    // (done) => {
-    //   const id = 300;
-    //   chai.request(server)
-    //     .delete(`/api/v1/roles/${id}`)
-    //     .set({ authorization: adminToken })
-    //     .end((err, res) => {
-    //       expect(res.status).to.equal(404);
-    //       expect(res.body).to.be.a('object');
-    //       expect(res.body.message).to.equal('Role not found');
-    //       done();
-    //     });
-    // });
-    // it(`Should fail to delete a role given
-    //   the admin enters an input that is out of range`, (done) => {
-    //   const id = 3000000000000000;
-    //   chai.request(server)
-    //     .delete(`/api/v1/roles/${id}`)
-    //     .set({ authorization: adminToken })
-    //     .end((err, res) => {
-    //       expect(res.status).to.equal(200);
-    //       expect(res.body).to.be.a('object');
-    //       expect(res.body.message)
-    //       .to.eql(`value "${id}" is out of range for type integer`);
-    //       done();
-    //     });
-    // });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/search.spec.js.html b/coverage/document-manager/server/test/controllers/search.spec.js.html deleted file mode 100644 index 8876054..0000000 --- a/coverage/document-manager/server/test/controllers/search.spec.js.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/search.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers search.spec.js -

-
-
- 98.33% - Statements - 59/60 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 19/19 -
-
- 98.28% - Lines - 57/58 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -1091x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow, Baas } = data;
- 
-describe('Search', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/SEARCH/users/?q={name}', () => {
-    it('Should return an error if no querystring is provided', (done) => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/users/?q=${query}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Invalid search input');
-          done();
-        });
-    });
-    it('Should return a search list response of the required search input',
-    (done) => {
-      const query = Baas.userName;
-      request(server)
-      .get(`/api/v1/search/users/?q=${query}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body.user[0].fullName).to.eql(Baas.fullName);
-        expect(res.body.user[0].userName).to.equal(Baas.userName);
-        done();
-      });
-    });
-  });
-  describe('/SEARCH/documents/?q=', () => {
-    it('Should return an error if no querystring is provided', (done) => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Invalid search input');
-          done();
-        });
-    });
-    it('Should return a search list of the required search input', (done) => {
-      const query = 'John';
-      request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.property('document');
-          expect(res.body.document[0].title).to.equal('John Doe');
-          expect(res.body.document[0].content).to.equal('eze goes to school');
-          expect(res.body).to.have.property('pagination');
-          expect(res.body.paginaton).to.have.property('totalCount').to.equal(1);
-          done();
-        });
-    });
-    it('Should throw an error if the searched document is not found',
-      (done) => {
-        const query = 'jk';
-        request(server)
-          .get(`/api/v1/search/documents/?q=${query}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body.message).to.equal('Document not found');
-            done();
-          });
-      });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/controllers/user.spec.js.html b/coverage/document-manager/server/test/controllers/user.spec.js.html deleted file mode 100644 index e583780..0000000 --- a/coverage/document-manager/server/test/controllers/user.spec.js.html +++ /dev/null @@ -1,1232 +0,0 @@ - - - - Code coverage report for document-manager/server/test/controllers/user.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/controllers user.spec.js -

-
-
- 98.58% - Statements - 208/211 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 64/64 -
-
- 98.56% - Lines - 206/209 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -3901x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../../index';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fakeBass, fellow, user1, user2 } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST User login', () => {
-    it('Should fail if the user enters incorrect crendentials upon login',
-    (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user1)
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. User not found.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('Should fail if the user provide a wrong password', (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user2)
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. Wrong password.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('should log in a user and return a token', (done) => {
-      request(server)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['success', 'token']);
-          expect(res.body.success).to.eql(true);
-          done();
-        });
-    });
- 
-    describe('/POST User Signup', () => {
-      it('should create a new user', (done) => {
-        request(server)
-          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body)
-              .to.have.keys(['message', 'success', 'userDetails']);
-            expect(res.body.success).to.eql(true);
-            expect(res.body.message)
-            .to.eql('You have successfully registered.');
-            done();
-          });
-      });
-    });
- 
-    describe('#GET Users', () => {
-      it('Should get all users if the user is an admin ', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body).to.have.keys(['user', 'pagination']);
-            done();
-          });
-      });
-      it('Should fail to get all users if the user has no admin access ',
-      (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('You are not authorized');
-            done();
-          });
-      });
-      it('Should fail to get all users if no token was provided', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            done();
-          });
-      });
-      it('Should get all users with correct limit as a query', (done) => {
-        const limit = 1;
-        chai.request(server)
-          .get(`/api/v1/users?limit=${limit}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.user[0].fullName).to.equal('Baas Bank');
-            expect(res.body.user[0].userName).to.equal('bank');
-            done();
-          });
-      });
-    });
-    describe('#GET User by Id', () => {
-      it('Should get a user if the user is an admin', (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).to.eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should get the user if the requested user is the current user',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should fail to get a user if an invalid input is entered',
-      (done) => {
-        const id = 'fddjsdcdjn';
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.property('message')
-            .to.eql(`invalid input syntax for integer: "${id}"`);
-            done();
-          });
-      });
-      it('should fail to get the user if the requester is not the owner',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`api/users/${id}`)
-          .set({ authorization: sampleUserToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.keys(['message']);
-            expect(res.body.message).to.eql('Unauthorized access');
-          });
-        done();
-      });
-      it('Should fail to get a user if the user does not exist',
-      (done) => {
-        const id = 250;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.have.property('message');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get a user if the id is out of range',
-      (done) => {
-        const id = 500000000000000000;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.have.property('message')
-            .to.equal(`value "${id}" is out of range for type integer`);
-            done();
-          });
-      });
-    });
-    describe('#PUT Update user by Id', () => {
-      it('Should update a user`s full name if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ fullName: 'jake doe' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.fullName).to.eql('jake doe');
-              done();
-            });
-        });
-      it('Should update a user`s email if the user has the same id', (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.email).to.eql('jakedoe@andela.com');
-            done();
-          });
-      });
-      it('Should update a user`s username if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ userName: 'jakedoe12' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.userName).to.eql('jakedoe12');
-              done();
-            });
-        });
-      it(`Should fail to update a user's
-      details if the user does not have the same user id`,
-      (done) => {
-        const id = 3;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-      it(`Should fail to update a user's
-        details if the user enters an invalid user id`,
-      (done) => {
-        const id = 2302;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-    });
-    describe('#DELETE /:id Users', () => {
-      it('Should delete a user given the user has admin access', (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(204);
-            done();
-          });
-      });
-      it('Should fail to delete a user if the user has no admin access',
-      (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this field');
-            done();
-          });
-      });
-      it('Should give a User not found if user don\'t exist', (done) => {
-        const id = 23;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-    });
-    describe('/GET/users/:id/documents Documents', () => {
-      it('Should fail to get documents if the user does not exist', (done) => {
-        const userId = 9;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get documents if there is no token present',
-      (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            expect(res.body.success).to.eql(false);
-            done();
-          });
-      });
-      it('Should get documents for the user with its unique userId', (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('object');
-            expect(res.body.document[1].userId).to.eql(2);
-            expect(res.body.document[1].title).to.eql('hey yo!');
-            expect(res.body.document[1].content)
-            .to.eql('Andela is really fun!!');
-            done();
-          });
-      });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/document.spec.js.html b/coverage/document-manager/server/test/document.spec.js.html deleted file mode 100644 index 73007d7..0000000 --- a/coverage/document-manager/server/test/document.spec.js.html +++ /dev/null @@ -1,1139 +0,0 @@ - - - - Code coverage report for document-manager/server/test/document.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test document.spec.js -

-
-
- 96.76% - Statements - 179/185 -
-
- 100% - Branches - 0/0 -
-
- 98.21% - Functions - 55/56 -
-
- 96.72% - Lines - 177/183 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -3591x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -1x -  -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -  -  -  -1x -  -  -  -1x -  -1x -  -  -  -  -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -  -  -  -  -  -1x -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Documents', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Document', () => {
-    it('should add a new document if the user is authenticated', (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome!!!',
-        access: 'public',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('id');
-        expect(res.body.title).to.eql('boromir-team');
-        expect(res.body.content).to.eql('Andela is really awesome!!!');
-        expect(res.body.access).to.equal('public');
-        done();
-      });
-    });
- 
-    it('Should fail if document already exist', () => {
-      const document = {
-        title: 'John team',
-        content: 'eze goes to school',
-        access: 'public',
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body.message).to.eql('Document already exists');
-      });
-    });
-    it('should fail to add a new document if the user is not authenticated',
-    (done) => {
-      const document = {
-        title: 'boromir-team',
-        content: 'Andela is really awesome !!!',
-        value: 'private',
-        userId: 2,
-      };
-      request(server)
-      .post('/api/v1/documents')
-      .send(document)
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('No token provided.');
-        done();
-      });
-    });
-  });
- 
-  describe('/GET Documents', () => {
-    it('Should get all documents for the user that is authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.keys(['document', 'pagination']);
-        done();
-      });
-    });
-    it('should fail to get all documents if the user is not authenticated',
-    (done) => {
-      request(server)
-      .get('/api/v1/documents/')
-      .end((err, res) => {
-        expect(res.status).to.equal(403);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).be.eql('No token provided.');
-        expect(res.body.success).to.eql(false);
-        done();
-      });
-    });
-    it('Should get all documents with correct limit as a query', (done) => {
-      const limit = 1;
-      request(server)
-        .get(`/api/v1/documents?limit=${limit}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-    it('Should get all documents with correct offset as a query', (done) => {
-      const offset = 0;
-      request(server)
-        .get(`/api/v1/documents?limit=${offset}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Document', () => {
-    it('Should fail to get document if it doesn`t exist', (done) => {
-      const documentId = 8;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-    it('Should get all public regardless of id', (done) => {
-      const documentId = 4;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(4);
-          expect(res.body.title).to.equal('boromir-team');
-          expect(res.body.access).to.equal('public');
-          done();
-        });
-    });
-    it('Should fail to get a private document if the requester does not own it',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a private document the where the requester is the owner',
-    (done) => {
-      const documentId = 2;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.access).to.eql('private');
-          expect(res.body.title).to.eql('John naddddd');
-          expect(res.body.id).to.eql(2);
-          expect(res.body.userId).to.eql(2);
-          done();
-        });
-    });
-    it('Should fail get a role document if the users are not on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to view this document');
-          done();
-        });
-    });
-    it('Should get a role document if the users are on the same role',
-    (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-          done();
-        });
-    });
-    it('Should get a role document if the user is an admin', (done) => {
-      const documentId = 3;
-      request(server)
-        .get(`/api/v1/documents/${documentId}/`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.id).to.eql(3);
-          expect(res.body.title).to.eql('James Hannn');
-          expect(res.body.access).to.eql('role');
-        });
-      done();
-    });
-  });
- 
-  describe('/PUT/:id, Document', () => {
-    it('Should update a document by id if the user has the same id',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: userToken })
-          .send({ title: 'wreck it ralph' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.title).to.eql('wreck it ralph');
-            done();
-          });
-      });
-    it(`Should fail to update a document by
-      id if the user does not have the same id`,
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: sampleUserToken })
-          .send({ title: 'spiderman Homecoming' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to edit this document');
-            done();
-          });
-      });
-    it('Should not update a document by id if the user has admin access',
-      (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/documents/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'wreck it' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            done();
-          });
-      });
-    it('Should fail to update a document by id if the document does not exist',
-      (done) => {
-        const id = 10;
-        request(server)
-        .put(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .send({ title: 'Deadpool' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document Not Found');
-          done();
-        });
-      });
-  });
- 
-  describe('DELETE/:id Document', () => {
-    it('Should delete a document if the user has admin access', (done) => {
-      const id = 3;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should delete a document if the user is the owner', (done) => {
-      const id = 2;
-      request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          done();
-        });
-    });
-    it('Should fail to delete the document given the user is not the owner',
-    (done) => {
-      const id = 1;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: sampleUserToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql('You are not authorized to delete this document');
-          done();
-        });
-    });
-    it('Should fail to delete if the document does not exist', (done) => {
-      const id = 234;
-      chai.request(server)
-        .delete(`/api/v1/documents/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Document not found');
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/index.html b/coverage/document-manager/server/test/index.html deleted file mode 100644 index 003d5a5..0000000 --- a/coverage/document-manager/server/test/index.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - Code coverage report for document-manager/server/test - - - - - - - -
-
-

- All files document-manager/server/test -

-
-
- 95.28% - Statements - 586/615 -
-
- 100% - Branches - 0/0 -
-
- 99.47% - Functions - 188/189 -
-
- 95.22% - Lines - 578/607 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document.spec.js
96.76%179/185100%0/098.21%55/5696.72%177/183
mockData.js
100%2/2100%0/0100%0/0100%2/2
role.spec.js
93.75%150/160100%0/0100%50/5093.67%148/158
search.spec.js
82.14%46/56100%0/0100%19/1981.48%44/54
user.spec.js
98.58%209/212100%0/0100%64/6498.57%207/210
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/index.spec.js.html b/coverage/document-manager/server/test/index.spec.js.html deleted file mode 100644 index ca3eb5d..0000000 --- a/coverage/document-manager/server/test/index.spec.js.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Code coverage report for document-manager/server/test/index.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test index.spec.js -

-
-
- 100% - Statements - 6/6 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 6/6 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -91x -1x -1x -1x -  -1x -  -1x - 
process.env.NODE_ENV = 'test';
-const chai = require('chai');
-const chaiHttp = require('chai-http');
-const server = require('../../index');
- 
-let expect = chai.expect();
- 
-chai.use(chaiHttp);
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/middlewares/auth.spec.js.html b/coverage/document-manager/server/test/middlewares/auth.spec.js.html deleted file mode 100644 index 52005bf..0000000 --- a/coverage/document-manager/server/test/middlewares/auth.spec.js.html +++ /dev/null @@ -1,383 +0,0 @@ - - - - Code coverage report for document-manager/server/test/middlewares/auth.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test/middlewares auth.spec.js -

-
-
- 35.48% - Statements - 22/62 -
-
- 100% - Branches - 0/0 -
-
- 20% - Functions - 4/20 -
-
- 34.43% - Lines - 21/61 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -1071x -1x -  -1x -1x -1x -1x -1x -1x -  -1x -1x -  -1x -1x -1x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
const chai = require('chai');
-const chaiHttp = require('chai-http');
- 
-const expect = chai.expect;
-const EventEmitter = require('events').EventEmitter;
-const httpMocks = require('node-mocks-http');
-const data = require('../controllers/mockdata');
-const server = require('../../../index');
-const auth = require('../../middlewares/auth');
- 
-chai.use(chaiHttp);
-let adminToken, userToken;
-const { admin, fellow } = data;
-describe('Authentication', () => {
-  before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-      .end((err, res) => {
-        adminToken = res.body.token;
-        done();
-      });
-  });
-    before((done) => {
-    chai.request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('VerifyJwtToken', () => {
-    it('Should check if the token is provided with request', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents',
-      });
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.verifyJwtToken(request, response, nextCallBack);
-      expect(response._getData().message).to.equal('No token provided.');
-      done();
-    });
-  it('Should provide access if the token is provided and valid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents',
-      headers: { 'x-access-token': adminToken }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
-    expect(response._getData().message).to.equal(undefined);
-    done();
-  });
-  it('Should deny access if the token is invalid', (done) => {
-    const request = httpMocks.createRequest({
-      method: 'GET',
-      url: '/api/v1/documents/',
-      headers: { 'x-access-token': 'themaniscoming' }
-    });
-    const response = httpMocks.createResponse();
-    const nextCallBack = () => { };
-    auth.verifyJwtToken(request, response, nextCallBack);
- 
-    response.on('end', () => {
-      expect(response._getData().success).to.equal(false);
-    });
-    done();
-  });
-  });
-  describe('AdminAcess', () => {
-    it('Should deny access if the user is not admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': userToken }
-      });
-      request.decoded = { roleId: 2 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal('You are not authorized');
-      });
-      done();
-    });
-    it('Should grant access if the user is an admin', (done) => {
-      const request = httpMocks.createRequest({
-        method: 'GET',
-        url: '/api/v1/documents/',
-        headers: { 'x-access-token': adminToken }
-      });
-      request.decoded = { roleId: 1 };
-      const response = httpMocks.createResponse();
-      const nextCallBack = () => { };
-      auth.adminAccess(request, response, nextCallBack);
-      response.on('end', () => {
-        expect(response._getData().message).to.equal(undefined);
-      });
-      done();
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/middlewares/index.html b/coverage/document-manager/server/test/middlewares/index.html deleted file mode 100644 index d19829c..0000000 --- a/coverage/document-manager/server/test/middlewares/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Code coverage report for document-manager/server/test/middlewares - - - - - - - -
-
-

- All files document-manager/server/test/middlewares -

-
-
- 35.48% - Statements - 22/62 -
-
- 100% - Branches - 0/0 -
-
- 20% - Functions - 4/20 -
-
- 34.43% - Lines - 21/61 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
auth.spec.js
35.48%22/62100%0/020%4/2034.43%21/61
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/mockData.js.html b/coverage/document-manager/server/test/mockData.js.html deleted file mode 100644 index 2135885..0000000 --- a/coverage/document-manager/server/test/mockData.js.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - Code coverage report for document-manager/server/test/mockData.js - - - - - - - -
-
-

- All files / document-manager/server/test mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -451x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/role.js.html b/coverage/document-manager/server/test/role.js.html deleted file mode 100644 index a81a819..0000000 --- a/coverage/document-manager/server/test/role.js.html +++ /dev/null @@ -1,950 +0,0 @@ - - - - Code coverage report for document-manager/server/test/role.js - - - - - - - -
-
-

- All files / document-manager/server/test role.js -

-
-
- 92.02% - Statements - 150/163 -
-
- 100% - Branches - 0/0 -
-
- 96.08% - Functions - 49/51 -
-
- 91.93% - Lines - 148/161 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -2961x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -1x -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
-  after((done) => {
-    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
-    done();
-  });
- 
-  describe('/POST Role', () => {
-  it('should add a new role if the user is an admin', (done) => {
-    request(server)
-    .post('/api/v1/roles')
-    .send({ title: 'boromir' })
-    .set({ authorization: adminToken })
-    .end((err, res) => {
-      expect(res.status).to.equal(201);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('Role successfully created');
-      expect(res.body).to.have.property('role');
-      expect(res.body.role).to.have.property('title').to.equal('kiba');
-    });
-    done();
-  });
-  it('should add a new role if the user is an admin', (done) => {
-    request(server)
-    .post('/api/v1/roles')
-    .send({ title: 'king' })
-    .set({ authorization: adminToken })
-    .end((err, res) => {
-      expect(res.status).to.equal(204);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('Role successfully created');
-      expect(res.body).to.have.property('role');
-    });
-    done();
-  });
-  it('Should fail if a non-admin wants to add a new role', (done) => {
-    const role = {
-      title: 'boromir-team'
-    };
-    request(server)
-      .post('/api/v1/roles/')
-      .set({ authorization: userToken })
-    .send(role)
-    .end((err, res) => {
-      expect(res.status).to.equal(401);
-      expect(res.body).to.be.a('object');
-      expect(res.body).to.have.property('message').to.equal('You are not authorized');
-      done();
-    });
-  });
-  it('Should return an error if the title is not a string', (done) => {
-    chai.request(server)
-      .post('/api/v1/roles')
-      .set({ authorization: adminToken })
-      .send({ title: 358583 })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.be.a('object');
-        expect(res.body).to.have.property('message').to.equal('Invalid input credentials');
-        done();
-      });
-  });
-});
- 
-describe('/GET Role', () => {
-  it('Should get all the roles if the user is an admin', (done) => {
-    chai.request(server)
-      .get('/api/v1/roles')
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).to.have.length(5);
-        expect(res.body).to.be.a('array');
-        expect(res.body[0]).to.have.property('id').to.equal(1);
-        expect(res.body[0]).to.have.property('title').to.equal('admin')
-        expect(res.body[1]).to.have.property('id').to.equal(2);
-        expect(res.body[1]).to.have.property('title').to.equal('facilitator');
-        done();
-      });
-  });
-  it('Should fail to get the roles if the user is not admin', (done) => {
-    chai.request(server)
-      .get('/api/v1/roles')
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.have.property('message').to.equal('You are not authorized');
-        done();
-      });
-  });
-});
- 
-describe('/GET/:id Role', () => {
-  it('Should get a role by id if the user is an admin', (done) => {
-    const id = 2;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body).be.a('object');
-        expect(res.body).to.have.property('title').to.equal('facilitator');
-        expect(res.body).to.have.property('id').to.equal(2);
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the user is not an admin', (done) => {
-    const id = 2;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.have.property('message').to.equal('You are not authorized');
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the user enters an invalid input', (done) => {
-    const id = 'fddjsdcdjn';
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.have.property('message').to.equal(`invalid input syntax for integer: "${id}"`);
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the role does not exist', (done) => {
-    const id = 250;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(404);
-        expect(res.body).to.have.property('message').to.equal('Role not found');
-        done();
-      });
-  });
-  it('Should fail to get a role by id if the id is out of range', (done) => {
-    const id = 500000000000000000000;
-    chai.request(server)
-      .get(`/api/v1/roles/${id}`)
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(400);
-        expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-        done();
-      });
-  });
-});
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the admin enters an invalid input'
-      , (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role not found');
-          done();
-        });
-      });
-    it('Should fail to update a role by id if the admin enters an id that is out range', (done) => {
-      const id = 2000000000000000;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'regular' })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-        });
-       done();
-    });
-    it('Should fail to delete a role given the user has no admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an invalid input', (done) => {
-      const id = 300;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal('Role not found');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an input that is out of range', (done) => {
-      const id = 3000000000000000;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body).to.have.property('message').to.equal(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/role.spec.js.html b/coverage/document-manager/server/test/role.spec.js.html deleted file mode 100644 index eec4810..0000000 --- a/coverage/document-manager/server/test/role.spec.js.html +++ /dev/null @@ -1,980 +0,0 @@ - - - - Code coverage report for document-manager/server/test/role.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test role.spec.js -

-
-
- 93.75% - Statements - 150/160 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 50/50 -
-
- 93.67% - Lines - 148/158 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -3061x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -1x -  -1x -1x -  -  -  -  -1x -  -  -  -  -1x -  -1x -1x -  -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -  -  -1x -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -  -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Roles', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST Role', () => {
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'boromir' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(201);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-        expect(res.body.role).to.have.property('title').to.equal('boromir');
-      });
-      done();
-    });
-    it('should add a new role if the user is an admin', (done) => {
-      request(server)
-      .post('/api/v1/roles')
-      .send({ title: 'king' })
-      .set({ authorization: adminToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(204);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('Role successfully created');
-        expect(res.body).to.have.property('role');
-      });
-      done();
-    });
-    it('Should fail if a non-admin wants to add a new role', (done) => {
-      const role = {
-        title: 'boromir-team'
-      };
-      request(server)
-        .post('/api/v1/roles/')
-        .set({ authorization: userToken })
-      .send(role)
-      .end((err, res) => {
-        expect(res.status).to.equal(401);
-        expect(res.body).to.be.a('object');
-        expect(res.body.message).to.eql('You are not authorized');
-        done();
-      });
-    });
-    it('Should return an error if the title is not a string', (done) => {
-      chai.request(server)
-        .post('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .send({ title: 358583 })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Invalid input credentials');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET Role', () => {
-    it('Should get all the roles if the user is an admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.length(5);
-          expect(res.body).to.be.a('array');
-          expect(res.body[0].id).to.eql(1);
-          expect(res.body[0].title).to.eql('admin');
-          expect(res.body[1].id).to.eql(2);
-          expect(res.body[1].title).to.eql('facilitator');
-          done();
-        });
-    });
-    it('Should fail to get the roles if the user is not admin', (done) => {
-      chai.request(server)
-        .get('/api/v1/roles')
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql('You are not authorized');
-          done();
-        });
-    });
-  });
- 
-  describe('/GET/:id Role', () => {
-    it('Should get a role by id if the user is an admin', (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).be.a('object');
-          expect(res.body.title).to.eql('facilitator');
-          expect(res.body.id).to.equal(2);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user is not an admin',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the user enters an invalid input',
-    (done) => {
-      const id = 'fddjsdcdjn';
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body.message)
-          .to.eql(`invalid input syntax for integer: "${id}"`);
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the role does not exist', (done) => {
-      const id = 250;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body.message).to.eql('Role not found');
-          done();
-        });
-    });
-    it('Should fail to get a role by id if the id is out of range', (done) => {
-      const id = 500000000000000000000;
-      chai.request(server)
-        .get(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message)
-          .to.eql(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-  describe('/PUT/:id Role', () => {
-    it('Should update a role by id if the user has admin access', (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'boromir-team' })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('Role updated successfully');
-          expect(res.body).to.have.property('role');
-          done();
-        });
-    });
-    it('Should fail to update a role by id if the user has no admin access',
-    (done) => {
-      const id = 2;
-      chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: userToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it(`Should fail to update a
-       role by id if the admin enters an invalid input`,
-      (done) => {
-        const id = 200;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-         .set({ authorization: adminToken })
-        .send({ title: 'kiba' })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-      });
-    it(`Should fail to update a role by
-      id if the admin enters an id that is out range`,
-      (done) => {
-        const id = 2000000000000000;
-        chai.request(server)
-          .put(`/api/v1/roles/${id}`)
-          .set({ authorization: adminToken })
-          .send({ title: 'regular' })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql(`value "${id}" is out of range for type integer`);
-            done();
-          });
-      });
-  });
-  describe('/DELETE/:id Role', () => {
-    it('Should delete a role given the user has admin access', (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(204);
-          expect(res.body).to.be.a('object');
-        });
-      done();
-    });
-    it('Should fail to delete a role given the user has no admin access',
-    (done) => {
-      const id = 3;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.eql('You are not authorized');
-          done();
-        });
-    });
-    it('Should fail to delete a role given the admin enters an invalid input',
-    (done) => {
-      const id = 300;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message).to.equal('Role not found');
-          done();
-        });
-    });
-    it(`Should fail to delete a role given
-      the admin enters an input that is out of range`, (done) => {
-      const id = 3000000000000000;
-      chai.request(server)
-        .delete(`/api/v1/roles/${id}`)
-        .set({ authorization: adminToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.be.a('object');
-          expect(res.body.message)
-          .to.eql(`value "${id}" is out of range for type integer`);
-          done();
-        });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/search.spec.js.html b/coverage/document-manager/server/test/search.spec.js.html deleted file mode 100644 index 2374e28..0000000 --- a/coverage/document-manager/server/test/search.spec.js.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - Code coverage report for document-manager/server/test/search.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test search.spec.js -

-
-
- 82.14% - Statements - 46/56 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 19/19 -
-
- 81.48% - Lines - 44/54 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -1031x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -  -  -1x -1x -1x -1x -  -  -  -1x -  -  -  -1x -1x -1x -  -  -  -1x -  -  -  -  -  -  -  -1x -1x -1x -  -  -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fellow } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/SEARCH/users/?q={name}', () => {
-    it('Should return an error if no querystring is provided', () => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/users/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body.message).to.eql('Inval search input');
-        });
-    });
-    it('Should return a search list response of the required search input',
-    () => {
-      const query = 'jame';
-      request(server)
-      .get(`/api/v1/search/users/?q=${query}`)
-      .set({ authorization: userToken })
-      .end((err, res) => {
-        expect(res.status).to.equal(200);
-        expect(res.body.fullName).to.eql('jame doe');
-        expect(res.body.userName).to.eql('testdoe');
-      });
-    });
-  });
-  describe('/SEARCH/documents/?q=', () => {
-    it('Should return an error if no querystring is provided', () => {
-      const query = '';
-      request(server)
-        .get(`/api/v1/search/document/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.property('message').to.equal('Invalid search input')
-        });
-      });
-     it('Should return a search list of the required search input', () => {
-       const query = 'John';
-       request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(200);
-          expect(res.body).to.have.property('document');
-          expect(res.body.document[0]).to.have.property('title').to.equal('John Doe');
-          expect(res.body.document[0]).to.have.property('content').to.equal('eze goes to school');
-          expect(res.body).to.have.property('pagination');
-          expect(res.body.paginaton).to.have.property('totalCount').to.equal(1);
-        });
-     });
-     it('Should throw an error if the searched document is not found', () => {
-       const query = 'jk';
-       request(server)
-        .get(`/api/v1/search/documents/?q=${query}`)
-        .set({ authorization: userToken })
-        .end((err, res) => {
-          expect(res.status).to.equal(404);
-          expect(res.body).to.have.property('message').to.equal('Document not found');
-        });
-     });
-   });
-});
- 
-
-
- - - - - - - diff --git a/coverage/document-manager/server/test/user.spec.js.html b/coverage/document-manager/server/test/user.spec.js.html deleted file mode 100644 index 3d7d402..0000000 --- a/coverage/document-manager/server/test/user.spec.js.html +++ /dev/null @@ -1,1235 +0,0 @@ - - - - Code coverage report for document-manager/server/test/user.spec.js - - - - - - - -
-
-

- All files / document-manager/server/test user.spec.js -

-
-
- 98.58% - Statements - 209/212 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 64/64 -
-
- 98.57% - Lines - 207/210 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 -254 -255 -256 -257 -258 -259 -260 -261 -262 -263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 -308 -309 -310 -311 -312 -313 -314 -315 -316 -317 -318 -319 -320 -321 -322 -323 -324 -325 -326 -327 -328 -329 -330 -331 -332 -333 -334 -335 -336 -337 -338 -339 -340 -341 -342 -343 -344 -345 -346 -347 -348 -349 -350 -351 -352 -353 -354 -355 -356 -357 -358 -359 -360 -361 -362 -363 -364 -365 -366 -367 -368 -369 -370 -371 -372 -373 -374 -375 -376 -377 -378 -379 -380 -381 -382 -383 -384 -385 -386 -387 -388 -389 -390 -3911x -1x -1x -1x -1x -1x -  -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -  -  -1x -1x -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -  -1x -1x -  -1x -1x -  -1x -  -  -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -1x -1x -  -  -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -  -1x -1x -  -  -  -1x -  -  -  -1x -  -1x -  -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -  -  -  -  -1x -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -  -  -1x -1x -1x -1x -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -1x -  -  -1x -1x -  -  -  -  -1x -1x -1x -  -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -  -  -1x -  -1x -1x -  -  -  -1x -1x -  -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -  -1x -1x -1x -1x -  -  -1x -  -1x -1x -  -  -1x -1x -1x -1x -1x -  -  -1x -1x -1x -  -  -  -1x -1x -1x -1x -1x -  -1x -  -  -  -  -  - 
import chai from 'chai';
-import request from 'supertest';
-import http from 'chai-http';
-import server from '../../index';
-import models from '../models';
-import data from './mockData';
- 
-const expect = chai.expect;
-chai.use(http);
-let userToken, adminToken, sampleUserToken;
-const { admin, fakeBass, fellow, user1, user2 } = data;
- 
-describe('Users', () => {
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(admin)
-        .end((err, res) => {
-          adminToken = res.body.token;
-          done();
-        });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send(fellow)
-      .end((err, res) => {
-        userToken = res.body.token;
-        done();
-      });
-  });
-  before((done) => {
-    request(server)
-      .post('/api/v1/users/login')
-      .send({ email: 'blessing@test.com', password: 'pass123' })
-      .end((err, res) => {
-        sampleUserToken = res.body.token;
-        done();
-      });
-  });
- 
-  describe('/POST User login', () => {
-    it('Should fail if the user enters incorrect crendentials upon login',
-    (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user1)
-        .end((err, res) => {
-          expect(res.status).to.equal(400);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. User not found.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('Should fail if the user provide a wrong password', (done) => {
-      request(server)
-        .post('/api/v1/users/login')
-        .send(user2)
-        .end((err, res) => {
-          expect(res.status).to.equal(401);
-          expect(res.body).to.have.keys(['message', 'success']);
-          expect(res.body.message)
-          .to.eql('Authentication failed. Wrong password.');
-          expect(res.body.success).to.eql(false);
-          done();
-        });
-    });
- 
-    it('should log in a user and return a token', (done) => {
-      request(server)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['success', 'token']);
-          expect(res.body.success).to.eql(true);
-          done();
-        });
-    });
- 
-    describe('/POST User Signup', () => {
-      it('should create a new user', (done) => {
-        request(server)
-          .post('/api/v1/users/').send(fakeBass).end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body)
-              .to.have.keys(['message', 'success', 'userDetails']);
-            expect(res.body.success).to.eql(true);
-            expect(res.body.message)
-            .to.eql('You have successfully registered.');
-            done();
-          });
-      });
-    });
- 
-    describe('#GET Users', () => {
-      it('Should get all users if the user is an admin ', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body).to.have.keys(['user', 'pagination']);
-            done();
-          });
-      });
-      it('Should fail to get all users if the user has no admin access ',
-      (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('You are not authorized');
-            done();
-          });
-      });
-      it('Should fail to get all users if no token was provided', (done) => {
-        request(server)
-          .get('/api/v1/users')
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            done();
-          });
-      });
-      it('Should get all users with correct limit as a query', (done) => {
-        const limit = 1;
-        chai.request(server)
-          .get(`/api/v1/users?limit=${limit}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.user[0].fullName).to.equal('Baas Bank');
-            expect(res.body.user[0].userName).to.equal('bank');
-            done();
-          });
-      });
-    });
-    describe('#GET User by Id', () => {
-      it('Should get a user if the user is an admin', (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).to.eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should get the user if the requested user is the current user',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('array');
-            expect(res.body[0].fullName).to.eql('John Bosco');
-            expect(res.body[0].id).eql(2);
-            expect(res.body[0].userName).to.eql('john');
-            expect(res.body[0].email).to.eql('john@test.com');
-            expect(res.body[0].roleId).to.eql(2);
-            done();
-          });
-      });
-      it('Should fail to get a user if an invalid input is entered',
-      (done) => {
-        const id = 'fddjsdcdjn';
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.property('message')
-            .to.eql(`invalid input syntax for integer: "${id}"`);
-            done();
-          });
-      });
-      it('should fail to get the user if the requester is not the owner',
-      (done) => {
-        const id = 2;
-        request(server)
-          .get(`api/users/${id}`)
-          .set({ authorization: sampleUserToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.have.keys(['message']);
-            expect(res.body.message).to.eql('Unauthorized access');
-          });
-        done();
-      });
-      it('Should fail to get a user if the user does not exist',
-      (done) => {
-        const id = 250;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.have.property('message');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get a user if the id is out of range',
-      (done) => {
-        const id = 500000000000000000;
-        request(server)
-          .get(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(400);
-            expect(res.body).to.have.property('message')
-            .to.equal(`value "${id}" is out of range for type integer`);
-            done();
-          });
-      });
-    });
-    describe('#PUT Update user by Id', () => {
-      it('Should update a user`s full name if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ fullName: 'jake doe' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.fullName).to.eql('jake doe');
-              done();
-            });
-        });
-      it('Should update a user`s email if the user has the same id', (done) => {
-        const id = 2;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).to.be.a('object');
-            expect(res.body.id).to.eql(2);
-            expect(res.body.email).to.eql('jakedoe@andela.com');
-            done();
-          });
-      });
-      it('Should update a user`s username if the user has the same id',
-        (done) => {
-          const id = 2;
-          request(server)
-            .put(`/api/v1/users/${id}`)
-            .set({ authorization: userToken })
-            .send({ userName: 'jakedoe12' })
-            .end((err, res) => {
-              expect(res.status).to.equal(200);
-              expect(res.body).to.be.a('object');
-              expect(res.body.id).to.eql(2);
-              expect(res.body.userName).to.eql('jakedoe12');
-              done();
-            });
-        });
-      it(`Should fail to update a user's
-      details if the user does not have the same user id`,
-      (done) => {
-        const id = 3;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-      it(`Should fail to update a user's
-        details if the user enters an invalid user id`,
-      (done) => {
-        const id = 2302;
-        request(server)
-          .put(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .send({ email: 'jakedoe@andela.com' })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this user');
-            done();
-          });
-      });
-    });
-    describe('#DELETE /:id Users', () => {
-      it('Should delete a user given the user has admin access', (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(204);
-            done();
-          });
-      });
-      it('Should fail to delete a user if the user has no admin access',
-      (done) => {
-        const id = 3;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(401);
-            expect(res.body.message)
-            .to.eql('You are not authorized to access this field');
-            done();
-          });
-      });
-      it('Should give a User not found if user don\'t exist', (done) => {
-        const id = 23;
-        request(server)
-          .delete(`/api/v1/users/${id}`)
-          .set({ authorization: adminToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).to.be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-    });
-    describe('/GET/users/:id/documents Documents', () => {
-      it('Should fail to get documents if the user does not exist', (done) => {
-        const userId = 9;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(404);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('User not found');
-            done();
-          });
-      });
-      it('Should fail to get documents if there is no token present',
-      (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .end((err, res) => {
-            expect(res.status).to.equal(403);
-            expect(res.body).be.a('object');
-            expect(res.body.message).to.eql('No token provided.');
-            expect(res.body.success).to.eql(false);
-            done();
-          });
-      });
-      it('Should get documents for the user with its unique userId', (done) => {
-        const userId = 2;
-        request(server)
-          .get(`/api/v1/users/${userId}/documents`)
-          .set({ authorization: userToken })
-          .end((err, res) => {
-            expect(res.status).to.equal(200);
-            expect(res.body).be.a('object');
-            expect(res.body.document[1].userId).to.eql(2);
-            expect(res.body.document[1].title).to.eql('boromir-team');
-            expect(res.body.document[1].content)
-            .to.eql('Andela is really awesome!!!');
-            done();
-          });
-      });
-    });
-  });
-});
- 
-
-
- - - - - - - diff --git a/coverage/gulpfile.babel.js.html b/coverage/gulpfile.babel.js.html deleted file mode 100644 index 479875a..0000000 --- a/coverage/gulpfile.babel.js.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Code coverage report for gulpfile.babel.js - - - - - - - -
-
-

- All files gulpfile.babel.js -

-
-
- 78.57% - Statements - 11/14 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/3 -
-
- 91.67% - Lines - 11/12 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -401x -1x -  -1x -1x -  -  -1x -  -1x -  -  -  -  -1x -  -  -  -  -  -1x -  -  -  -  -  -  -  -1x -  -  -  -  -  -  -  -  -1x -1x - 
import gulp from 'gulp';
-import mocha from 'gulp-mocha';
- 
-import loadPlugins from 'gulp-load-plugins';
-import path from 'path';
- 
-// Load the gulp plugins into the `plugins` variable
-const plugins = loadPlugins();
- 
-const paths = {
-  js: ['./**/*.js', '!dist/**', '!node_modules/**']
-};
- 
-// Compile all Babel Javascript into ES5 and put it into the dist dir
-gulp.task('babel', () =>
-  gulp.src(paths.js, { base: '.' })
-    .pipe(plugins.babel())
-    .pipe(gulp.dest('dist'))
-);
- 
-gulp.task('mochaTest', () => {
-  gulp.src(['server/test/**/*.js'])
-    .pipe(mocha({
-      reporter: 'spec',
-    }));
-});
- 
-// Start server with restart on file change events
-gulp.task('nodemon', ['babel'], () =>
-  plugins.nodemon({
-    script: path.join('dist', 'index.js'),
-    ext: 'js',
-    ignore: ['README.md', '.DS_Store', 'node_modules/**/*.js', 'dist/**/*.js'],
-    tasks: ['babel']
-  })
-);
- 
-gulp.task('test', ['mochaTest']);
-gulp.task('default', ['nodemon']);
- 
-
-
- - - - - - - diff --git a/coverage/index.html b/coverage/index.html deleted file mode 100644 index 010797d..0000000 --- a/coverage/index.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - Code coverage report for All files - - - - - - - -
-
-

- All files -

-
-
- 93.42% - Statements - 895/958 -
-
- 80.29% - Branches - 110/137 -
-
- 89.55% - Functions - 257/287 -
-
- 93.35% - Lines - 885/948 -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
document-manager
100%4/4100%2/2100%1/1100%4/4
document-manager/server/config
100%21/21100%2/2100%2/2100%20/20
document-manager/server/controllers
80.95%187/23180.17%93/11665.48%55/8480.95%187/231
document-manager/server/helpers
100%3/3100%0/0100%1/1100%2/2
document-manager/server/middlewares
92.31%12/1387.5%7/8100%3/392.31%12/13
document-manager/server/models
97.5%39/4066.67%6/9100%9/997.5%39/40
document-manager/server/routes
100%36/36100%0/0100%0/0100%36/36
document-manager/server/test/controllers
97.21%593/610100%0/099.47%186/18797.18%585/602
-
-
- - - - - - - diff --git a/coverage/mockData.js.html b/coverage/mockData.js.html deleted file mode 100644 index f3adac1..0000000 --- a/coverage/mockData.js.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - Code coverage report for mockData.js - - - - - - - -
-
-

- All files mockData.js -

-
-
- 100% - Statements - 2/2 -
-
- 100% - Branches - 0/0 -
-
- 100% - Functions - 0/0 -
-
- 100% - Lines - 2/2 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -451x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import dotenv from 'dotenv';
- 
-dotenv.config();
- 
-export default {
-  admin: {
-    email: 'baas@test.com',
-    password: process.env.TEST_ADMIN_PASSWORD
-  },
-  fellow: {
-    email: 'john@test.com',
-    password: process.env.TEST_FELLOW_PASSWORD
-  },
-  faciliatator: {
-    email: 'blessing@test.com',
-    password: process.env.TEST_FACILITATOR_PASSWORD
-  },
-  user2: {
-    email: 'baas@test.com',
-    password: 'test'
-  },
-  user1: {
-    email: 'test@test123.com',
-    password: 'test'
-  },
-  fakeBass: {
-    fullName: 'Baasbank Adams',
-    userName: 'tiaandela',
-    email: 'name@example.com',
-    password: 'pass123',
-    roleId: 1,
-    createdAt: new Date(),
-    updatedAt: new Date()
-  },
-  fakeUserDetails: {
-    fullName: 'Daniel Cfh',
-    userName: 'cfh',
-    email: 'cfh@example.com',
-    password: 'pass123',
-    roleId: 2,
-    createdAt: 'date',
-    updatedAt: new Date()
-  },
-};
- 
-
-
- - - - - - - diff --git a/coverage/prettify.css b/coverage/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/prettify.js b/coverage/prettify.js deleted file mode 100644 index ef51e03..0000000 --- a/coverage/prettify.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/sort-arrow-sprite.png b/coverage/sort-arrow-sprite.png deleted file mode 100644 index 03f704a609c6fd0dbfdac63466a7d7c958b5cbf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^>_9Bd!3HEZxJ@+%Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS>Jii$m5978H@?Fn+^JD|Y9yzj{W`447Gxa{7*dM7nnnD-Lb z6^}Hx2)'; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function (a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function (a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i =0 ; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/coverage/user.spec.js.html b/coverage/user.spec.js.html deleted file mode 100644 index c42313f..0000000 --- a/coverage/user.spec.js.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - Code coverage report for user.spec.js - - - - - - - -
-
-

- All files user.spec.js -

-
-
- 6.67% - Statements - 1/15 -
-
- 100% - Branches - 0/0 -
-
- 0% - Functions - 0/5 -
-
- 6.67% - Lines - 1/15 -
-
-
-
-

-
-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -391x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
import models from '../../models/';
-import data from '../mockData';
- 
- 
-const expect = chai.expect;
-chai.use(http);
- 
-const { admin, incompleteLoginCredentials, fakeEsther } = data;
-// , superUser, regularUser, fakeEsther, fakeUserDetails
- 
-describe('Users', () => {
-  after((done) => {
-    models.User.destroy({ where: { id: { $notIn: [1, 2, 3] } } });
-    done();
-  });
-  describe('user login endpoint', () => {
-    it('should log in a user and return a token', (done) => {
-      chai.request(app)
-        .post('/api/v1/users/login').send(admin).end((err, res) => {
-          expect(res.status).to.equal(201);
-          expect(res.body).to.have.keys(['message', 'token']);
-          expect(res.body.message).to.eql('login successful');
-          done();
-        });
-    });
-  // describe('user sign up endpoint', () => {
-  //   it('should create a new user', (done) => {
-  //     chai.request(app)
-  //       .post('/api/v1/users/').send(fakeEsther).end((err, res) => {
-  //         console.log("here?", res.status);
-  //         expect(res.status).to.equal(201);
-  //         expect(res.body).to.have.keys(['message', 'user', 'token']);
-  //         expect(res.body.message).to.eql('signup successful');
-  //         done();
-  //       });
-  //   });
-  });
-});
- 
-
-
- - - - - - - From e339055343a6c67c70ecc0ee30b729b7ae06a246 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:26:44 +0100 Subject: [PATCH 46/98] remove dist --- dist/coverage/prettify.js | 363 ------------------ dist/coverage/sorter.js | 169 -------- dist/gulpfile.babel.js | 73 ---- dist/index.js | 19 - dist/server/config/config.js | 27 -- dist/server/config/express.js | 51 --- dist/server/controllers/documents.js | 241 ------------ dist/server/controllers/roles.js | 142 ------- dist/server/controllers/search.js | 148 ------- dist/server/controllers/users.js | 300 --------------- dist/server/helpers/helper.js | 12 - dist/server/middlewares/auth.js | 44 --- .../migrations/20170709115213-create-role.js | 30 -- .../migrations/20170709115254-create-user.js | 54 --- .../20170709120158-create-document.js | 46 --- dist/server/models/document.js | 29 -- dist/server/models/index.js | 41 -- dist/server/models/role.js | 17 - dist/server/models/user.js | 41 -- dist/server/routes/documents.js | 40 -- dist/server/routes/index.js | 37 -- dist/server/routes/roles.js | 40 -- dist/server/routes/search.js | 31 -- dist/server/routes/users.js | 48 --- .../seeders/20170727152600-sample-roles.js | 23 -- .../seeders/20170727153559-sample-users.js | 38 -- .../20170727153641-sample-documents.js | 32 -- dist/server/test/controllers/document.spec.js | 297 -------------- dist/server/test/controllers/mockData.js | 63 --- dist/server/test/controllers/role.spec.js | 257 ------------- dist/server/test/controllers/search.spec.js | 104 ----- dist/server/test/controllers/user.spec.js | 306 --------------- 32 files changed, 3163 deletions(-) delete mode 100644 dist/coverage/prettify.js delete mode 100644 dist/coverage/sorter.js delete mode 100644 dist/gulpfile.babel.js delete mode 100644 dist/index.js delete mode 100644 dist/server/config/config.js delete mode 100644 dist/server/config/express.js delete mode 100644 dist/server/controllers/documents.js delete mode 100644 dist/server/controllers/roles.js delete mode 100644 dist/server/controllers/search.js delete mode 100644 dist/server/controllers/users.js delete mode 100644 dist/server/helpers/helper.js delete mode 100644 dist/server/middlewares/auth.js delete mode 100644 dist/server/migrations/20170709115213-create-role.js delete mode 100644 dist/server/migrations/20170709115254-create-user.js delete mode 100644 dist/server/migrations/20170709120158-create-document.js delete mode 100644 dist/server/models/document.js delete mode 100644 dist/server/models/index.js delete mode 100644 dist/server/models/role.js delete mode 100644 dist/server/models/user.js delete mode 100644 dist/server/routes/documents.js delete mode 100644 dist/server/routes/index.js delete mode 100644 dist/server/routes/roles.js delete mode 100644 dist/server/routes/search.js delete mode 100644 dist/server/routes/users.js delete mode 100644 dist/server/seeders/20170727152600-sample-roles.js delete mode 100644 dist/server/seeders/20170727153559-sample-users.js delete mode 100644 dist/server/seeders/20170727153641-sample-documents.js delete mode 100644 dist/server/test/controllers/document.spec.js delete mode 100644 dist/server/test/controllers/mockData.js delete mode 100644 dist/server/test/controllers/role.spec.js delete mode 100644 dist/server/test/controllers/search.spec.js delete mode 100644 dist/server/test/controllers/user.spec.js diff --git a/dist/coverage/prettify.js b/dist/coverage/prettify.js deleted file mode 100644 index 17e401d..0000000 --- a/dist/coverage/prettify.js +++ /dev/null @@ -1,363 +0,0 @@ -"use strict"; - -window.PR_SHOULD_USE_CONTINUATION = true;(function () { - var h = ["break,continue,do,else,for,if,return,while"];var u = [h, "auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p = [u, "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l = [p, "alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x = [p, "abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R = [x, "as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r = "all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w = [p, "debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I = [h, "and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f = [h, "alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H = [h, "case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A = [l, R, w, s + I, f, H];var e = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C = "str";var z = "kwd";var j = "com";var O = "typ";var G = "lit";var L = "pun";var F = "pln";var m = "tag";var E = "dec";var J = "src";var P = "atn";var n = "atv";var N = "nocode";var M = "(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z) { - var ad = 0;var S = false;var ac = false;for (var V = 0, U = Z.length; V < U; ++V) { - var ae = Z[V];if (ae.ignoreCase) { - ac = true; - } else { - if (/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ""))) { - S = true;ac = false;break; - } - } - }var Y = { b: 8, t: 9, n: 10, v: 11, f: 12, r: 13 };function ab(ah) { - var ag = ah.charCodeAt(0);if (ag !== 92) { - return ag; - }var af = ah.charAt(1);ag = Y[af];if (ag) { - return ag; - } else { - if ("0" <= af && af <= "7") { - return parseInt(ah.substring(1), 8); - } else { - if (af === "u" || af === "x") { - return parseInt(ah.substring(2), 16); - } else { - return ah.charCodeAt(1); - } - } - } - }function T(af) { - if (af < 32) { - return (af < 16 ? "\\x0" : "\\x") + af.toString(16); - }var ag = String.fromCharCode(af);if (ag === "\\" || ag === "-" || ag === "[" || ag === "]") { - ag = "\\" + ag; - }return ag; - }function X(am) { - var aq = am.substring(1, am.length - 1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));var ak = [];var af = [];var ao = aq[0] === "^";for (var ar = ao ? 1 : 0, aj = aq.length; ar < aj; ++ar) { - var ah = aq[ar];if (/\\[bdsw]/i.test(ah)) { - ak.push(ah); - } else { - var ag = ab(ah);var al;if (ar + 2 < aj && "-" === aq[ar + 1]) { - al = ab(aq[ar + 2]);ar += 2; - } else { - al = ag; - }af.push([ag, al]);if (!(al < 65 || ag > 122)) { - if (!(al < 65 || ag > 90)) { - af.push([Math.max(65, ag) | 32, Math.min(al, 90) | 32]); - }if (!(al < 97 || ag > 122)) { - af.push([Math.max(97, ag) & ~32, Math.min(al, 122) & ~32]); - } - } - } - }af.sort(function (av, au) { - return av[0] - au[0] || au[1] - av[1]; - });var ai = [];var ap = [NaN, NaN];for (var ar = 0; ar < af.length; ++ar) { - var at = af[ar];if (at[0] <= ap[1] + 1) { - ap[1] = Math.max(ap[1], at[1]); - } else { - ai.push(ap = at); - } - }var an = ["["];if (ao) { - an.push("^"); - }an.push.apply(an, ak);for (var ar = 0; ar < ai.length; ++ar) { - var at = ai[ar];an.push(T(at[0]));if (at[1] > at[0]) { - if (at[1] + 1 > at[0]) { - an.push("-"); - }an.push(T(at[1])); - } - }an.push("]");return an.join(""); - }function W(al) { - var aj = al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g"));var ah = aj.length;var an = [];for (var ak = 0, am = 0; ak < ah; ++ak) { - var ag = aj[ak];if (ag === "(") { - ++am; - } else { - if ("\\" === ag.charAt(0)) { - var af = +ag.substring(1);if (af && af <= am) { - an[af] = -1; - } - } - } - }for (var ak = 1; ak < an.length; ++ak) { - if (-1 === an[ak]) { - an[ak] = ++ad; - } - }for (var ak = 0, am = 0; ak < ah; ++ak) { - var ag = aj[ak];if (ag === "(") { - ++am;if (an[am] === undefined) { - aj[ak] = "(?:"; - } - } else { - if ("\\" === ag.charAt(0)) { - var af = +ag.substring(1);if (af && af <= am) { - aj[ak] = "\\" + an[am]; - } - } - } - }for (var ak = 0, am = 0; ak < ah; ++ak) { - if ("^" === aj[ak] && "^" !== aj[ak + 1]) { - aj[ak] = ""; - } - }if (al.ignoreCase && S) { - for (var ak = 0; ak < ah; ++ak) { - var ag = aj[ak];var ai = ag.charAt(0);if (ag.length >= 2 && ai === "[") { - aj[ak] = X(ag); - } else { - if (ai !== "\\") { - aj[ak] = ag.replace(/[a-zA-Z]/g, function (ao) { - var ap = ao.charCodeAt(0);return "[" + String.fromCharCode(ap & ~32, ap | 32) + "]"; - }); - } - } - } - }return aj.join(""); - }var aa = [];for (var V = 0, U = Z.length; V < U; ++V) { - var ae = Z[V];if (ae.global || ae.multiline) { - throw new Error("" + ae); - }aa.push("(?:" + W(ae) + ")"); - }return new RegExp(aa.join("|"), ac ? "gi" : "g"); - }function a(V) { - var U = /(?:^|\s)nocode(?:\s|$)/;var X = [];var T = 0;var Z = [];var W = 0;var S;if (V.currentStyle) { - S = V.currentStyle.whiteSpace; - } else { - if (window.getComputedStyle) { - S = document.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); - } - }var Y = S && "pre" === S.substring(0, 3);function aa(ab) { - switch (ab.nodeType) {case 1: - if (U.test(ab.className)) { - return; - }for (var ae = ab.firstChild; ae; ae = ae.nextSibling) { - aa(ae); - }var ad = ab.nodeName;if ("BR" === ad || "LI" === ad) { - X[W] = "\n";Z[W << 1] = T++;Z[W++ << 1 | 1] = ab; - }break;case 3:case 4: - var ac = ab.nodeValue;if (ac.length) { - if (!Y) { - ac = ac.replace(/[ \t\r\n]+/g, " "); - } else { - ac = ac.replace(/\r\n?/g, "\n"); - }X[W] = ac;Z[W << 1] = T;T += ac.length;Z[W++ << 1 | 1] = ab; - }break;} - }aa(V);return { sourceCode: X.join("").replace(/\n$/, ""), spans: Z }; - }function B(S, U, W, T) { - if (!U) { - return; - }var V = { sourceCode: U, basePos: S };W(V);T.push.apply(T, V.decorations); - }var v = /\S/;function o(S) { - var V = undefined;for (var U = S.firstChild; U; U = U.nextSibling) { - var T = U.nodeType;V = T === 1 ? V ? S : U : T === 3 ? v.test(U.nodeValue) ? S : V : V; - }return V === S ? undefined : V; - }function g(U, T) { - var S = {};var V;(function () { - var ad = U.concat(T);var ah = [];var ag = {};for (var ab = 0, Z = ad.length; ab < Z; ++ab) { - var Y = ad[ab];var ac = Y[3];if (ac) { - for (var ae = ac.length; --ae >= 0;) { - S[ac.charAt(ae)] = Y; - } - }var af = Y[1];var aa = "" + af;if (!ag.hasOwnProperty(aa)) { - ah.push(af);ag[aa] = null; - } - }ah.push(/[\0-\uffff]/);V = k(ah); - })();var X = T.length;var W = function W(ah) { - var Z = ah.sourceCode, - Y = ah.basePos;var ad = [Y, F];var af = 0;var an = Z.match(V) || [];var aj = {};for (var ae = 0, aq = an.length; ae < aq; ++ae) { - var ag = an[ae];var ap = aj[ag];var ai = void 0;var am;if (typeof ap === "string") { - am = false; - } else { - var aa = S[ag.charAt(0)];if (aa) { - ai = ag.match(aa[1]);ap = aa[0]; - } else { - for (var ao = 0; ao < X; ++ao) { - aa = T[ao];ai = ag.match(aa[1]);if (ai) { - ap = aa[0];break; - } - }if (!ai) { - ap = F; - } - }am = ap.length >= 5 && "lang-" === ap.substring(0, 5);if (am && !(ai && typeof ai[1] === "string")) { - am = false;ap = J; - }if (!am) { - aj[ag] = ap; - } - }var ab = af;af += ag.length;if (!am) { - ad.push(Y + ab, ap); - } else { - var al = ai[1];var ak = ag.indexOf(al);var ac = ak + al.length;if (ai[2]) { - ac = ag.length - ai[2].length;ak = ac - al.length; - }var ar = ap.substring(5);B(Y + ab, ag.substring(0, ak), W, ad);B(Y + ab + ak, al, q(ar, al), ad);B(Y + ab + ac, ag.substring(ac), W, ad); - } - }ah.decorations = ad; - };return W; - }function i(T) { - var W = [], - S = [];if (T.tripleQuotedStrings) { - W.push([C, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, null, "'\""]); - } else { - if (T.multiLineStrings) { - W.push([C, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, null, "'\"`"]); - } else { - W.push([C, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, "\"'"]); - } - }if (T.verbatimStrings) { - S.push([C, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]); - }var Y = T.hashComments;if (Y) { - if (T.cStyleComments) { - if (Y > 1) { - W.push([j, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, "#"]); - } else { - W.push([j, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, "#"]); - }S.push([C, /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, null]); - } else { - W.push([j, /^#[^\r\n]*/, null, "#"]); - } - }if (T.cStyleComments) { - S.push([j, /^\/\/[^\r\n]*/, null]);S.push([j, /^\/\*[\s\S]*?(?:\*\/|$)/, null]); - }if (T.regexLiterals) { - var X = "/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/";S.push(["lang-regex", new RegExp("^" + M + "(" + X + ")")]); - }var V = T.types;if (V) { - S.push([O, V]); - }var U = ("" + T.keywords).replace(/^ | $/g, "");if (U.length) { - S.push([z, new RegExp("^(?:" + U.replace(/[\s,]+/g, "|") + ")\\b"), null]); - }W.push([F, /^\s+/, null, " \r\n\t\xA0"]);S.push([G, /^@[a-z_$][a-z_$@0-9]*/i, null], [O, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null], [F, /^[a-z_$][a-z_$@0-9]*/i, null], [G, new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*", "i"), null, "0123456789"], [F, /^\\[\s\S]?/, null], [L, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);return g(W, S); - }var K = i({ keywords: A, hashComments: true, cStyleComments: true, multiLineStrings: true, regexLiterals: true });function Q(V, ag) { - var U = /(?:^|\s)nocode(?:\s|$)/;var ab = /\r\n?|\n/;var ac = V.ownerDocument;var S;if (V.currentStyle) { - S = V.currentStyle.whiteSpace; - } else { - if (window.getComputedStyle) { - S = ac.defaultView.getComputedStyle(V, null).getPropertyValue("white-space"); - } - }var Z = S && "pre" === S.substring(0, 3);var af = ac.createElement("LI");while (V.firstChild) { - af.appendChild(V.firstChild); - }var W = [af];function ae(al) { - switch (al.nodeType) {case 1: - if (U.test(al.className)) { - break; - }if ("BR" === al.nodeName) { - ad(al);if (al.parentNode) { - al.parentNode.removeChild(al); - } - } else { - for (var an = al.firstChild; an; an = an.nextSibling) { - ae(an); - } - }break;case 3:case 4: - if (Z) { - var am = al.nodeValue;var aj = am.match(ab);if (aj) { - var ai = am.substring(0, aj.index);al.nodeValue = ai;var ah = am.substring(aj.index + aj[0].length);if (ah) { - var ak = al.parentNode;ak.insertBefore(ac.createTextNode(ah), al.nextSibling); - }ad(al);if (!ai) { - al.parentNode.removeChild(al); - } - } - }break;} - }function ad(ak) { - while (!ak.nextSibling) { - ak = ak.parentNode;if (!ak) { - return; - } - }function ai(al, ar) { - var aq = ar ? al.cloneNode(false) : al;var ao = al.parentNode;if (ao) { - var ap = ai(ao, 1);var an = al.nextSibling;ap.appendChild(aq);for (var am = an; am; am = an) { - an = am.nextSibling;ap.appendChild(am); - } - }return aq; - }var ah = ai(ak.nextSibling, 0);for (var aj; (aj = ah.parentNode) && aj.nodeType === 1;) { - ah = aj; - }W.push(ah); - }for (var Y = 0; Y < W.length; ++Y) { - ae(W[Y]); - }if (ag === (ag | 0)) { - W[0].setAttribute("value", ag); - }var aa = ac.createElement("OL");aa.className = "linenums";var X = Math.max(0, ag - 1 | 0) || 0;for (var Y = 0, T = W.length; Y < T; ++Y) { - af = W[Y];af.className = "L" + (Y + X) % 10;if (!af.firstChild) { - af.appendChild(ac.createTextNode("\xA0")); - }aa.appendChild(af); - }V.appendChild(aa); - }function D(ac) { - var aj = /\bMSIE\b/.test(navigator.userAgent);var am = /\n/g;var al = ac.sourceCode;var an = al.length;var V = 0;var aa = ac.spans;var T = aa.length;var ah = 0;var X = ac.decorations;var Y = X.length;var Z = 0;X[Y] = an;var ar, aq;for (aq = ar = 0; aq < Y;) { - if (X[aq] !== X[aq + 2]) { - X[ar++] = X[aq++];X[ar++] = X[aq++]; - } else { - aq += 2; - } - }Y = ar;for (aq = ar = 0; aq < Y;) { - var at = X[aq];var ab = X[aq + 1];var W = aq + 2;while (W + 2 <= Y && X[W + 1] === ab) { - W += 2; - }X[ar++] = at;X[ar++] = ab;aq = W; - }Y = X.length = ar;var ae = null;while (ah < T) { - var af = aa[ah];var S = aa[ah + 2] || an;var ag = X[Z];var ap = X[Z + 2] || an;var W = Math.min(S, ap);var ak = aa[ah + 1];var U;if (ak.nodeType !== 1 && (U = al.substring(V, W))) { - if (aj) { - U = U.replace(am, "\r"); - }ak.nodeValue = U;var ai = ak.ownerDocument;var ao = ai.createElement("SPAN");ao.className = X[Z + 1];var ad = ak.parentNode;ad.replaceChild(ao, ak);ao.appendChild(ak);if (V < S) { - aa[ah + 1] = ak = ai.createTextNode(al.substring(W, S));ad.insertBefore(ak, ao.nextSibling); - } - }V = W;if (V >= S) { - ah += 2; - }if (V >= ap) { - Z += 2; - } - } - }var t = {};function c(U, V) { - for (var S = V.length; --S >= 0;) { - var T = V[S];if (!t.hasOwnProperty(T)) { - t[T] = U; - } else { - if (window.console) { - console.warn("cannot override language handler %s", T); - } - } - } - }function q(T, S) { - if (!(T && t.hasOwnProperty(T))) { - T = /^\s*]*(?:>|$)/], [j, /^<\!--[\s\S]*?(?:-\->|$)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], [L, /^(?:<[%?]|[%?]>)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i]]), ["default-markup", "htm", "html", "mxml", "xhtml", "xml", "xsl"]);c(g([[F, /^[\s]+/, null, " \t\r\n"], [n, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, "\"'"]], [[m, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i], [P, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i], ["lang-uq.val", /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/], [L, /^[=<>\/]+/], ["lang-js", /^on\w+\s*=\s*\"([^\"]+)\"/i], ["lang-js", /^on\w+\s*=\s*\'([^\']+)\'/i], ["lang-js", /^on\w+\s*=\s*([^\"\'>\s]+)/i], ["lang-css", /^style\s*=\s*\"([^\"]+)\"/i], ["lang-css", /^style\s*=\s*\'([^\']+)\'/i], ["lang-css", /^style\s*=\s*([^\"\'>\s]+)/i]]), ["in.tag"]);c(g([], [[n, /^[\s\S]+/]]), ["uq.val"]);c(i({ keywords: l, hashComments: true, cStyleComments: true, types: e }), ["c", "cc", "cpp", "cxx", "cyc", "m"]);c(i({ keywords: "null,true,false" }), ["json"]);c(i({ keywords: R, hashComments: true, cStyleComments: true, verbatimStrings: true, types: e }), ["cs"]);c(i({ keywords: x, cStyleComments: true }), ["java"]);c(i({ keywords: H, hashComments: true, multiLineStrings: true }), ["bsh", "csh", "sh"]);c(i({ keywords: I, hashComments: true, multiLineStrings: true, tripleQuotedStrings: true }), ["cv", "py"]);c(i({ keywords: s, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["perl", "pl", "pm"]);c(i({ keywords: f, hashComments: true, multiLineStrings: true, regexLiterals: true }), ["rb"]);c(i({ keywords: w, cStyleComments: true, regexLiterals: true }), ["js"]);c(i({ keywords: r, hashComments: 3, cStyleComments: true, multilineStrings: true, tripleQuotedStrings: true, regexLiterals: true }), ["coffee"]);c(g([], [[C, /^[\s\S]+/]]), ["regex"]);function d(V) { - var U = V.langExtension;try { - var S = a(V.sourceNode);var T = S.sourceCode;V.sourceCode = T;V.spans = S.spans;V.basePos = 0;q(U, T)(V);D(V); - } catch (W) { - if ("console" in window) { - console.log(W && W.stack ? W.stack : W); - } - } - }function y(W, V, U) { - var S = document.createElement("PRE");S.innerHTML = W;if (U) { - Q(S, U); - }var T = { langExtension: V, numberLines: U, sourceNode: S };d(T);return S.innerHTML; - }function b(ad) { - function Y(af) { - return document.getElementsByTagName(af); - }var ac = [Y("pre"), Y("code"), Y("xmp")];var T = [];for (var aa = 0; aa < ac.length; ++aa) { - for (var Z = 0, V = ac[aa].length; Z < V; ++Z) { - T.push(ac[aa][Z]); - } - }ac = null;var W = Date;if (!W.now) { - W = { now: function now() { - return +new Date(); - } }; - }var X = 0;var S;var ab = /\blang(?:uage)?-([\w.]+)(?!\S)/;var ae = /\bprettyprint\b/;function U() { - var ag = window.PR_SHOULD_USE_CONTINUATION ? W.now() + 250 : Infinity;for (; X < T.length && W.now() < ag; X++) { - var aj = T[X];var ai = aj.className;if (ai.indexOf("prettyprint") >= 0) { - var ah = ai.match(ab);var am;if (!ah && (am = o(aj)) && "CODE" === am.tagName) { - ah = am.className.match(ab); - }if (ah) { - ah = ah[1]; - }var al = false;for (var ak = aj.parentNode; ak; ak = ak.parentNode) { - if ((ak.tagName === "pre" || ak.tagName === "code" || ak.tagName === "xmp") && ak.className && ak.className.indexOf("prettyprint") >= 0) { - al = true;break; - } - }if (!al) { - var af = aj.className.match(/\blinenums\b(?::(\d+))?/);af = af ? af[1] && af[1].length ? +af[1] : true : false;if (af) { - Q(aj, af); - }S = { langExtension: ah, sourceNode: aj, numberLines: af };d(S); - } - } - }if (X < T.length) { - setTimeout(U, 250); - } else { - if (ad) { - ad(); - } - } - }U(); - }window.prettyPrintOne = y;window.prettyPrint = b;window.PR = { createSimpleLexer: g, registerLangHandler: c, sourceDecorator: i, PR_ATTRIB_NAME: P, PR_ATTRIB_VALUE: n, PR_COMMENT: j, PR_DECLARATION: E, PR_KEYWORD: z, PR_LITERAL: G, PR_NOCODE: N, PR_PLAIN: F, PR_PUNCTUATION: L, PR_SOURCE: J, PR_STRING: C, PR_TAG: m, PR_TYPE: O }; -})();PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_DECLARATION, /^]*(?:>|$)/], [PR.PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/], [PR.PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/], ["lang-", /^<\?([\s\S]+?)(?:\?>|$)/], ["lang-", /^<%([\s\S]+?)(?:%>|$)/], ["lang-", /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i], ["lang-handlebars", /^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-js", /^]*>([\s\S]*?)(<\/script\b[^>]*>)/i], ["lang-css", /^]*>([\s\S]*?)(<\/style\b[^>]*>)/i], ["lang-in.tag", /^(<\/?[a-z][^<>]*>)/i], [PR.PR_DECLARATION, /^{{[#^>/]?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{&?\s*[\w.][^}]*}}/], [PR.PR_DECLARATION, /^{{{>?\s*[\w.][^}]*}}}/], [PR.PR_COMMENT, /^{{![^}]*}}/]]), ["handlebars", "hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN, /^[ \t\r\n\f]+/, null, " \t\r\n\f"]], [[PR.PR_STRING, /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null], [PR.PR_STRING, /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null], ["lang-css-str", /^url\(([^\)\"\']*)\)/i], [PR.PR_KEYWORD, /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i, null], ["lang-css-kw", /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i], [PR.PR_COMMENT, /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], [PR.PR_COMMENT, /^(?:)/], [PR.PR_LITERAL, /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i], [PR.PR_LITERAL, /^#(?:[0-9a-f]{3}){1,2}/i], [PR.PR_PLAIN, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i], [PR.PR_PUNCTUATION, /^[^\s\w\'\"]+/]]), ["css"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_KEYWORD, /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]), ["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([], [[PR.PR_STRING, /^[^\)\"\']+/]]), ["css-str"]); \ No newline at end of file diff --git a/dist/coverage/sorter.js b/dist/coverage/sorter.js deleted file mode 100644 index 9519297..0000000 --- a/dist/coverage/sorter.js +++ /dev/null @@ -1,169 +0,0 @@ -'use strict'; - -var addSorting = function () { - "use strict"; - - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function sorter(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function finalSorter(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function () { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function () { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(cols); - addSortIndicators(); - enableUI(); - }; -}(); - -window.addEventListener('load', addSorting); \ No newline at end of file diff --git a/dist/gulpfile.babel.js b/dist/gulpfile.babel.js deleted file mode 100644 index a5f150d..0000000 --- a/dist/gulpfile.babel.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -var _gulp = require('gulp'); - -var _gulp2 = _interopRequireDefault(_gulp); - -var _gulpLoadPlugins = require('gulp-load-plugins'); - -var _gulpLoadPlugins2 = _interopRequireDefault(_gulpLoadPlugins); - -var _path = require('path'); - -var _path2 = _interopRequireDefault(_path); - -var _gulpMocha = require('gulp-mocha'); - -var _gulpMocha2 = _interopRequireDefault(_gulpMocha); - -var _gulpExit = require('gulp-exit'); - -var _gulpExit2 = _interopRequireDefault(_gulpExit); - -var _gulpCoveralls = require('gulp-coveralls'); - -var _gulpCoveralls2 = _interopRequireDefault(_gulpCoveralls); - -var _gulpCoverage = require('gulp-coverage'); - -var _gulpCoverage2 = _interopRequireDefault(_gulpCoverage); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Load the gulp plugins into the `plugins` variable -var plugins = (0, _gulpLoadPlugins2.default)(); - -_gulp2.default.task('tests', function () { - _gulp2.default.src('./server/tests/*.js').pipe(plugins.babel()).pipe((0, _gulpMocha2.default)()).pipe((0, _gulpExit2.default)()); -}); - -// Compile all Babel Javascript into ES5 and place in dist folder -var paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**'] -}; - -// Compile all Babel Javascript into ES5 and put it into the dist dir -_gulp2.default.task('babel', function () { - return _gulp2.default.src(paths.js, { base: '.' }).pipe(plugins.babel()).pipe(_gulp2.default.dest('dist')); -}); - -_gulp2.default.task('coverage', function () { - _gulp2.default.src('server/test/**/*.js', { read: false }).pipe(_gulpCoverage2.default.instrument({ - pattern: ['server/controllers/**/*.js'], - debugDirectory: 'debug' - })).pipe((0, _gulpMocha2.default)()).pipe(_gulpCoverage2.default.gather()).pipe(_gulpCoverage2.default.format()).pipe(_gulp2.default.dest('reports')); -}); - -_gulp2.default.task('coveralls', function () { - return _gulp2.default.src('./coverage/lcov').pipe((0, _gulpCoveralls2.default)()); -}); - -// Restart server with on every changes made to file -_gulp2.default.task('nodemon', ['babel'], function () { - return plugins.nodemon({ - script: _path2.default.join('dist', 'index.js'), - ignore: ['README.md', 'node_modules/**/*.js', 'dist/**/*.js'], - ext: 'js', - tasks: ['babel'] - }); -}); - -_gulp2.default.task('test', ['tests']); -_gulp2.default.task('default', ['nodemon']); -_gulp2.default.task('production', ['babel']); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 80c5176..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('./server/config/express'); - -var _express2 = _interopRequireDefault(_express); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var port = process.env.PORT || 3000; - -var server = _express2.default.listen(port, function () { - console.log('API Server started and listening on port 3000'); -}); - -exports.default = server; \ No newline at end of file diff --git a/dist/server/config/config.js b/dist/server/config/config.js deleted file mode 100644 index d3ec778..0000000 --- a/dist/server/config/config.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -module.exports = { - development: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-dev', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' - }, - test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' - }, - production: { - username: 'root', - password: null, - database: 'database_production', - host: '127.0.0.1', - dialect: 'postgres' - } -}; \ No newline at end of file diff --git a/dist/server/config/express.js b/dist/server/config/express.js deleted file mode 100644 index 40c9b7c..0000000 --- a/dist/server/config/express.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _bodyParser = require('body-parser'); - -var _bodyParser2 = _interopRequireDefault(_bodyParser); - -var _morgan = require('morgan'); - -var _morgan2 = _interopRequireDefault(_morgan); - -var _expressValidator = require('express-validator'); - -var _expressValidator2 = _interopRequireDefault(_expressValidator); - -var _routes = require('../routes'); - -var _routes2 = _interopRequireDefault(_routes); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var app = (0, _express2.default)(); - -app.use((0, _morgan2.default)('dev')); - -app.use(_bodyParser2.default.json()); -app.use(_bodyParser2.default.urlencoded({ extended: false })); -app.use((0, _expressValidator2.default)()); - -app.use(function (req, res, next) { - var send = res.send; - var sent = false; - res.send = function (data) { - if (sent) return; - send.bind(res)(data); - sent = true; - }; - next(); -}); - -// mount all routes on /api path -app.use('/api/v1', _routes2.default); - -exports.default = app; \ No newline at end of file diff --git a/dist/server/controllers/documents.js b/dist/server/controllers/documents.js deleted file mode 100644 index 04f90f1..0000000 --- a/dist/server/controllers/documents.js +++ /dev/null @@ -1,241 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var User = _models2.default.User; -var Document = _models2.default.Document; -var metaData = _helper2.default.paginationMetaData; - -/** - * Create documents for users - * @param {object} req - document to be created - * @param {object} res - created document - * @returns {object} - created document - */ -function createDocument(req, res) { - req.check('title', 'Title is required').notEmpty(); - req.check('content', 'Content is required').notEmpty(); - req.check('access', 'accessType is required').notEmpty(); - - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - Document.findAll({ - where: { - title: req.body.title - } - }).then(function (document) { - if (document.length === 0) { - return Document.create({ - title: req.body.title, - content: req.body.content, - access: req.body.value, - userId: req.body.userId - }).then(function (documentResponse) { - return res.status(200).send(documentResponse); - }).catch(function (error) { - return res.status(400).send(error); - }); - } - return res.status(403).json({ - message: 'Document already exists' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Update user document. - * @param {number} req - request id of the document to be updated - * @param {object} res - object of the updated document - * @returns {object} - updated document - */ -function updateDocument(req, res) { - if (isNaN(req.params.id)) { - return res.status(400); - } - var docId = Number(req.params.id); - return Document.findById(docId).then(function (document) { - if (!document) { - return res.status(404).send({ - message: 'Document Not Found' - }); - } - if (Number(document.userId) !== Number(req.decoded.id)) { - return res.status(401).json({ - message: 'You are not authorized to edit this document' - }); - } - return document.update({ - title: req.body.title || document.title, - content: req.body.content || document.content, - access: req.body.value || document.access, - userId: req.body.userId || document.userId - }).then(function () { - return res.status(200).send(document); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Get all documents - * @param {object} req - contains an object of the query, limits and offset - * @param {array} res - array of documents with pagination - * @returns {array} - array of documents - */ -function getAllDocument(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - access: { - $ne: 'private' - } - }, - include: [{ - model: User, - attributes: ['userName', 'roleId'] - }] - }).then(function (_ref) { - var document = _ref.rows, - count = _ref.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - include: [{ - model: User, - attributes: ['userName', 'roleId'], - where: { - roleId: req.decoded.roleId - } - }], - where: { - access: { - $ne: 'private' - } - } - - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Find a document by Id - * @param {number} req - id of the requested document - * @param {object} res - object containg the requested document - * @returns {object} requested document - */ -function findDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - res.status(404).json({ message: 'Document not found' }); - } - if (req.decoded.roleId === 1) { - return document; - } - if (document.access === 'public') { - return res.status(200).send(document); - } - if (document.access === 'private') { - if (document.userId !== req.decoded.id) { - return res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - } - if (document.access === 'role') { - return _models2.default.User.findById(document.userId).then(function (documentOwner) { - if (Number(documentOwner.roleId) !== Number(req.decoded.roleId)) { - return res.status(401).json({ - message: 'You are not authorized to view this document' - }); - } - return res.status(200).send(document); - }).catch(function (error) { - return res.status(400).send(error); - }); - } - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Delete a document by Id - * @param {number} req - id of the requested document - * @param {object} res - message - * @returns {object} - message - */ -function deleteDocument(req, res) { - return Document.findById(req.params.id).then(function (document) { - if (!document) { - return res.status(404).send({ - message: 'Document Not Found' - }); - } - if (req.decoded.roleId !== 1 && Number(document.userId) !== Number(req.decoded.id)) { - return res.status(401).json({ - message: 'You are not authorized to delete this document' - }); - } - return document.destroy().then(function () { - return res.status(204).send({ - message: 'Document successfully deleted' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -exports.default = { - createDocument: createDocument, - updateDocument: updateDocument, - getAllDocument: getAllDocument, - findDocument: findDocument, - deleteDocument: deleteDocument }; \ No newline at end of file diff --git a/dist/server/controllers/roles.js b/dist/server/controllers/roles.js deleted file mode 100644 index a2e80f8..0000000 --- a/dist/server/controllers/roles.js +++ /dev/null @@ -1,142 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var models = require('../models'); - -var Role = models.Role; - -/** - * Creates a new Role. - * @param {object} req - role to be created - * @param {object} res - new created role - * @returns {object} - newly created role - */ -function createRole(req, res) { - req.check('title', 'Title is required').notEmpty(); - - var errors = req.validationErrors(); - if (errors) { - res.status(400).json({ errors: errors }); - } else { - Role.findAll({ - where: { title: req.body.title } - }).then(function (err, existingRole) { - if (!existingRole) { - Role.create({ - title: req.body.title - }).then(function (role) { - res.status(201).send({ - message: 'Role successfully created', - role: role - }); - }).catch(function (error) { - res.json(error.errors); - }); - } - }).catch(function (error) { - return res.json(error); - }); - } -} - -/** - * Get all roles. - * @param {void} req - no request body attached - * @param {array} res - an array of roles and their id - * @returns {array} array of roles - */ -function getRoles(req, res) { - return Role.findAll().then(function (role) { - return res.status(200).json(role); - }).catch(function (error) { - return res.json(error); - }); -} - -/** - * Find roles by Id. - * @param {number} req - requested role - * @param {object} res - role found by id - * @returns {object} - role found by id - */ -function findRole(req, res) { - if (isNaN(req.params.id)) { - return res.status(401).json({ - message: 'invalid input syntax for integer: "' + req.params.id + '"' - }); - } else { - Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - res.status(200).json(role); - }).catch(function (error) { - return res.status(400).json(error); - }); - } -} - -/** - * Update role. - * @param {number} req - requested role by id - * @param {object} res - updated role - * @returns {object} - updated role status - */ -function updateRole(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized to access the role' }); - } - return Role.findById(req.params.id).then(function (role) { - if (!role) { - return res.status(404).json({ - message: 'Role not found' - }); - } - return role.update({ - title: req.body.title || role.title - }).then(function () { - return res.status(200).json({ - message: 'Role updated successfully', - role: role - }); - }).catch(function (error) { - return res.status(400).json(error); - }); - }).catch(function (error) { - return res.status(400).json(error); - }); -} - -/** - * Delete roles by Id. - * @param {number} req - role to be deleted by id - * @param {object} res - deleted role - * @returns {object} - message - */ -function deleteRole(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ message: 'You are not authorized to access the role' }); - } - return Role.findById(req.params.id).then(function (role) { - if (!role) { - res.status(404).json({ - message: 'Role not found' - }); - } - return role.destroy().then(function () { - return res.status(204).send({ - message: 'Role deleted successfully' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.json(error); - }); -} - -exports.default = { createRole: createRole, getRoles: getRoles, findRole: findRole, updateRole: updateRole, deleteRole: deleteRole }; \ No newline at end of file diff --git a/dist/server/controllers/search.js b/dist/server/controllers/search.js deleted file mode 100644 index fa9f13b..0000000 --- a/dist/server/controllers/search.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var Document = _models2.default.Document; -var User = _models2.default.User; -var metaData = _helper2.default.paginationMetaData; - -/** - * Search for user using a query string - * @param {string} req - search query of string - * @param {array} res - array of users - * @returns {array} - array users searched - */ -function searchUser(req, res) { - var searchQuery = req.query.q, - limit = req.query.limit, - offset = req.query.offset; - if (!searchQuery) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - return User.findAndCountAll({ - limit: limit, - offset: offset, - attributes: { exclude: ['password'] }, - where: { - userName: { - $like: '%' + searchQuery + '%' - } - } - }).then(function (_ref) { - var user = _ref.rows, - count = _ref.count; - - if (count === 0) { - return res.status(404).json({ message: 'User not found' }); - } - res.status(200).send({ - user: user, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * - * Search for documents by title - * @param {string} req - an object containing the query, offset and limit - * @param {array} res - an array containing searched document - * @returns {array} - searched document - */ -function searchDocuments(req, res) { - var limit = req.query.limit, - offset = req.query.offset, - queryString = req.query.q; - if (!queryString) { - return res.status(400).json({ - message: 'Invalid search input' - }); - } - if (req.decoded.roleId === 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - }, - include: [{ - model: User, - attributes: ['userName', 'roleId'] - }] - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - if (count === 0) { - return res.status(404).json({ - message: 'Document not found' - }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } else if (req.decoded.roleId !== 1) { - return Document.findAndCountAll({ - limit: limit, - offset: offset, - include: [{ - model: User, - attributes: ['userName', 'roleId'], - where: { - roleId: req.decoded.roleId - } - }], - where: { - access: { - $ne: 'private' - }, - title: { - $like: '%' + queryString + '%' - } - } - - }).then(function (_ref3) { - var document = _ref3.rows, - count = _ref3.count; - - if (count === 0) { - return res.status(404).json({ - message: 'Document not found' - }); - } - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -exports.default = { searchUser: searchUser, searchDocuments: searchDocuments }; \ No newline at end of file diff --git a/dist/server/controllers/users.js b/dist/server/controllers/users.js deleted file mode 100644 index 6496518..0000000 --- a/dist/server/controllers/users.js +++ /dev/null @@ -1,300 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _bcrypt = require('bcrypt'); - -var _bcrypt2 = _interopRequireDefault(_bcrypt); - -var _jsonwebtoken = require('jsonwebtoken'); - -var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); - -var _helper = require('../helpers/helper'); - -var _helper2 = _interopRequireDefault(_helper); - -var _models = require('../models'); - -var _models2 = _interopRequireDefault(_models); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -require('dotenv').config(); - -var jwtSecret = process.env.JWT_SECRET; -var Document = _models2.default.Document; -var User = _models2.default.User; -var metaData = _helper2.default.paginationMetaData; - -/** - * Get all users - * @param {number} req - limit and offset for getting all user - * @param {array} res - array of users or error - * @returns {array} - an array of users - */ -function getUsers(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - return User.findAndCountAll({ limit: limit, - offset: offset, - attributes: { exclude: ['password'] } - }).then(function (_ref) { - var user = _ref.rows, - count = _ref.count; - - res.status(200).send({ - user: user, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Create a user - * @param {object} req - request from user - * @param {object} res - newly created user or error - * @returns {object} - an object of a created user - */ -function createUser(req, res) { - req.check('fullName', 'FullName is required').notEmpty(); - req.check('userName', 'userName is required').notEmpty(); - req.check('email', 'Email is required').notEmpty(); - req.check('email', 'Please put a valid email').isEmail(); - req.check('password', 'Password is required').notEmpty(); - req.check('password', 'Password must be a mininum of 4 character').isLength(4, 50); - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - User.findAll({ - where: { email: req.body.email } - }).then(function (err, user) { - if (!user) { - User.create({ - fullName: req.body.fullName, - userName: req.body.userName, - email: req.body.email, - password: _bcrypt2.default.hashSync(req.body.password, _bcrypt2.default.genSaltSync(10)), - roleId: req.body.roleId || 2 - }).then(function (userDetails) { - res.status(200).json({ - userDetails: userDetails, - success: true, - message: 'You have successfully registered.' - }); - }).catch(function (error) { - res.status(400).json(error); - }); - } - }); - } -} - -/** - * Log In user with JWT - * @param {object} req - request from log in user - * @param {object} res - authenicated user details - * @returns {object} - an object of the logged in user and a token - */ -function login(req, res) { - req.check('email', 'Email is required').notEmpty(); - req.check('email', 'Please put a valid email').isEmail(); - req.check('password', 'Password is required').notEmpty(); - - var errors = req.validationErrors(); - - if (errors) { - res.status(400).json({ errors: errors }); - } else { - User.findAll({ - where: { email: req.body.email } - }).then(function (user) { - var existingUser = user[0]; - if (!existingUser) { - res.status(400).json({ - success: false, - message: 'Authentication failed. User not found.' }); - } else if (existingUser) { - if (_bcrypt2.default.compareSync(req.body.password, existingUser.password)) { - var payLoad = { - email: existingUser.email, - id: existingUser.id, - fullName: existingUser.fullName, - roleId: existingUser.roleId - }; - var token = _jsonwebtoken2.default.sign(payLoad, jwtSecret, { - expiresIn: 60 * 60 * 24 - }); - res.status(201).json({ - success: true, - token: token - }); - } else { - res.status(401).json({ - success: false, - message: 'Authentication failed. Wrong password.' - }); - } - } - }).catch(function (error) { - return res.status(400).send(error); - }); - } -} - -/** - * Find a user by Id - * @param {number} req - request for user using the id of the user - * @param {object} res - an object of the user(s) found or error - * @returns {object} - an object of found user - */ -function findUser(req, res) { - var userQuery = Number(req.params.id); - if (req.decoded.id !== userQuery && req.decoded.roleId !== 1) { - return res.status(401).json({ - message: 'Unauthorized Access' - }); - } - if (isNaN(userQuery)) { - return res.status(401).json({ - message: 'invalid input syntax for integer: "' + req.params.id + '"' - }); - } - return User.findAll({ - where: { - id: req.params.id - }, - attributes: { exclude: ['password'] } - }).then(function (user) { - if (!user.length) { - res.status(404).json({ message: 'User not found' }); - } - res.status(200).send(user); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - *Update a user by Id - * @param {object} req - updated user object - * @param {object} res - updated user object or error - * @returns {object} - return an object of the updated user - */ -function updateUser(req, res) { - if (Number(req.decoded.id) !== Number(req.params.id)) { - return res.status(401).json({ - message: 'You are not authorized to access this user' - }); - } - var userId = Number(req.params.id); - _bcrypt2.default.genSalt(10, function (err, salt) { - _bcrypt2.default.hash(req.body.password, salt, function (err, hash) { - User.findById(userId).then(function (user) { - if (!user) { - return res.status(404).json({ message: 'User not found' }); - } - return user.update({ - fullName: req.body.fullName || user.fullName, - userName: req.body.userName || user.userName, - email: req.body.email || user.email, - password: hash || user.password, - roleId: req.body.roleId || user.roleId - }).then(function (updatedUser) { - res.status(200).send({ - id: updatedUser.id, - fullName: updatedUser.fullName, - userName: updatedUser.userName, - email: updatedUser.email, - roleId: updatedUser.roleId, - message: 'Details successfully updated.' - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }); - }); -} - -/** - * Delete a user by Id - * @param {number} req - delete user with an id - * @param {object} res - message - * @returns {object} - null - */ -function deleteUser(req, res) { - if (req.decoded.roleId !== 1) { - return res.status(401).json({ - message: 'You are not authorized to access this field' - }); - } - return User.findById(req.params.id).then(function (user) { - if (!user) { - return res.status(404).json({ message: 'User not found' }); - } - return user.destroy().then(function () { - return res.status(204).json({ - message: 'User has been deleted successfully' }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -/** - * Get documents for specific user - * @param {object} req - request object containing limit query and offset - * @param {array} res - array of documents for the requested user - * @return {array} - array of requested user's document - */ -function getUserDocuments(req, res) { - var limit = req.query.limit; - var offset = req.query.offset; - User.findById(req.params.id).then(function (user) { - if (!user) { - return res.status(404).json({ - message: 'User not found' - }); - } - return Document.findAndCountAll({ - limit: limit, - offset: offset, - where: { - userId: user.id - } - }).then(function (_ref2) { - var document = _ref2.rows, - count = _ref2.count; - - res.status(200).send({ - document: document, - pagination: metaData(count, limit, offset) - }); - }).catch(function (error) { - return res.status(400).send(error); - }); - }).catch(function (error) { - return res.status(400).send(error); - }); -} - -exports.default = { - getUsers: getUsers, - createUser: createUser, - login: login, - findUser: findUser, - updateUser: updateUser, - deleteUser: deleteUser, - getUserDocuments: getUserDocuments -}; \ No newline at end of file diff --git a/dist/server/helpers/helper.js b/dist/server/helpers/helper.js deleted file mode 100644 index 9669f87..0000000 --- a/dist/server/helpers/helper.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -var paginationMetaData = function paginationMetaData(count, limit, offset) { - return { - totalCount: count, - pageCount: Math.ceil(count / limit), - page: Math.floor(offset / limit) + 1, - pageSize: limit - }; -}; - -module.exports.paginationMetaData = paginationMetaData; \ No newline at end of file diff --git a/dist/server/middlewares/auth.js b/dist/server/middlewares/auth.js deleted file mode 100644 index 7e0eb35..0000000 --- a/dist/server/middlewares/auth.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _jsonwebtoken = require('jsonwebtoken'); - -var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var jwtSecret = process.env.JWT_SECRET; - -function verifyToken(req, res, next) { - var token = req.headers.authorization || req.headers['x-access-token']; - if (token) { - _jsonwebtoken2.default.verify(token, jwtSecret, function (err, decoded) { - if (err) { - res.json({ success: false, message: 'Failed to authenticate token.' }); - } else { - req.decoded = decoded; - next(); - } - }); - } else { - return res.status(403).send({ - success: false, - message: 'No token provided.' - }); - } -} - -function adminAccess(req, res, next) { - if (req.decoded.roleId === 1) { - next(); - } else { - return res.status(401).json({ - message: 'You are not authorized' - }); - } -} - -exports.default = { verifyToken: verifyToken, adminAccess: adminAccess }; \ No newline at end of file diff --git a/dist/server/migrations/20170709115213-create-role.js b/dist/server/migrations/20170709115213-create-role.js deleted file mode 100644 index faafbd0..0000000 --- a/dist/server/migrations/20170709115213-create-role.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Roles', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Roles'); - } -}; \ No newline at end of file diff --git a/dist/server/migrations/20170709115254-create-user.js b/dist/server/migrations/20170709115254-create-user.js deleted file mode 100644 index 51491fa..0000000 --- a/dist/server/migrations/20170709115254-create-user.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Users', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - fullName: { - type: Sequelize.STRING, - allowNull: false - }, - userName: { - type: Sequelize.STRING, - allowNull: false, - unique: true - }, - email: { - type: Sequelize.STRING, - allowNull: false, - unique: true, - validate: { isEmail: true } - }, - password: { - type: Sequelize.STRING, - allowNull: false - }, - roleId: { - type: Sequelize.INTEGER, - references: { - model: 'Roles', - key: 'id', - as: 'roleId' - }, - allowNull: false, - defaultValue: 2 - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Users'); - } -}; \ No newline at end of file diff --git a/dist/server/migrations/20170709120158-create-document.js b/dist/server/migrations/20170709120158-create-document.js deleted file mode 100644 index 9c83e45..0000000 --- a/dist/server/migrations/20170709120158-create-document.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.createTable('Documents', { - id: { - allowNull: false, - autoIncrement: true, - primaryKey: true, - type: Sequelize.INTEGER - }, - title: { - type: Sequelize.STRING, - allowNull: false - }, - content: { - type: Sequelize.STRING, - allowNull: false - }, - access: { - type: Sequelize.ENUM('public', 'private', 'role'), - defaultValue: 'public', - allowNull: false - }, - userId: { - type: Sequelize.INTEGER, - references: { - model: 'Users', - key: 'id', - as: 'userId' - } - }, - createdAt: { - allowNull: false, - type: Sequelize.DATE - }, - updatedAt: { - allowNull: false, - type: Sequelize.DATE - } - }); - }, - down: function down(queryInterface, Sequelize) { - return queryInterface.dropTable('Documents'); - } -}; \ No newline at end of file diff --git a/dist/server/models/document.js b/dist/server/models/document.js deleted file mode 100644 index d204122..0000000 --- a/dist/server/models/document.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var Document = sequelize.define('Document', { - title: { - type: DataTypes.STRING, - allowNull: false - }, - content: { - type: DataTypes.TEXT, - allowNull: false - }, - userId: { - type: DataTypes.INTEGER, - unique: true, - allowNull: false - }, - access: { - type: DataTypes.ENUM, - values: ['public', 'private', 'role'] - } - }); - Document.associate = function (models) { - Document.belongsTo(models.User, { - foreignKey: 'userId' - }); - }; - return Document; -}; \ No newline at end of file diff --git a/dist/server/models/index.js b/dist/server/models/index.js deleted file mode 100644 index d5e98bf..0000000 --- a/dist/server/models/index.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -var fs = require('fs'); -var path = require('path'); -var Sequelize = require('sequelize'); - -var basename = path.basename(module.filename); -var env = process.env.NODE_ENV || 'development'; -var config = require('../config/config.js')[env]; - -var db = {}; - -var sequelize = void 0; -if (config.use_env_variable) { - sequelize = new Sequelize(process.env[config.use_env_variable]); -} else { - sequelize = new Sequelize(config.database, config.username, config.password, config); -} - -fs.readdirSync(__dirname).filter(function (file) { - return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'; -}).forEach(function (file) { - var model = sequelize.import(path.join(__dirname, file)); - db[model.name] = model; -}); - -Object.keys(db).forEach(function (modelName) { - if (db[modelName].associate) { - db[modelName].associate(db); - } -}); - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; \ No newline at end of file diff --git a/dist/server/models/role.js b/dist/server/models/role.js deleted file mode 100644 index 4979353..0000000 --- a/dist/server/models/role.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var Role = sequelize.define('Role', { - title: { - type: DataTypes.STRING, - allowNull: false, - unique: true - } - }); - Role.associate = function (models) { - Role.hasMany(models.User, { - foreignKey: 'roleId' - }); - }; - return Role; -}; \ No newline at end of file diff --git a/dist/server/models/user.js b/dist/server/models/user.js deleted file mode 100644 index def997e..0000000 --- a/dist/server/models/user.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -module.exports = function (sequelize, DataTypes) { - var User = sequelize.define('User', { - fullName: { - type: DataTypes.STRING, - allowNull: false - }, - userName: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - email: { - type: DataTypes.STRING, - allowNull: false, - unique: true - }, - password: { - type: DataTypes.STRING, - allowNull: false - }, - roleId: { - type: DataTypes.INTEGER, - allowNull: false, - defaultvalue: 2 - } - }); - User.associate = function (models) { - User.hasMany(models.Document, { - foreignKey: 'userId', - onDelete: 'CASCADE', - hooks: true - }); - User.belongsTo(models.Role, { - foreignKey: 'roleId', - onDelete: 'CASCADE' - }); - }; - return User; -}; \ No newline at end of file diff --git a/dist/server/routes/documents.js b/dist/server/routes/documents.js deleted file mode 100644 index f57376c..0000000 --- a/dist/server/routes/documents.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _documents = require('../controllers/documents'); - -var _documents2 = _interopRequireDefault(_documents); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/v1/documents - Get all documents */ -.get(_auth2.default.verifyToken, _documents2.default.getAllDocument) - -/** POST /api/v1/documents - Create document */ -.post(_auth2.default.verifyToken, _documents2.default.createDocument); - -router.route('/:id') -/** PUT /api/v1/documents/id - Create document */ -.put(_auth2.default.verifyToken, _documents2.default.updateDocument) - -/** GET /api/v1/documents/id - get document */ -.get(_auth2.default.verifyToken, _documents2.default.findDocument) - -/** DELETE /api/v1/documents/id - delete document */ -.delete(_auth2.default.verifyToken, _documents2.default.deleteDocument); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/index.js b/dist/server/routes/index.js deleted file mode 100644 index 1f4a3ec..0000000 --- a/dist/server/routes/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _users = require('./users'); - -var _users2 = _interopRequireDefault(_users); - -var _search = require('./search'); - -var _search2 = _interopRequireDefault(_search); - -var _documents = require('./documents'); - -var _documents2 = _interopRequireDefault(_documents); - -var _roles = require('./roles'); - -var _roles2 = _interopRequireDefault(_roles); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -/** GET /api-status - Check service status **/ -router.use('/users', _users2.default); -router.use('/search', _search2.default); -router.use('/documents', _documents2.default); -router.use('/roles', _roles2.default); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/roles.js b/dist/server/routes/roles.js deleted file mode 100644 index 63ea87b..0000000 --- a/dist/server/routes/roles.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _roles = require('../controllers/roles'); - -var _roles2 = _interopRequireDefault(_roles); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/roles - Get list of roles */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.getRoles) - -/** POST /api/roles - Create roles */ -.post(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.createRole); - -router.route('/:id') -/** GET /api/users/roles - Find roles */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.findRole) - -/** PUT /api/users/id - update roles */ -.put(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.updateRole) - -/** DELETE /api/users/id - delete roles */ -.delete(_auth2.default.verifyToken, _auth2.default.adminAccess, _roles2.default.deleteRole); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/search.js b/dist/server/routes/search.js deleted file mode 100644 index ea6c0e2..0000000 --- a/dist/server/routes/search.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _search = require('../controllers/search'); - -var _search2 = _interopRequireDefault(_search); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/users') -/** GET /api/v1/users - search list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _search2.default.searchUser); - -router.route('/documents') -/** GET /api/v1/search - search list of documents */ -.get(_auth2.default.verifyToken, _search2.default.searchDocuments); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/routes/users.js b/dist/server/routes/users.js deleted file mode 100644 index 4eb365a..0000000 --- a/dist/server/routes/users.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _express = require('express'); - -var _express2 = _interopRequireDefault(_express); - -var _users = require('../controllers/users'); - -var _users2 = _interopRequireDefault(_users); - -var _auth = require('../middlewares/auth'); - -var _auth2 = _interopRequireDefault(_auth); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var router = _express2.default.Router(); - -router.route('/') -/** GET /api/users - Get list of users */ -.get(_auth2.default.verifyToken, _auth2.default.adminAccess, _users2.default.getUsers) - -/** POST /api/users - Create/Signup users */ -.post(_users2.default.createUser); - -router.route('/login') -/** POST /api/users/login - Login users */ -.post(_users2.default.login); - -router.route('/:id') -/** GET /api/users/id - Find users */ -.get(_auth2.default.verifyToken, _users2.default.findUser) - -/** PUT /api/users/id - update users */ -.put(_auth2.default.verifyToken, _users2.default.updateUser) - -/** DELETE /api/users/id - delete users */ -.delete(_auth2.default.verifyToken, _users2.default.deleteUser); - -router.route('/:id/documents') -/** GET /api/users/id/documents - Find documents of a specific user*/ -.get(_auth2.default.verifyToken, _users2.default.getUserDocuments); - -exports.default = router; \ No newline at end of file diff --git a/dist/server/seeders/20170727152600-sample-roles.js b/dist/server/seeders/20170727152600-sample-roles.js deleted file mode 100644 index 790d10f..0000000 --- a/dist/server/seeders/20170727152600-sample-roles.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface) { - return queryInterface.bulkInsert('Roles', [{ - title: 'admin', - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'facilitator', - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'fellow', - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface) { - return queryInterface.bulkDelete('Roles', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153559-sample-users.js b/dist/server/seeders/20170727153559-sample-users.js deleted file mode 100644 index 6c8bde8..0000000 --- a/dist/server/seeders/20170727153559-sample-users.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var bcrypt = require('bcrypt'); -require('dotenv').config(); - -module.exports = { - up: function up(queryInterface) { - return queryInterface.bulkInsert('Users', [{ - userName: 'bank', - fullName: 'Baas Bank', - email: 'baas@test.com', - password: bcrypt.hashSync(process.env.TEST_ADMIN_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, { - userName: 'john', - fullName: 'John Bosco', - email: 'john@test.com', - password: bcrypt.hashSync(process.env.TEST_FELLOW_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - userName: 'blessing', - fullName: 'Blessing Philip', - email: 'blessing@test.com', - password: bcrypt.hashSync(process.env.TEST_FACILITATOR_PASSWORD, bcrypt.genSaltSync(10)), - roleId: 3, - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface) { - return queryInterface.bulkDelete('Users', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/seeders/20170727153641-sample-documents.js b/dist/server/seeders/20170727153641-sample-documents.js deleted file mode 100644 index caf5e98..0000000 --- a/dist/server/seeders/20170727153641-sample-documents.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -module.exports = { - up: function up(queryInterface, Sequelize) { - return queryInterface.bulkInsert('Documents', [{ - title: 'John Doe', - content: 'eze goes to school', - access: 'public', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'John naddddd', - content: 'John watches american gods regularly', - access: 'private', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }, { - title: 'James Hannn', - content: 'Han is a bad guy', - access: 'role', - userId: 2, - createdAt: new Date(), - updatedAt: new Date() - }], {}); - }, - - down: function down(queryInterface, Sequelize) { - return queryInterface.bulkDelete('Documents', null, {}); - } -}; \ No newline at end of file diff --git a/dist/server/test/controllers/document.spec.js b/dist/server/test/controllers/document.spec.js deleted file mode 100644 index fb9ffdf..0000000 --- a/dist/server/test/controllers/document.spec.js +++ /dev/null @@ -1,297 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Documents', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST Document', function () { - it('should add a new document if the user is authenticated', function (done) { - var document = { - title: 'hey yo!', - content: 'Andela is really fun!!', - access: 'public', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.property('id'); - expect(res.body.title).to.eql('hey yo!'); - expect(res.body.content).to.eql('Andela is really fun!!'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - - it('Should fail if document already exist', function () { - var document = { - title: 'John team', - content: 'eze goes to school', - access: 'public' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body.message).to.eql('Document already exists'); - }); - }); - it('should fail to add a new document if the user is not authenticated', function (done) { - var document = { - title: 'boromir-team', - content: 'Andela is really awesome !!!', - value: 'private', - userId: 2 - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/documents').send(document).end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - it('should fail to add a new document if the value field is missing', function (done) { - var document = { - title: 'kiba-team', - content: 'Andela is really awesome!!!', - access: '', - userId: 1 - }; - _chai2.default.request(_index2.default).post('/api/v1/documents').send(document).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.be.equal('accessType is required'); - done(); - }); - }); - }); - - describe('/GET Documents', function () { - it('Should get all documents for the user that is authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['document', 'pagination']); - done(); - }); - }); - it('should fail to get all documents if the user is not authenticated', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).be.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get all documents with correct limit as a query', function (done) { - var limit = 1; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + limit).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - it('Should get all documents with correct offset as a query', function (done) { - var offset = 0; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents?limit=' + offset).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - done(); - }); - }); - }); - - describe('/GET/:id Document', function () { - it('Should fail to get document if it doesn`t exist', function (done) { - var documentId = 8; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document not found'); - done(); - }); - }); - it('Should get all public regardless of id', function (done) { - var documentId = 4; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(4); - expect(res.body.title).to.equal('hey yo!'); - expect(res.body.access).to.equal('public'); - done(); - }); - }); - it('Should fail to get a private document if the requester does not own it', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a private document the where the requester is the owner', function (done) { - var documentId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.access).to.eql('private'); - expect(res.body.title).to.eql('John naddddd'); - expect(res.body.id).to.eql(2); - expect(res.body.userId).to.eql(2); - done(); - }); - }); - it('Should fail get a role document if the users are not on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to view this document'); - done(); - }); - }); - it('Should get a role document if the users are on the same role', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - done(); - }); - }); - it('Should get a role document if the user is an admin', function (done) { - var documentId = 3; - (0, _supertest2.default)(_index2.default).get('/api/v1/documents/' + documentId + '/').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(3); - expect(res.body.title).to.eql('James Hannn'); - expect(res.body.access).to.eql('role'); - }); - done(); - }); - }); - - describe('/PUT/:id, Document', function () { - it('Should update a document by id if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'wreck it ralph' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.title).to.eql('wreck it ralph'); - done(); - }); - }); - it('Should fail to update a document by\n id if the user does not have the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).send({ title: 'spiderman Homecoming' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to edit this document'); - done(); - }); - }); - it('Should not update a document by id if the user has admin access', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: adminToken }).send({ title: 'wreck it' }).end(function (err, res) { - expect(res.status).to.equal(401); - done(); - }); - }); - it('Should fail to update a document by id if the document does not exist', function (done) { - var id = 10; - (0, _supertest2.default)(_index2.default).put('/api/v1/documents/' + id).set({ authorization: userToken }).send({ title: 'Deadpool' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document Not Found'); - done(); - }); - }); - }); - - describe('DELETE/:id Document', function () { - it('Should delete a document if the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should delete a document if the user is the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete the document given the user is not the owner', function (done) { - var id = 1; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to delete this document'); - done(); - }); - }); - it('Should fail to delete if the document does not exist', function (done) { - var id = 234; - _chai2.default.request(_index2.default).delete('/api/v1/documents/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Document Not Found'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/mockData.js b/dist/server/test/controllers/mockData.js deleted file mode 100644 index 34d40d9..0000000 --- a/dist/server/test/controllers/mockData.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _dotenv = require('dotenv'); - -var _dotenv2 = _interopRequireDefault(_dotenv); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_dotenv2.default.config(); - -exports.default = { - admin: { - email: 'baas@test.com', - password: process.env.TEST_ADMIN_PASSWORD - }, - fellow: { - email: 'john@test.com', - password: process.env.TEST_FELLOW_PASSWORD - }, - faciliatator: { - email: 'blessing@test.com', - password: process.env.TEST_FACILITATOR_PASSWORD - }, - user2: { - email: 'baas@test.com', - password: 'test' - }, - user1: { - email: 'test@test123.com', - password: 'test' - }, - fakeBass: { - fullName: 'Baasbank Adams', - userName: 'tiaandela', - email: 'name@example.com', - password: 'pass123', - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, - Baas: { - fullName: 'Baas Bank', - userName: 'bank', - email: 'baas@test.com', - password: 'pass123', - roleId: 1, - createdAt: new Date(), - updatedAt: new Date() - }, - fakeUserDetails: { - fullName: 'Daniel Cfh', - userName: 'cfh', - email: 'cfh@example.com', - password: 'pass123', - roleId: 2, - createdAt: 'date', - updatedAt: new Date() - } -}; \ No newline at end of file diff --git a/dist/server/test/controllers/role.spec.js b/dist/server/test/controllers/role.spec.js deleted file mode 100644 index 6d28fb3..0000000 --- a/dist/server/test/controllers/role.spec.js +++ /dev/null @@ -1,257 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow; - - -describe('Roles', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST Role', function () { - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'boromir' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - expect(res.body.role).to.have.property('title').to.equal('boromir'); - }); - done(); - }); - it('should add a new role if the user is an admin', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/roles').send({ title: 'king' }).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role successfully created'); - expect(res.body).to.have.property('role'); - }); - done(); - }); - it('Should fail if a non-admin wants to add a new role', function (done) { - var role = { - title: 'boromir-team' - }; - (0, _supertest2.default)(_index2.default).post('/api/v1/roles/').set({ authorization: userToken }).send(role).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should return an error if the title is not a string', function (done) { - _chai2.default.request(_index2.default).post('/api/v1/roles').set({ authorization: adminToken }).send({ title: 358583 }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Invalid input credentials'); - done(); - }); - }); - }); - - describe('/GET Role', function () { - it('Should get all the roles if the user is an admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.length(5); - expect(res.body).to.be.a('array'); - expect(res.body[0].id).to.eql(1); - expect(res.body[0].title).to.eql('admin'); - expect(res.body[1].id).to.eql(2); - expect(res.body[1].title).to.eql('facilitator'); - done(); - }); - }); - it('Should fail to get the roles if the user is not admin', function (done) { - _chai2.default.request(_index2.default).get('/api/v1/roles').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - }); - - describe('/GET/:id Role', function () { - it('Should get a role by id if the user is an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.title).to.eql('facilitator'); - expect(res.body.id).to.equal(2); - done(); - }); - }); - it('Should fail to get a role by id if the user is not an admin', function (done) { - var id = 2; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get a role by id if the user enters an invalid input', function (done) { - var id = 'fddjsdcdjn'; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('Should fail to get a role by id if the role does not exist', function (done) { - var id = 250; - _chai2.default.request(_index2.default).get('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body.message).to.eql('Role not found'); - done(); - }); - }); - // it('Should fail to get a role by id if the id is out of range', (done) => { - // const id = 500000000000000000000; - // chai.request(server) - // .get(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); - }); - describe('/PUT/:id Role', function () { - it('Should update a role by id if the user has admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'boromir-team' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('Role updated successfully'); - expect(res.body).to.have.property('role'); - done(); - }); - }); - it('Should fail to update a role by id if the user has no admin access', function (done) { - var id = 2; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: userToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to update a\n role by id if the admin enters an invalid input', function (done) { - var id = 200; - _chai2.default.request(_index2.default).put('/api/v1/roles/' + id).set({ authorization: adminToken }).send({ title: 'kiba' }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.equal('Role not found'); - done(); - }); - }); - // it(`Should fail to update a role by - // id if the admin enters an id that is out range`, - // (done) => { - // const id = 2000000000000000; - // chai.request(server) - // .put(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .send({ title: 'regular' }) - // .end((err, res) => { - // expect(res.status).to.equal(400); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); - }); - describe('/DELETE/:id Role', function () { - it('Should delete a role given the user has admin access', function (done) { - var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - expect(res.body).to.be.a('object'); - }); - done(); - }); - it('Should fail to delete a role given the user has no admin access', function (done) { - var id = 3; - _chai2.default.request(_index2.default).delete('/api/v1/roles/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - // it('Should fail to delete a role given the admin enters an invalid input', - // (done) => { - // const id = 300; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(404); - // expect(res.body).to.be.a('object'); - // expect(res.body.message).to.equal('Role not found'); - // done(); - // }); - // }); - // it(`Should fail to delete a role given - // the admin enters an input that is out of range`, (done) => { - // const id = 3000000000000000; - // chai.request(server) - // .delete(`/api/v1/roles/${id}`) - // .set({ authorization: adminToken }) - // .end((err, res) => { - // expect(res.status).to.equal(200); - // expect(res.body).to.be.a('object'); - // expect(res.body.message) - // .to.eql(`value "${id}" is out of range for type integer`); - // done(); - // }); - // }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/search.spec.js b/dist/server/test/controllers/search.spec.js deleted file mode 100644 index ebcbf38..0000000 --- a/dist/server/test/controllers/search.spec.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fellow = _mockData2.default.fellow, - Baas = _mockData2.default.Baas; - - -describe('Search', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/SEARCH/users/?q={name}', function () { - it('Should return an error if no querystring is provided', function (done) { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - done(); - }); - }); - it('Should return a search list response of the required search input', function (done) { - var query = Baas.userName; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/users/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body.user[0].fullName).to.eql(Baas.fullName); - expect(res.body.user[0].userName).to.equal(Baas.userName); - done(); - }); - }); - }); - describe('/SEARCH/documents/?q=', function () { - it('Should return an error if no querystring is provided', function (done) { - var query = ''; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body.message).to.eql('Invalid search input'); - done(); - }); - }); - it('Should return a search list of the required search input', function (done) { - var query = 'John'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.property('document'); - expect(res.body.document[0].title).to.equal('John Doe'); - expect(res.body.document[0].content).to.equal('eze goes to school'); - expect(res.body).to.have.property('pagination'); - expect(res.body.paginaton).to.have.property('totalCount').to.equal(1); - done(); - }); - }); - it('Should throw an error if the searched document is not found', function (done) { - var query = 'jk'; - (0, _supertest2.default)(_index2.default).get('/api/v1/search/documents/?q=' + query).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body.message).to.equal('Document not found'); - done(); - }); - }); - }); -}); \ No newline at end of file diff --git a/dist/server/test/controllers/user.spec.js b/dist/server/test/controllers/user.spec.js deleted file mode 100644 index d747a63..0000000 --- a/dist/server/test/controllers/user.spec.js +++ /dev/null @@ -1,306 +0,0 @@ -'use strict'; - -var _chai = require('chai'); - -var _chai2 = _interopRequireDefault(_chai); - -var _supertest = require('supertest'); - -var _supertest2 = _interopRequireDefault(_supertest); - -var _chaiHttp = require('chai-http'); - -var _chaiHttp2 = _interopRequireDefault(_chaiHttp); - -var _index = require('../../../index'); - -var _index2 = _interopRequireDefault(_index); - -var _mockData = require('./mockData'); - -var _mockData2 = _interopRequireDefault(_mockData); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var expect = _chai2.default.expect; -_chai2.default.use(_chaiHttp2.default); -var userToken = void 0, - adminToken = void 0, - sampleUserToken = void 0; -var admin = _mockData2.default.admin, - fakeBass = _mockData2.default.fakeBass, - fellow = _mockData2.default.fellow, - user1 = _mockData2.default.user1, - user2 = _mockData2.default.user2; - - -describe('Users', function () { - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - adminToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(fellow).end(function (err, res) { - userToken = res.body.token; - done(); - }); - }); - before(function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send({ email: 'blessing@test.com', password: 'pass123' }).end(function (err, res) { - sampleUserToken = res.body.token; - done(); - }); - }); - - describe('/POST User login', function () { - it('Should fail if the user enters incorrect crendentials upon login', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user1).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. User not found.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('Should fail if the user provide a wrong password', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(user2).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message', 'success']); - expect(res.body.message).to.eql('Authentication failed. Wrong password.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - - it('should log in a user and return a token', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/login').send(admin).end(function (err, res) { - expect(res.status).to.equal(201); - expect(res.body).to.have.keys(['success', 'token']); - expect(res.body.success).to.eql(true); - done(); - }); - }); - - describe('/POST User Signup', function () { - it('should create a new user', function (done) { - (0, _supertest2.default)(_index2.default).post('/api/v1/users/').send(fakeBass).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.have.keys(['message', 'success', 'userDetails']); - expect(res.body.success).to.eql(true); - expect(res.body.message).to.eql('You have successfully registered.'); - done(); - }); - }); - }); - - describe('#GET Users', function () { - it('Should get all users if the user is an admin ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body).to.have.keys(['user', 'pagination']); - done(); - }); - }); - it('Should fail to get all users if the user has no admin access ', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized'); - done(); - }); - }); - it('Should fail to get all users if no token was provided', function (done) { - (0, _supertest2.default)(_index2.default).get('/api/v1/users').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - done(); - }); - }); - it('Should get all users with correct limit as a query', function (done) { - var limit = 1; - _chai2.default.request(_index2.default).get('/api/v1/users?limit=' + limit).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.user[0].fullName).to.equal('Baas Bank'); - expect(res.body.user[0].userName).to.equal('bank'); - done(); - }); - }); - }); - describe('#GET User by Id', function () { - it('Should get a user if the user is an admin', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).to.eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should get the user if the requested user is the current user', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('array'); - expect(res.body[0].fullName).to.eql('John Bosco'); - expect(res.body[0].id).eql(2); - expect(res.body[0].userName).to.eql('john'); - expect(res.body[0].email).to.eql('john@test.com'); - expect(res.body[0].roleId).to.eql(2); - done(); - }); - }); - it('Should fail to get a user if an invalid input is entered', function (done) { - var id = 'fddjsdcdjn'; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.property('message').to.eql('invalid input syntax for integer: "' + id + '"'); - done(); - }); - }); - it('should fail to get the user if the requester is not the owner', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).get('api/users/' + id).set({ authorization: sampleUserToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.have.keys(['message']); - expect(res.body.message).to.eql('Unauthorized access'); - }); - done(); - }); - it('Should fail to get a user if the user does not exist', function (done) { - var id = 250; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.have.property('message'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get a user if the id is out of range', function (done) { - var id = 500000000000000000; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(400); - expect(res.body).to.have.property('message').to.equal('value "' + id + '" is out of range for type integer'); - done(); - }); - }); - }); - describe('#PUT Update user by Id', function () { - it('Should update a user`s full name if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ fullName: 'jake doe' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.fullName).to.eql('jake doe'); - done(); - }); - }); - it('Should update a user`s email if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.email).to.eql('jakedoe@andela.com'); - done(); - }); - }); - it('Should update a user`s username if the user has the same id', function (done) { - var id = 2; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ userName: 'jakedoe12' }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).to.be.a('object'); - expect(res.body.id).to.eql(2); - expect(res.body.userName).to.eql('jakedoe12'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user does not have the same user id', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - it('Should fail to update a user\'s\n details if the user enters an invalid user id', function (done) { - var id = 2302; - (0, _supertest2.default)(_index2.default).put('/api/v1/users/' + id).set({ authorization: userToken }).send({ email: 'jakedoe@andela.com' }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('You are not authorized to access this user'); - done(); - }); - }); - }); - describe('#DELETE /:id Users', function () { - it('Should delete a user given the user has admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(204); - done(); - }); - }); - it('Should fail to delete a user if the user has no admin access', function (done) { - var id = 3; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(401); - expect(res.body.message).to.eql('You are not authorized to access this field'); - done(); - }); - }); - it('Should give a User not found if user don\'t exist', function (done) { - var id = 23; - (0, _supertest2.default)(_index2.default).delete('/api/v1/users/' + id).set({ authorization: adminToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).to.be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - }); - describe('/GET/users/:id/documents Documents', function () { - it('Should fail to get documents if the user does not exist', function (done) { - var userId = 9; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(404); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('User not found'); - done(); - }); - }); - it('Should fail to get documents if there is no token present', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').end(function (err, res) { - expect(res.status).to.equal(403); - expect(res.body).be.a('object'); - expect(res.body.message).to.eql('No token provided.'); - expect(res.body.success).to.eql(false); - done(); - }); - }); - it('Should get documents for the user with its unique userId', function (done) { - var userId = 2; - (0, _supertest2.default)(_index2.default).get('/api/v1/users/' + userId + '/documents').set({ authorization: userToken }).end(function (err, res) { - expect(res.status).to.equal(200); - expect(res.body).be.a('object'); - expect(res.body.document[1].userId).to.eql(2); - expect(res.body.document[1].title).to.eql('hey yo!'); - expect(res.body.document[1].content).to.eql('Andela is really fun!!'); - done(); - }); - }); - }); - }); -}); \ No newline at end of file From c07769d13989ccd74879e40249f515e4f564ea5e Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:27:30 +0100 Subject: [PATCH 47/98] remove .env file --- .env | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 3ab0297..0000000 --- a/.env +++ /dev/null @@ -1,5 +0,0 @@ -JWT_SECRET=iamflax -TEST_ADMIN_PASSWORD=pass123 -TEST_FELLOW_PASSWORD=pass123 -TEST_FACILITATOR_PASSWORD=pass123 -PASSWORD=pass123 From 372623ea1af55e9a01f91cfee68fa8ad7f9d383b Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:29:00 +0100 Subject: [PATCH 48/98] remove coverrun --- .coverrun | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .coverrun diff --git a/.coverrun b/.coverrun deleted file mode 100644 index 3e78ba3..0000000 --- a/.coverrun +++ /dev/null @@ -1 +0,0 @@ -{ "run" : ".cover_9729541293026875" } \ No newline at end of file From dfad6b32bb3c70c93f9863e99f63db8170d260a6 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:35:42 +0100 Subject: [PATCH 49/98] remove env file from folder structure --- .coverrun | 1 - .env | 6 ------ 2 files changed, 7 deletions(-) delete mode 100644 .coverrun delete mode 100644 .env diff --git a/.coverrun b/.coverrun deleted file mode 100644 index 3e78ba3..0000000 --- a/.coverrun +++ /dev/null @@ -1 +0,0 @@ -{ "run" : ".cover_9729541293026875" } \ No newline at end of file diff --git a/.env b/.env deleted file mode 100644 index ff9a3ea..0000000 --- a/.env +++ /dev/null @@ -1,6 +0,0 @@ -JWT_SECRET=iamflax -TEST_ADMIN_PASSWORD=pass123 -TEST_FELLOW_PASSWORD=pass123 -TEST_FACILITATOR_PASSWORD=pass123 -PASSWORD=pass123 -TEST_DB=postgres://qvugccno:lEPRlNKRx7zt50Ua_qH7JvCDf7Lt5xEt@babar.elephantsql.com:5432/qvugccno From 1616c6d2f6e44d74e887cde2f5870886adfe1792 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:38:47 +0100 Subject: [PATCH 50/98] feat(testing):testing - fix codeclimate badge on readme [Finishes #149632847] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba8dd7e..2f25897 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # document-manager +[![Build Status](https://travis-ci.org/iakhator/document-manager.svg?branch=staging)](https://travis-ci.org/iakhator/document-manager) [![Coverage Status](https://coveralls.io/repos/github/iakhator/document-manager/badge.svg?branch=staging)](https://coveralls.io/github/iakhator/document-manager?branch=staging) -[![Code [![Code Climate](https://codeclimate.com/github/iakhator/Document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) +[![Code Climate](https://codeclimate.com/github/iakhator/Document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) From d5b1d9d131c5f24b88ed08a1545f232af07d50fc Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Thu, 3 Aug 2017 18:41:09 +0100 Subject: [PATCH 51/98] feat(testing):testing - fix codeclimate badge [Finishes #149632847] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f25897..c90bf5e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # document-manager [![Build Status](https://travis-ci.org/iakhator/document-manager.svg?branch=staging)](https://travis-ci.org/iakhator/document-manager) [![Coverage Status](https://coveralls.io/repos/github/iakhator/document-manager/badge.svg?branch=staging)](https://coveralls.io/github/iakhator/document-manager?branch=staging) -[![Code Climate](https://codeclimate.com/github/iakhator/Document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) +[![Code Climate](https://codeclimate.com/github/iakhator/document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) From 8a85316382ab0ff5ae0eb49108eda6ff0819a497 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 4 Aug 2017 09:26:49 +0100 Subject: [PATCH 52/98] feat(testing):testing - fixing codeclimate badge [Finishes #149632847] --- codeclimate.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/codeclimate.yml b/codeclimate.yml index a287ac0..b0753a2 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -1,7 +1,9 @@ engines: - duplication: - enabled: false - config: - languages: - javascript: - mass_threshold: 20 + duplication: + enabled: false + config: + languages: + javascript: + mass_threshold: 20 + exclude_paths: + - "server/test/" From c4d02806df04a06e7f81430c4454af286095c82f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 4 Aug 2017 12:19:19 +0100 Subject: [PATCH 53/98] feat(testing):testing - fixing codeclimate badge [Finishes #149632847] --- gulpfile.babel.js | 5 ----- server/config/config.js | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index db8f8c4..e8763c5 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -1,7 +1,6 @@ import gulp from 'gulp'; import loadPlugins from 'gulp-load-plugins'; import path from 'path'; -import coveralls from 'gulp-coveralls'; import shell from 'gulp-shell'; // Load the gulp plugins into the `plugins` variable @@ -27,10 +26,6 @@ gulp.task('coverage', shell.task([ 'cross-env NODE_ENV=test nyc mocha ./server/test/**/*.js', ])); -gulp.task('coveralls', () => gulp.src('./coverage/lcov') - .pipe(coveralls())); - - // Restart server with on every changes made to file gulp.task('nodemon', ['babel'], () => plugins.nodemon({ diff --git a/server/config/config.js b/server/config/config.js index c0da612..5ae4cac 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -10,7 +10,12 @@ module.exports = { dialect: 'postgres' }, test: { - use_env_variable: 'TEST_DB' + username: 'andeladeveloper', + password: null, + database: 'docmanager-test', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' }, production: { username: 'root', From 4b782df61e8cc73a927fbeb68197dc1ad305c51c Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 4 Aug 2017 12:25:24 +0100 Subject: [PATCH 54/98] configuring integration tools --- server/config/config.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/server/config/config.js b/server/config/config.js index 5ae4cac..c0da612 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -10,12 +10,7 @@ module.exports = { dialect: 'postgres' }, test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' + use_env_variable: 'TEST_DB' }, production: { username: 'root', From e2026265908a9b176e84aa4035efbf0c5b655c53 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 4 Aug 2017 12:54:21 +0100 Subject: [PATCH 55/98] feat(testing):testing - fix config js [Finishes #149632847] --- server/config/config.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/server/config/config.js b/server/config/config.js index 5ae4cac..c0da612 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -10,12 +10,7 @@ module.exports = { dialect: 'postgres' }, test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' + use_env_variable: 'TEST_DB' }, production: { username: 'root', From bd2a8fde22c26c5afa177cc84adc7bb89d15d225 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Fri, 4 Aug 2017 13:04:24 +0100 Subject: [PATCH 56/98] feat(testing):testing - fix config.js [Finishes #149632847] --- codeclimate.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/codeclimate.yml b/codeclimate.yml index b0753a2..1272843 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -1,9 +1,17 @@ engines: + eslint: + enabled: true + channel: "eslint-3" + checks: + import/no-unresolved: + enabled: false duplication: enabled: false config: languages: - javascript: - mass_threshold: 20 - exclude_paths: - - "server/test/" + - javascript +ratings: + paths: + - "**.js" +exclude_paths: +- server/test/ From 4aa1247cd641dfe093cd8e32b92b0b55a0078e08 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 6 Aug 2017 08:48:00 +0100 Subject: [PATCH 57/98] - ensure travis is building [Finishes #149632847] --- codeclimate.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/codeclimate.yml b/codeclimate.yml index 1272843..b993a4b 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -1,17 +1,20 @@ engines: eslint: enabled: true - channel: "eslint-3" - checks: - import/no-unresolved: - enabled: false + config: + config: .eslintrc duplication: enabled: false config: languages: - javascript + fixme: + enabled: true ratings: paths: + - "**.es6" - "**.js" + - "**.jsx" exclude_paths: +- node_modules/**/* - server/test/ From 6acb6114233734321330f22114075d2a194b5bbf Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 6 Aug 2017 09:33:02 +0100 Subject: [PATCH 58/98] - add env.sample file [Finishes #149632847] --- .env.sample | 6 +++ README.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++- codeclimate.yml | 11 +++-- 3 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..195f6bb --- /dev/null +++ b/.env.sample @@ -0,0 +1,6 @@ +JWT_SECRET='' +TEST_ADMIN_PASSWORD='' +TEST_FELLOW_PASSWORD='' +TEST_FACILITATOR_PASSWORD='' +PASSWORD='' +TEST_DB='' diff --git a/README.md b/README.md index c90bf5e..75dc3e5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,125 @@ -# document-manager [![Build Status](https://travis-ci.org/iakhator/document-manager.svg?branch=staging)](https://travis-ci.org/iakhator/document-manager) [![Coverage Status](https://coveralls.io/repos/github/iakhator/document-manager/badge.svg?branch=staging)](https://coveralls.io/github/iakhator/document-manager?branch=staging) [![Code Climate](https://codeclimate.com/github/iakhator/document-manager/badges/gpa.svg)](https://codeclimate.com/github/iakhator/document-manager) + +# document-manager +Document manager provides REST API endpoints for a document management system. It allows create, retrieve, update and delete actions to be carried out. +It also ensures that users are authorized. + +# API Documentation +The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API status and errors. + +## Features + +**Users**: +A created user will have a role, either an admin or a fellow. +- A Fellow User can: + - Create an account + - Search users + - Create a document + - Edit a document + - Retrieve a document + - Delete a document + - Limit access to a document by specifying an access group `i.e. public, private or role`. + - View public documents created by other users. + - View documents created by his access group with access level set as `role`. + - Search documents. + - View `public` and `role` access level documents of other regular users. + +- An Admin User can: + - View all users + - View all created documents + - Delete any user + - Update any user's role + - Create a new role + - View all created roles + - Search for any user + - Search for any document + +**Documents**: +Documents can be created and must have: + - Published date + - Title + - Content + - Access (`private, public or role`) + +**Roles**: +Roles can also be created, the default roles are `admin` and `fellow`. +Only an admin user can create and manage role(s) + +**Authentication**: +Users are authenticated and validated using JSON web token (JWT). +By generating a token on login, API endpoints and documents are protected from unauthorized access. +Requests to protected routes are validated using the generated token. + +## Endpoints + +**Users** + +Request type | Endpoint | Action +------------ | -------- | ------ +POST | [/users](#create-user) | Create a new user +GET | [/users](#get-all-users) | Get all users +GET | [/users/:id](#get-user) | Get details of a specific user +GET | [/users/login](#login) | To log a user in +GET | [/users/?limit={integer}&offset={integer}](#pagination) | Pagination for users +GET | [/search/users/?query=new](#search-user) | To search for a user +GET | [/users/:id/documents](#user-documents) | Retrieve all documents created by a user +PUT | [/users/:id](#edit-user) | Edit user details +DELETE | [/users/:id](#delete-user) | Delete a user from database + +**Roles** + +Request type | Endpoint | Action +------------ | -------- | ------ +POST | [/roles](#create-role) | Create a new role +GET | [/roles](#get-all-roles) | Get all created roles +GET | [/role/:id](#get-role) | Get a specific role +PUT | [/role/:id](#edit-role) | Edit a specific role +DELETE | [/role/:id](#delete-role) | Delete a specific role + +**Documents** + +Request type | Endpoint | Action +------------ | -------- | ------ +POST | [/documents](#create-document) | Create a new document +GET | [/documents](#get-all-documents) | Retrieve all documents +GET | [/documents/:id](#get-document) | Retrieve a specific document +GET | [/documents/?limit={integer}&offset={integer}](#pagination) | Pagination for documents +GET | [/search/documents/?query=new](#search-document) | Search documents using key terms +PUT | [/documents/:id](#edit-document) | Update a specific document +DELETE | [/documents/:id](#delete-document) | Remove a specific document from storage + +## Development +Document Management System API is built with the following technologies; +- EcmaScript6 (ES6) +- [NodeJs](https://nodejs.org) +- [Express](http://expressjs.com/) +- [Postgresql](https://www.postgresql.org/) +- [Sequelize ORM](http://docs.sequelizejs.com/en/v3/) + +## Installation + - Install [NodeJs](https://nodejs.org/en/) and [Postgres](https://www.postgresql.org/) on your machine + - Clone the repository `$ git clone https://github.com/iakhator/document-manager.git` + - Change into the directory `$ cd /document-manager` + - Install all required dependencies with `$ npm install` + - Create a `.env` file in your root directory as described in `.env.sample` file + - Start the app with `npm start` + - Run Test `npm test` + +## Contributing +- Fork this repository to your GitHub account +- Clone the forked repository +- Create your feature branch +- Commit your changes +- Push to the remote branch +- Open a Pull Request + +## Limitations +The limitations of the API are: +- Users cannot delete themselves using the API +- Documents are not unique (A user can create a document with the same title) +- User cannot login on two different platform + +## LICENSE + This project is authored by [Itua Akhator](https://github.com/iakhator) it is licensed under the MIT license. diff --git a/codeclimate.yml b/codeclimate.yml index 1272843..b993a4b 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -1,17 +1,20 @@ engines: eslint: enabled: true - channel: "eslint-3" - checks: - import/no-unresolved: - enabled: false + config: + config: .eslintrc duplication: enabled: false config: languages: - javascript + fixme: + enabled: true ratings: paths: + - "**.es6" - "**.js" + - "**.jsx" exclude_paths: +- node_modules/**/* - server/test/ From 89648e002a866e509b6a0aebfb70e43cd58afb2f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Sun, 6 Aug 2017 11:57:39 +0100 Subject: [PATCH 59/98] - add middleware test [Finishes #149632847] --- server/middlewares/auth.js | 17 +++- server/test/controllers/document.spec.js | 59 +++++++------ server/test/controllers/mockData.js | 2 +- server/test/controllers/role.spec.js | 43 +++++----- server/test/controllers/search.spec.js | 17 ++-- server/test/controllers/user.spec.js | 59 +++++++------ server/test/middlewares/auth.spec.js | 104 +++++++++++++++++++++++ 7 files changed, 208 insertions(+), 93 deletions(-) create mode 100644 server/test/middlewares/auth.spec.js diff --git a/server/middlewares/auth.js b/server/middlewares/auth.js index 85fb266..330580f 100644 --- a/server/middlewares/auth.js +++ b/server/middlewares/auth.js @@ -2,7 +2,14 @@ import jwt from 'jsonwebtoken'; const jwtSecret = process.env.JWT_SECRET; - +/** + * verifyToken verify the user upon login + * @method verifyToken + * @param {string} req authorization header + * @param {string} res token generated + * @param {Function} next move to the next function + * @return {void} + */ function verifyToken(req, res, next) { const token = req.headers.authorization || req.headers['x-access-token']; if (token) { @@ -22,6 +29,14 @@ function verifyToken(req, res, next) { } } +/** + * checking for admin access + * @method adminAccess + * @param {string} req authorization header + * @param {string} res token generated + * @param {Function} next move to the next function + * @return {void} + */ function adminAccess(req, res, next) { if (req.decoded.roleId === 1) { next(); diff --git a/server/test/controllers/document.spec.js b/server/test/controllers/document.spec.js index 4810302..70013fa 100644 --- a/server/test/controllers/document.spec.js +++ b/server/test/controllers/document.spec.js @@ -1,29 +1,28 @@ import chai from 'chai'; import request from 'supertest'; -import http from 'chai-http'; import server from '../../../index'; import data from './mockData'; const expect = chai.expect; -chai.use(http); +const superRequest = request(server); let userToken, adminToken, sampleUserToken; const { admin, fellow } = data; describe('Documents', () => { before((done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(admin) .end((err, res) => { adminToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send(fellow) .end((err, res) => { userToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send({ email: 'blessing@test.com', password: 'pass123' }) .end((err, res) => { @@ -40,7 +39,7 @@ describe('Documents', () => { access: 'public', userId: 2, }; - request(server) + superRequest .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -61,7 +60,7 @@ describe('Documents', () => { content: 'eze goes to school', access: 'public', }; - request(server) + superRequest .post('/api/v1/documents') .set({ authorization: userToken }) .end((err, res) => { @@ -77,7 +76,7 @@ describe('Documents', () => { value: 'private', userId: 2, }; - request(server) + superRequest .post('/api/v1/documents') .send(document) .end((err, res) => { @@ -95,7 +94,7 @@ describe('Documents', () => { access: '', userId: 1, }; - request(server) + superRequest .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -114,7 +113,7 @@ describe('Documents', () => { value: 'public', userId: 2, }; - request(server) + superRequest .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -133,7 +132,7 @@ describe('Documents', () => { value: 'public', userId: 2, }; - request(server) + superRequest .post('/api/v1/documents') .send(document) .set({ authorization: userToken }) @@ -149,7 +148,7 @@ describe('Documents', () => { describe('/GET Documents', () => { it('Should get all documents for the user that is authenticated', (done) => { - request(server) + superRequest .get('/api/v1/documents') .set({ authorization: userToken }) .end((err, res) => { @@ -161,7 +160,7 @@ describe('Documents', () => { }); it('should fail to get all documents if the user is not authenticated', (done) => { - request(server) + superRequest .get('/api/v1/documents/') .end((err, res) => { expect(res.status).to.equal(403); @@ -173,7 +172,7 @@ describe('Documents', () => { }); it('Should get all documents with correct limit as a query', (done) => { const limit = 1; - request(server) + superRequest .get(`/api/v1/documents?limit=${limit}`) .set({ authorization: userToken }) .end((err, res) => { @@ -184,7 +183,7 @@ describe('Documents', () => { }); it('Should get all documents with correct offset as a query', (done) => { const offset = 0; - request(server) + superRequest .get(`/api/v1/documents?limit=${offset}`) .set({ authorization: userToken }) .end((err, res) => { @@ -198,7 +197,7 @@ describe('Documents', () => { describe('/GET/:id Document', () => { it('Should fail to get document if it doesn`t exist', (done) => { const documentId = 8; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: userToken }) .end((err, res) => { @@ -210,7 +209,7 @@ describe('Documents', () => { }); it('Should get all public regardless of id', (done) => { const documentId = 4; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: userToken }) .end((err, res) => { @@ -225,7 +224,7 @@ describe('Documents', () => { it('Should fail to get a private document if the requester does not own it', (done) => { const documentId = 2; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: sampleUserToken }) .end((err, res) => { @@ -239,7 +238,7 @@ describe('Documents', () => { it('Should get a private document the where the requester is the owner', (done) => { const documentId = 2; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: userToken }) .end((err, res) => { @@ -255,7 +254,7 @@ describe('Documents', () => { it('Should fail get a role document if the users are not on the same role', (done) => { const documentId = 3; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: sampleUserToken }) .end((err, res) => { @@ -269,7 +268,7 @@ describe('Documents', () => { it('Should get a role document if the users are on the same role', (done) => { const documentId = 3; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: userToken }) .end((err, res) => { @@ -283,7 +282,7 @@ describe('Documents', () => { }); it('Should get a role document if the user is an admin', (done) => { const documentId = 3; - request(server) + superRequest .get(`/api/v1/documents/${documentId}/`) .set({ authorization: adminToken }) .end((err, res) => { @@ -301,7 +300,7 @@ describe('Documents', () => { it('Should update a document by id if the user has the same id', (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/documents/${id}`) .set({ authorization: userToken }) .send({ title: 'wreck it ralph' }) @@ -317,7 +316,7 @@ describe('Documents', () => { id if the user does not have the same id`, (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/documents/${id}`) .set({ authorization: sampleUserToken }) .send({ title: 'spiderman Homecoming' }) @@ -332,7 +331,7 @@ describe('Documents', () => { it('Should not update a document by id if the user has admin access', (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/documents/${id}`) .set({ authorization: adminToken }) .send({ title: 'wreck it' }) @@ -344,7 +343,7 @@ describe('Documents', () => { it('Should fail to update a document by id if the document does not exist', (done) => { const id = 10; - request(server) + superRequest .put(`/api/v1/documents/${id}`) .set({ authorization: userToken }) .send({ title: 'Deadpool' }) @@ -360,7 +359,7 @@ describe('Documents', () => { describe('DELETE/:id Document', () => { it('Should delete a document if the user has admin access', (done) => { const id = 3; - request(server) + superRequest .delete(`/api/v1/documents/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -370,7 +369,7 @@ describe('Documents', () => { }); it('Should delete a document if the user is the owner', (done) => { const id = 2; - request(server) + superRequest .delete(`/api/v1/documents/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -381,7 +380,7 @@ describe('Documents', () => { it('Should fail to delete the document given the user is not the owner', (done) => { const id = 1; - request(server) + superRequest .delete(`/api/v1/documents/${id}`) .set({ authorization: sampleUserToken }) .end((err, res) => { @@ -394,7 +393,7 @@ describe('Documents', () => { }); it('Should fail to delete if the document does not exist', (done) => { const id = 234; - request(server) + superRequest .delete(`/api/v1/documents/${id}`) .set({ authorization: userToken }) .end((err, res) => { diff --git a/server/test/controllers/mockData.js b/server/test/controllers/mockData.js index 6599fee..5111a82 100644 --- a/server/test/controllers/mockData.js +++ b/server/test/controllers/mockData.js @@ -11,7 +11,7 @@ export default { email: 'john@test.com', password: process.env.TEST_FELLOW_PASSWORD }, - faciliatator: { + facilitator: { email: 'blessing@test.com', password: process.env.TEST_FACILITATOR_PASSWORD }, diff --git a/server/test/controllers/role.spec.js b/server/test/controllers/role.spec.js index fa4ecdb..586a336 100644 --- a/server/test/controllers/role.spec.js +++ b/server/test/controllers/role.spec.js @@ -1,23 +1,22 @@ import chai from 'chai'; import request from 'supertest'; -import http from 'chai-http'; import server from '../../../index'; import data from './mockData'; const expect = chai.expect; -chai.use(http); +const superRequest = request(server); let userToken, adminToken; const { admin, fellow } = data; describe('Roles', () => { before((done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(admin) .end((err, res) => { adminToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send(fellow) .end((err, res) => { @@ -28,7 +27,7 @@ describe('Roles', () => { describe('/POST Role', () => { it('should add a new role if the user is an admin', (done) => { - request(server) + superRequest .post('/api/v1/roles') .send({ title: 'boromir' }) .set({ authorization: adminToken }) @@ -42,7 +41,7 @@ describe('Roles', () => { done(); }); it('should add a new role if the user is an admin', (done) => { - request(server) + superRequest .post('/api/v1/roles') .send({ title: 'king' }) .set({ authorization: adminToken }) @@ -58,7 +57,7 @@ describe('Roles', () => { const role = { title: 'boromir-team' }; - request(server) + superRequest .post('/api/v1/roles/') .set({ authorization: userToken }) .send(role) @@ -73,7 +72,7 @@ describe('Roles', () => { describe('/GET Role', () => { it('Should get all the roles if the user is an admin', (done) => { - chai.request(server) + superRequest .get('/api/v1/roles') .set({ authorization: adminToken }) .end((err, res) => { @@ -88,7 +87,7 @@ describe('Roles', () => { }); }); it('Should fail to get the roles if the user is not admin', (done) => { - chai.request(server) + superRequest .get('/api/v1/roles') .set({ authorization: userToken }) .end((err, res) => { @@ -103,7 +102,7 @@ describe('Roles', () => { describe('/GET/:id Role', () => { it('Should get a role by id if the user is an admin', (done) => { const id = 2; - chai.request(server) + superRequest .get(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -117,7 +116,7 @@ describe('Roles', () => { it('Should fail to get a role by id if the user is not an admin', (done) => { const id = 2; - chai.request(server) + superRequest .get(`/api/v1/roles/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -129,7 +128,7 @@ describe('Roles', () => { it('Should fail to get a role by id if the user enters an invalid input', (done) => { const id = 'fddjsdcdjn'; - chai.request(server) + superRequest .get(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -141,7 +140,7 @@ describe('Roles', () => { }); it('Should fail to get a role by id if the role does not exist', (done) => { const id = 250; - chai.request(server) + superRequest .get(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -152,7 +151,7 @@ describe('Roles', () => { }); it('Should fail to get a role by id if the id is out of range', (done) => { const id = 500000000000000000000; - request(server) + superRequest .get(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -165,7 +164,7 @@ describe('Roles', () => { describe('/PUT/:id Role', () => { it('Should update a role by id if the user has admin access', (done) => { const id = 2; - chai.request(server) + superRequest .put(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .send({ title: 'boromir-team' }) @@ -180,7 +179,7 @@ describe('Roles', () => { it('Should fail to update a role by id if the user has no admin access', (done) => { const id = 2; - chai.request(server) + superRequest .put(`/api/v1/roles/${id}`) .set({ authorization: userToken }) .send({ title: 'boromir' }) @@ -195,7 +194,7 @@ describe('Roles', () => { role by id if the admin enters an invalid input`, (done) => { const id = 200; - chai.request(server) + superRequest .put(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .send({ title: 'kiba' }) @@ -209,7 +208,7 @@ describe('Roles', () => { it(`Should fail to update a role by id if the admin enters an id that is out range`, (done) => { const id = 2000000000000000; - request(server) + superRequest .put(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .send({ title: 'regular' }) @@ -225,7 +224,7 @@ describe('Roles', () => { it('Should fail to delete a role given the user has no admin access', (done) => { const id = 2; - request(server) + superRequest .delete(`/api/v1/roles/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -237,7 +236,7 @@ describe('Roles', () => { }); it('Should delete a role given the user has admin access', (done) => { const id = 3; - request(server) + superRequest .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -250,7 +249,7 @@ describe('Roles', () => { it(`Should fail to delete a role given the admin enters an input that is out of range`, (done) => { const id = 3000000000000000; - request(server) + superRequest .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -264,7 +263,7 @@ describe('Roles', () => { given the admin enters an id that is not found`, (done) => { const id = -3; - request(server) + superRequest .delete(`/api/v1/roles/${id}`) .set({ authorization: adminToken }) .end((err, res) => { diff --git a/server/test/controllers/search.spec.js b/server/test/controllers/search.spec.js index 740d4a1..8640861 100644 --- a/server/test/controllers/search.spec.js +++ b/server/test/controllers/search.spec.js @@ -1,24 +1,23 @@ import chai from 'chai'; import request from 'supertest'; -import http from 'chai-http'; import server from '../../../index'; import data from './mockData'; const expect = chai.expect; -chai.use(http); +const superRequest = request(server); let userToken, adminToken; const { admin, fellow, Baas } = data; describe('Search', () => { before((done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(admin) .end((err, res) => { adminToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send(fellow) .end((err, res) => { @@ -30,7 +29,7 @@ describe('Search', () => { describe('/SEARCH/users/?q={name}', () => { it('Should return an error if no querystring is provided', (done) => { const query = ''; - request(server) + superRequest .get(`/api/v1/search/users/?q=${query}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -42,7 +41,7 @@ describe('Search', () => { it('Should return a search list response of the required search input', (done) => { const query = Baas.userName; - request(server) + superRequest .get(`/api/v1/search/users/?q=${query}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -56,7 +55,7 @@ describe('Search', () => { describe('/SEARCH/documents/?q=', () => { it('Should return an error if no querystring is provided', (done) => { const query = ''; - request(server) + superRequest .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { @@ -67,7 +66,7 @@ describe('Search', () => { }); it('Should return a search list of the required search input', (done) => { const query = 'John'; - request(server) + superRequest .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -81,7 +80,7 @@ describe('Search', () => { it('Should throw an error if the searched document is not found', (done) => { const query = 'jk'; - request(server) + superRequest .get(`/api/v1/search/documents/?q=${query}`) .set({ authorization: userToken }) .end((err, res) => { diff --git a/server/test/controllers/user.spec.js b/server/test/controllers/user.spec.js index 1fb064b..aa8c383 100644 --- a/server/test/controllers/user.spec.js +++ b/server/test/controllers/user.spec.js @@ -1,29 +1,28 @@ import chai from 'chai'; import request from 'supertest'; -import http from 'chai-http'; import server from '../../../index'; import data from './mockData'; const expect = chai.expect; -chai.use(http); +const superRequest = request(server); let userToken, adminToken, sampleUserToken; const { admin, fakeBass, fellow, user1, user2 } = data; describe('Users', () => { before((done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(admin) .end((err, res) => { adminToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send(fellow) .end((err, res) => { userToken = res.body.token; }); - request(server) + superRequest .post('/api/v1/users/login') .send({ email: 'blessing@test.com', password: 'pass123' }) .end((err, res) => { @@ -35,7 +34,7 @@ describe('Users', () => { describe('/POST User login', () => { it('Should fail if the user enters incorrect crendentials upon login', (done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(user1) .end((err, res) => { @@ -49,7 +48,7 @@ describe('Users', () => { }); it('Should fail if the user provide a wrong password', (done) => { - request(server) + superRequest .post('/api/v1/users/login') .send(user2) .end((err, res) => { @@ -63,7 +62,7 @@ describe('Users', () => { }); it('should log in a user and return a token', (done) => { - request(server) + superRequest .post('/api/v1/users/login').send(admin).end((err, res) => { expect(res.status).to.equal(201); expect(res.body).to.have.keys(['success', 'token']); @@ -74,7 +73,7 @@ describe('Users', () => { describe('/POST User Signup', () => { it('should create a new user', (done) => { - request(server) + superRequest .post('/api/v1/users/').send(fakeBass).end((err, res) => { expect(res.status).to.equal(200); expect(res.body) @@ -89,7 +88,7 @@ describe('Users', () => { describe('#GET Users', () => { it('Should get all users if the user is an admin ', (done) => { - request(server) + superRequest .get('/api/v1/users') .set({ authorization: adminToken }) .end((err, res) => { @@ -101,7 +100,7 @@ describe('Users', () => { }); it('Should fail to get all users if the user has no admin access ', (done) => { - request(server) + superRequest .get('/api/v1/users') .set({ authorization: userToken }) .end((err, res) => { @@ -112,7 +111,7 @@ describe('Users', () => { }); }); it('Should fail to get all users if no token was provided', (done) => { - request(server) + superRequest .get('/api/v1/users') .end((err, res) => { expect(res.status).to.equal(403); @@ -123,7 +122,7 @@ describe('Users', () => { }); it('Should get all users with correct limit as a query', (done) => { const limit = 1; - chai.request(server) + superRequest .get(`/api/v1/users?limit=${limit}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -138,7 +137,7 @@ describe('Users', () => { describe('#GET User by Id', () => { it('Should get a user if the user is an admin', (done) => { const id = 2; - request(server) + superRequest .get(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -155,7 +154,7 @@ describe('Users', () => { it('Should get the user if the requested user is the current user', (done) => { const id = 2; - request(server) + superRequest .get(`/api/v1/users/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -172,7 +171,7 @@ describe('Users', () => { it('Should fail to get a user if an invalid input is entered', (done) => { const id = 'fddjsdcdjn'; - request(server) + superRequest .get(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -185,7 +184,7 @@ describe('Users', () => { it('should fail to get the user if the requester is not the owner', (done) => { const id = 2; - request(server) + superRequest .get(`api/users/${id}`) .set({ authorization: sampleUserToken }) .end((err, res) => { @@ -198,7 +197,7 @@ describe('Users', () => { it('Should fail to get a user if the user does not exist', (done) => { const id = 250; - request(server) + superRequest .get(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -211,7 +210,7 @@ describe('Users', () => { it('Should fail to get a user if the id is out of range', (done) => { const id = 500000000000000000; - request(server) + superRequest .get(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -226,7 +225,7 @@ describe('Users', () => { it('Should update a user`s full name if the user has the same id', (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/users/${id}`) .set({ authorization: userToken }) .send({ fullName: 'jake doe' }) @@ -240,7 +239,7 @@ describe('Users', () => { }); it('Should update a user`s email if the user has the same id', (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/users/${id}`) .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) @@ -255,7 +254,7 @@ describe('Users', () => { it('Should update a user`s username if the user has the same id', (done) => { const id = 2; - request(server) + superRequest .put(`/api/v1/users/${id}`) .set({ authorization: userToken }) .send({ userName: 'jakedoe12' }) @@ -271,7 +270,7 @@ describe('Users', () => { details if the user does not have the same user id`, (done) => { const id = 3; - request(server) + superRequest .put(`/api/v1/users/${id}`) .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) @@ -287,7 +286,7 @@ describe('Users', () => { details if the user enters an invalid user id`, (done) => { const id = 2302; - request(server) + superRequest .put(`/api/v1/users/${id}`) .set({ authorization: userToken }) .send({ email: 'jakedoe@andela.com' }) @@ -303,7 +302,7 @@ describe('Users', () => { describe('#DELETE /:id Users', () => { it('Should delete a user given the user has admin access', (done) => { const id = 3; - request(server) + superRequest .delete(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -314,7 +313,7 @@ describe('Users', () => { it('Should fail to delete a user if the user has no admin access', (done) => { const id = 3; - request(server) + superRequest .delete(`/api/v1/users/${id}`) .set({ authorization: userToken }) .end((err, res) => { @@ -326,7 +325,7 @@ describe('Users', () => { }); it('Should give a User not found if user don\'t exist', (done) => { const id = 23; - request(server) + superRequest .delete(`/api/v1/users/${id}`) .set({ authorization: adminToken }) .end((err, res) => { @@ -340,7 +339,7 @@ describe('Users', () => { describe('/GET/users/:id/documents Documents', () => { it('Should fail to get documents if the user does not exist', (done) => { const userId = 9; - request(server) + superRequest .get(`/api/v1/users/${userId}/documents`) .set({ authorization: userToken }) .end((err, res) => { @@ -353,7 +352,7 @@ describe('Users', () => { it('Should fail to get documents if there is no token present', (done) => { const userId = 2; - request(server) + superRequest .get(`/api/v1/users/${userId}/documents`) .end((err, res) => { expect(res.status).to.equal(403); @@ -365,7 +364,7 @@ describe('Users', () => { }); it('Should get documents for the user with its unique userId', (done) => { const userId = 2; - request(server) + superRequest .get(`/api/v1/users/${userId}/documents`) .set({ authorization: userToken }) .end((err, res) => { diff --git a/server/test/middlewares/auth.spec.js b/server/test/middlewares/auth.spec.js new file mode 100644 index 0000000..dc05424 --- /dev/null +++ b/server/test/middlewares/auth.spec.js @@ -0,0 +1,104 @@ +import chai from 'chai'; +import httpMocks from 'node-mocks-http'; +import request from 'supertest'; +import server from '../../../index'; +import data from '../controllers/mockData'; +import auth from '../../middlewares/auth'; + +const EventEmitter = require('events').EventEmitter; +const expect = chai.expect; + +const superRequest = request(server); +let adminToken, userToken; +const { admin, fellow } = data; + +describe('Authentication', () => { + before((done) => { + superRequest + .post('/api/v1/users/login') + .send(admin) + .end((err, res) => { + adminToken = res.body.token; + }); + superRequest + .post('/api/v1/users/login') + .send(fellow) + .end((err, res) => { + userToken = res.body.token; + done(); + }); + }); + + describe('VerifyToken', () => { + it('Should check if the token is provided with request', (done) => { + const httpRequest = httpMocks.createRequest({ + method: 'GET', + url: '/api/v1/documents', + }); + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.verifyToken(httpRequest, response, nextCallBack); + expect(response._getData().message).to.equal('No token provided.'); + done(); + }); + it('Should provide access if the token is provided and valid', (done) => { + const httpRequest = httpMocks.createRequest({ + method: 'GET', + url: '/api/v1/documents', + headers: { 'x-access-token': adminToken } + }); + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.verifyToken(httpRequest, response, nextCallBack); + expect(response._getData().message).to.equal(undefined); + done(); + }); + it('Should deny access if the token is invalid', (done) => { + const httpRequest = httpMocks.createRequest({ + method: 'GET', + url: '/api/v1/documents/', + headers: { 'x-access-token': 'thisisandela' } + }); + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.verifyToken(httpRequest, response, nextCallBack); + response.on('end', () => { + expect(response._getData().success).to.equal(false); + }); + done(); + }); + }); + + describe('AdminAccess', () => { + it('Should deny access if the user is not admin', (done) => { + const httpRequest = httpMocks.createRequest({ + method: 'GET', + url: '/api/v1/documents/', + headers: { 'x-access-token': userToken } + }); + httpRequest.decoded = { roleId: 2 }; + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.adminAccess(httpRequest, response, nextCallBack); + response.on('end', () => { + expect(response._getData().message).to.equal('You are not authorized'); + }); + done(); + }); + it('Should grant access if the user is an admin', (done) => { + const httpRequest = httpMocks.createRequest({ + method: 'GET', + url: '/api/v1/documents/', + headers: { 'x-access-token': adminToken } + }); + httpRequest.decoded = { roleId: 1 }; + const response = httpMocks.createResponse(); + const nextCallBack = () => { }; + auth.adminAccess(httpRequest, response, nextCallBack); + response.on('end', () => { + expect(response._getData().message).to.equal(undefined); + }); + done(); + }); + }); +}); From 5adc7fd6f320ff2e9015994368124bc94d7564fa Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 7 Aug 2017 13:46:53 +0100 Subject: [PATCH 60/98] feat(testing):test -configuring codeclimate --- codeclimate.yml | 2 +- gulpfile.babel.js | 2 +- server/{test => tests}/controllers/document.spec.js | 0 server/{test => tests}/controllers/mockData.js | 0 server/{test => tests}/controllers/role.spec.js | 0 server/{test => tests}/controllers/search.spec.js | 0 server/{test => tests}/controllers/user.spec.js | 0 server/{test => tests}/middlewares/auth.spec.js | 0 8 files changed, 2 insertions(+), 2 deletions(-) rename server/{test => tests}/controllers/document.spec.js (100%) rename server/{test => tests}/controllers/mockData.js (100%) rename server/{test => tests}/controllers/role.spec.js (100%) rename server/{test => tests}/controllers/search.spec.js (100%) rename server/{test => tests}/controllers/user.spec.js (100%) rename server/{test => tests}/middlewares/auth.spec.js (100%) diff --git a/codeclimate.yml b/codeclimate.yml index b993a4b..b79c857 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -17,4 +17,4 @@ ratings: - "**.jsx" exclude_paths: - node_modules/**/* -- server/test/ +- server/tests/ diff --git a/gulpfile.babel.js b/gulpfile.babel.js index e8763c5..9fadd89 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -23,7 +23,7 @@ gulp.task('migrate', shell.task([ ])); gulp.task('coverage', shell.task([ - 'cross-env NODE_ENV=test nyc mocha ./server/test/**/*.js', + 'cross-env NODE_ENV=test nyc mocha ./server/tests/**/*.js', ])); // Restart server with on every changes made to file diff --git a/server/test/controllers/document.spec.js b/server/tests/controllers/document.spec.js similarity index 100% rename from server/test/controllers/document.spec.js rename to server/tests/controllers/document.spec.js diff --git a/server/test/controllers/mockData.js b/server/tests/controllers/mockData.js similarity index 100% rename from server/test/controllers/mockData.js rename to server/tests/controllers/mockData.js diff --git a/server/test/controllers/role.spec.js b/server/tests/controllers/role.spec.js similarity index 100% rename from server/test/controllers/role.spec.js rename to server/tests/controllers/role.spec.js diff --git a/server/test/controllers/search.spec.js b/server/tests/controllers/search.spec.js similarity index 100% rename from server/test/controllers/search.spec.js rename to server/tests/controllers/search.spec.js diff --git a/server/test/controllers/user.spec.js b/server/tests/controllers/user.spec.js similarity index 100% rename from server/test/controllers/user.spec.js rename to server/tests/controllers/user.spec.js diff --git a/server/test/middlewares/auth.spec.js b/server/tests/middlewares/auth.spec.js similarity index 100% rename from server/test/middlewares/auth.spec.js rename to server/tests/middlewares/auth.spec.js From 3c499e3fcc02ebc99fffeba530a006cdd1c2185f Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 7 Aug 2017 14:23:01 +0100 Subject: [PATCH 61/98] feat(testing):test -configuring codeclimate --- codeclimate.yml | 2 +- gulpfile.babel.js | 4 ++-- server/config/config.js | 7 ++++++- server/{tests => test}/controllers/document.spec.js | 0 server/{tests => test}/controllers/mockData.js | 0 server/{tests => test}/controllers/role.spec.js | 0 server/{tests => test}/controllers/search.spec.js | 0 server/{tests => test}/controllers/user.spec.js | 0 server/{tests => test}/middlewares/auth.spec.js | 0 9 files changed, 9 insertions(+), 4 deletions(-) rename server/{tests => test}/controllers/document.spec.js (100%) rename server/{tests => test}/controllers/mockData.js (100%) rename server/{tests => test}/controllers/role.spec.js (100%) rename server/{tests => test}/controllers/search.spec.js (100%) rename server/{tests => test}/controllers/user.spec.js (100%) rename server/{tests => test}/middlewares/auth.spec.js (100%) diff --git a/codeclimate.yml b/codeclimate.yml index b79c857..680b9e5 100644 --- a/codeclimate.yml +++ b/codeclimate.yml @@ -17,4 +17,4 @@ ratings: - "**.jsx" exclude_paths: - node_modules/**/* -- server/tests/ +- server/test/** diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 9fadd89..4e13546 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -8,7 +8,7 @@ const plugins = loadPlugins(); // Compile all Babel Javascript into ES5 and place in dist folder const paths = { - js: ['./**/*.js', '!dist/**', '!node_modules/**'] + js: ['./**/*.js', '!dist/**', '!node_modules/**', '!./server/tests/**'] }; // Compile all Babel Javascript into ES5 and put it into the dist dir @@ -23,7 +23,7 @@ gulp.task('migrate', shell.task([ ])); gulp.task('coverage', shell.task([ - 'cross-env NODE_ENV=test nyc mocha ./server/tests/**/*.js', + 'cross-env NODE_ENV=test nyc mocha ./server/test/**/*.js', ])); // Restart server with on every changes made to file diff --git a/server/config/config.js b/server/config/config.js index c0da612..5ae4cac 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -10,7 +10,12 @@ module.exports = { dialect: 'postgres' }, test: { - use_env_variable: 'TEST_DB' + username: 'andeladeveloper', + password: null, + database: 'docmanager-test', + host: '127.0.0.1', + port: 5432, + dialect: 'postgres' }, production: { username: 'root', diff --git a/server/tests/controllers/document.spec.js b/server/test/controllers/document.spec.js similarity index 100% rename from server/tests/controllers/document.spec.js rename to server/test/controllers/document.spec.js diff --git a/server/tests/controllers/mockData.js b/server/test/controllers/mockData.js similarity index 100% rename from server/tests/controllers/mockData.js rename to server/test/controllers/mockData.js diff --git a/server/tests/controllers/role.spec.js b/server/test/controllers/role.spec.js similarity index 100% rename from server/tests/controllers/role.spec.js rename to server/test/controllers/role.spec.js diff --git a/server/tests/controllers/search.spec.js b/server/test/controllers/search.spec.js similarity index 100% rename from server/tests/controllers/search.spec.js rename to server/test/controllers/search.spec.js diff --git a/server/tests/controllers/user.spec.js b/server/test/controllers/user.spec.js similarity index 100% rename from server/tests/controllers/user.spec.js rename to server/test/controllers/user.spec.js diff --git a/server/tests/middlewares/auth.spec.js b/server/test/middlewares/auth.spec.js similarity index 100% rename from server/tests/middlewares/auth.spec.js rename to server/test/middlewares/auth.spec.js From 4038a352140a324e767a2618a96c8871f37b50b0 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 7 Aug 2017 14:24:47 +0100 Subject: [PATCH 62/98] feat(testing):test -configuring codeclimate --- server/config/config.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/server/config/config.js b/server/config/config.js index 5ae4cac..c0da612 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -10,12 +10,7 @@ module.exports = { dialect: 'postgres' }, test: { - username: 'andeladeveloper', - password: null, - database: 'docmanager-test', - host: '127.0.0.1', - port: 5432, - dialect: 'postgres' + use_env_variable: 'TEST_DB' }, production: { username: 'root', From 8a72ba056c225dded6e0b0338af484126ff442a9 Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Mon, 7 Aug 2017 15:43:22 +0100 Subject: [PATCH 63/98] feat(testing):test -configuring codeclimate --- package.json | 3 +- public/api-doc/favicon-16x16.png | Bin 0 -> 445 bytes public/api-doc/favicon-32x32.png | Bin 0 -> 1141 bytes public/api-doc/index.html | 95 ++++++++++++++++++ public/api-doc/oauth2-redirect.html | 53 ++++++++++ public/api-doc/swagger-ui-bundle.js | 81 +++++++++++++++ public/api-doc/swagger-ui-bundle.js.map | 1 + .../api-doc/swagger-ui-standalone-preset.js | 13 +++ .../swagger-ui-standalone-preset.js.map | 1 + public/api-doc/swagger-ui.css | 2 + public/api-doc/swagger-ui.css.map | 1 + public/api-doc/swagger-ui.js | 8 ++ public/api-doc/swagger-ui.js.map | 1 + server/config/express.js | 37 +++++++ 14 files changed, 295 insertions(+), 1 deletion(-) create mode 100755 public/api-doc/favicon-16x16.png create mode 100755 public/api-doc/favicon-32x32.png create mode 100755 public/api-doc/index.html create mode 100755 public/api-doc/oauth2-redirect.html create mode 100755 public/api-doc/swagger-ui-bundle.js create mode 100755 public/api-doc/swagger-ui-bundle.js.map create mode 100755 public/api-doc/swagger-ui-standalone-preset.js create mode 100755 public/api-doc/swagger-ui-standalone-preset.js.map create mode 100755 public/api-doc/swagger-ui.css create mode 100755 public/api-doc/swagger-ui.css.map create mode 100755 public/api-doc/swagger-ui.js create mode 100755 public/api-doc/swagger-ui.js.map diff --git a/package.json b/package.json index 82890ed..9cc4ca6 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ "pg": "^6.4.0", "pg-hstore": "^2.3.2", "sequelize": "^4.2.1", - "sequelize-cli": "^2.7.0" + "sequelize-cli": "^2.7.0", + "swagger-jsdoc": "^1.9.7" }, "devDependencies": { "babel-core": "^6.25.0", diff --git a/public/api-doc/favicon-16x16.png b/public/api-doc/favicon-16x16.png new file mode 100755 index 0000000000000000000000000000000000000000..0f7e13b0d9903d27a9129950b1dad362361504e4 GIT binary patch literal 445 zcmV;u0Yd(XP)rNm2=6wQ7&2F}_`h_PI>(9Fx!5<0%l6W{u0OQ#*rglqx3__&vD?|#%fhn*Mn&YY1i+JQHqPvZ34FR@_E%P@x zzTL;Bw#nJXWY}D7^bC>-bx{t|^|R6Oci&MKvov8Op~S=}R=h^p-=vZ0uqG@LE6tP7 n92{cY$^db6>&z__iT?Z#Z8BG|DVcT0DjiaEd>Z!7_`J}8! zKk_$1lGm$vJOY&DjT-(&VGn0;R`iN9=1aOuG`H}BlY>&R3KbGER zB2$7euhH;y1C_LTQex%L6khZpkjFn!ajOUK)f3JLz+I;CE@(N)T)CM4AWjfl-(04= zrsMQ)#NG6nr^Y7!6LA;iHXh?UOFE%hhy>7dl=;I$J>g0BH_r|_4ctEsXx z2sDIQnwa*rcK=*3XUC$D{I@}DTNs@GCb7dB2%%nV%jR){xktt;Ah09op7x@l5D6B2 z0uBdt0YmcN!o?lMpu9Io(1&B1s{TUu*a>2&>Iycx__fbDRM8PYtLt+#G*xSt(cn}K zt!~W2{`9r)xkh^xodLS&FbYw`x$t&Vhl?)#f&k-lZIs<`$gTj{^#^HewuJz(WnUZZ z{Ty_aE;^93bhc-^^k6ZM!^e~$q5!Zz`XPta{a@651gPzaFx$&%IHL6hx$mSeAa#n6 zLkyc-M zs$qhBZhCNE^aIEV)H_~^IeqSRnvo!21Qc`Z;S9!IqXl4K(RUImejotzuG65LVuGS# zcqp@OA8~ln^4c^VihUew)IOX^E9KMtvSvnZ| zC@rl{f(B*PA26aFR`|X!!I(7x_|kq{rlqwhCia+CfNbOg_yYt0bDCc4g#h#`3jpCd zNAhr%4#Ye{i>ni$fzY%r0IS%l3HHZ4tTjOi=JW-t_iG~)oC!2C!52Cc|TAPaH zJ}l%m9yPmA-4#lJea@uf$a`(1;={rL2f*8;7%icbF}e^_`X#ndU=SI0nIn8hXPXHS zSN4rbF}jl0HWx(_`q`-SRa9jP8Ab!}sThNkQ634k=qXBVM4`o{M>qrLJD ze*%D)S;wpxG$d%FcDf-6%zMqWA+gw!C1~T5+|ys$G3Ksm&x59Lyd?0l+LWSk6hc4~ z+yC>|4f;X3#cq3!)>#Mvb-^co7LMrzqWeKB$21I>tJgaGFwu6eB%&j?@d*8GAx~In zI1p-lXVKtcvY7;$TX~wjYw|QhB%q!npQES%F~%Aqz~pJB%rNu!xAj;>xZt75!VHju zfFy%B-`3;Qf<{h94~I62zcHv}D5pS-QCN`M8K1>jN9mpbrFk=5no8j!00000NkvXX Hu0mjfOavUK literal 0 HcmV?d00001 diff --git a/public/api-doc/index.html b/public/api-doc/index.html new file mode 100755 index 0000000..423b5c1 --- /dev/null +++ b/public/api-doc/index.html @@ -0,0 +1,95 @@ + + + + + + Swagger UI + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + diff --git a/public/api-doc/oauth2-redirect.html b/public/api-doc/oauth2-redirect.html new file mode 100755 index 0000000..00c7f01 --- /dev/null +++ b/public/api-doc/oauth2-redirect.html @@ -0,0 +1,53 @@ + + + + + + diff --git a/public/api-doc/swagger-ui-bundle.js b/public/api-doc/swagger-ui-bundle.js new file mode 100755 index 0000000..c3a98a6 --- /dev/null +++ b/public/api-doc/swagger-ui-bundle.js @@ -0,0 +1,81 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SwaggerUIBundle=t():e.SwaggerUIBundle=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist",t(t.s=1237)}([function(e,t,n){"use strict";e.exports=n(85)},function(e,t,n){e.exports=n(908)()},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(316),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(){function e(e,t){for(var n=0;n>>0;if(""+n!==t||4294967295===n)return NaN;t=n}return t<0?d(e)+t:t}function v(){return!0}function g(e,t,n){return(0===e||void 0!==n&&e<=-n)&&(void 0===t||void 0!==n&&t>=n)}function y(e,t){return b(e,t,0)}function _(e,t){return b(e,t,t)}function b(e,t,n){return void 0===e?n:e<0?Math.max(0,t+e):void 0===t?e:Math.min(t,e)}function x(e){this.next=e}function w(e,t,n,r){var i=0===e?t:1===e?n:[t,n];return r?r.value=i:r={value:i,done:!1},r}function k(){return{value:void 0,done:!0}}function E(e){return!!A(e)}function S(e){return e&&"function"==typeof e.next}function C(e){var t=A(e);return t&&t.call(e)}function A(e){var t=e&&(wn&&e[wn]||e[kn]);if("function"==typeof t)return t}function D(e){return e&&"number"==typeof e.length}function M(e){return null===e||void 0===e?B():o(e)?e.toSeq():q(e)}function O(e){return null===e||void 0===e?B().toKeyedSeq():o(e)?a(e)?e.toSeq():e.fromEntrySeq():L(e)}function T(e){return null===e||void 0===e?B():o(e)?a(e)?e.entrySeq():e.toIndexedSeq():z(e)}function P(e){return(null===e||void 0===e?B():o(e)?a(e)?e.entrySeq():e:z(e)).toSetSeq()}function I(e){this._array=e,this.size=e.length}function j(e){var t=Object.keys(e);this._object=e,this._keys=t,this.size=t.length}function N(e){this._iterable=e,this.size=e.length||e.size}function R(e){this._iterator=e,this._iteratorCache=[]}function F(e){return!(!e||!e[Sn])}function B(){return Cn||(Cn=new I([]))}function L(e){var t=Array.isArray(e)?new I(e).fromEntrySeq():S(e)?new R(e).fromEntrySeq():E(e)?new N(e).fromEntrySeq():"object"==typeof e?new j(e):void 0;if(!t)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+e);return t}function z(e){var t=U(e);if(!t)throw new TypeError("Expected Array or iterable object of values: "+e);return t}function q(e){var t=U(e)||"object"==typeof e&&new j(e);if(!t)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+e);return t}function U(e){return D(e)?new I(e):S(e)?new R(e):E(e)?new N(e):void 0}function W(e,t,n,r){var i=e._cache;if(i){for(var o=i.length-1,a=0;a<=o;a++){var s=i[n?o-a:a];if(!1===t(s[1],r?s[0]:a,e))return a+1}return a}return e.__iterateUncached(t,n)}function K(e,t,n,r){var i=e._cache;if(i){var o=i.length-1,a=0;return new x(function(){var e=i[n?o-a:a];return a++>o?k():w(t,r?e[0]:a-1,e[1])})}return e.__iteratorUncached(t,n)}function H(e,t){return t?V(t,e,"",{"":e}):G(e)}function V(e,t,n,r){return Array.isArray(t)?e.call(r,n,T(t).map(function(n,r){return V(e,n,r,t)})):J(t)?e.call(r,n,O(t).map(function(n,r){return V(e,n,r,t)})):t}function G(e){return Array.isArray(e)?T(e).map(G).toList():J(e)?O(e).map(G).toMap():e}function J(e){return e&&(e.constructor===Object||void 0===e.constructor)}function X(e,t){if(e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if(e=e.valueOf(),t=t.valueOf(),e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1}return!("function"!=typeof e.equals||"function"!=typeof t.equals||!e.equals(t))}function Y(e,t){if(e===t)return!0;if(!o(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||a(e)!==a(t)||s(e)!==s(t)||c(e)!==c(t))return!1;if(0===e.size&&0===t.size)return!0;var n=!u(e);if(c(e)){var r=e.entries();return t.every(function(e,t){var i=r.next().value;return i&&X(i[1],e)&&(n||X(i[0],t))})&&r.next().done}var i=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{i=!0;var l=e;e=t,t=l}var p=!0,f=t.__iterate(function(t,r){if(n?!e.has(t):i?!X(t,e.get(r,vn)):!X(e.get(r,vn),t))return p=!1,!1});return p&&e.size===f}function $(e,t){if(!(this instanceof $))return new $(e,t);if(this._value=e,this.size=void 0===t?1/0:Math.max(0,t),0===this.size){if(An)return An;An=this}}function Z(e,t){if(!e)throw new Error(t)}function Q(e,t,n){if(!(this instanceof Q))return new Q(e,t,n);if(Z(0!==n,"Cannot step a Range by 0"),e=e||0,void 0===t&&(t=1/0),n=void 0===n?1:Math.abs(n),t>>1&1073741824|3221225471&e}function oe(e){if(!1===e||null===e||void 0===e)return 0;if("function"==typeof e.valueOf&&(!1===(e=e.valueOf())||null===e||void 0===e))return 0;if(!0===e)return 1;var t=typeof e;if("number"===t){if(e!==e||e===1/0)return 0;var n=0|e;for(n!==e&&(n^=4294967295*e);e>4294967295;)e/=4294967295,n^=e;return ie(n)}if("string"===t)return e.length>Rn?ae(e):se(e);if("function"==typeof e.hashCode)return e.hashCode();if("object"===t)return ue(e);if("function"==typeof e.toString)return se(e.toString());throw new Error("Value type "+t+" cannot be hashed.")}function ae(e){var t=Ln[e];return void 0===t&&(t=se(e),Bn===Fn&&(Bn=0,Ln={}),Bn++,Ln[e]=t),t}function se(e){for(var t=0,n=0;n0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}function le(e){Z(e!==1/0,"Cannot perform this action with an infinite size.")}function pe(e){return null===e||void 0===e?we():fe(e)&&!c(e)?e:we().withMutations(function(t){var r=n(e);le(r.size),r.forEach(function(e,n){return t.set(n,e)})})}function fe(e){return!(!e||!e[zn])}function he(e,t){this.ownerID=e,this.entries=t}function de(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n}function me(e,t,n){this.ownerID=e,this.count=t,this.nodes=n}function ve(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n}function ge(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n}function ye(e,t,n){this._type=t,this._reverse=n,this._stack=e._root&&be(e._root)}function _e(e,t){return w(e,t[0],t[1])}function be(e,t){return{node:e,index:0,__prev:t}}function xe(e,t,n,r){var i=Object.create(qn);return i.size=e,i._root=t,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function we(){return Un||(Un=xe(0))}function ke(e,t,n){var r,i;if(e._root){var o=l(gn),a=l(yn);if(r=Ee(e._root,e.__ownerID,0,void 0,t,n,o,a),!a.value)return e;i=e.size+(o.value?n===vn?-1:1:0)}else{if(n===vn)return e;i=1,r=new he(e.__ownerID,[[t,n]])}return e.__ownerID?(e.size=i,e._root=r,e.__hash=void 0,e.__altered=!0,e):r?xe(i,r):we()}function Ee(e,t,n,r,i,o,a,s){return e?e.update(t,n,r,i,o,a,s):o===vn?e:(p(s),p(a),new ge(t,r,[i,o]))}function Se(e){return e.constructor===ge||e.constructor===ve}function Ce(e,t,n,r,i){if(e.keyHash===r)return new ve(t,r,[e.entry,i]);var o,a=(0===n?e.keyHash:e.keyHash>>>n)&mn,s=(0===n?r:r>>>n)&mn;return new de(t,1<>>=1)a[s]=1&n?t[o++]:void 0;return a[r]=i,new me(e,o+1,a)}function Oe(e,t,r){for(var i=[],a=0;a>1&1431655765,e=(858993459&e)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function Re(e,t,n,r){var i=r?e:h(e);return i[t]=n,i}function Fe(e,t,n,r){var i=e.length+1;if(r&&t+1===i)return e[t]=n,e;for(var o=new Array(i),a=0,s=0;s0&&io?0:o-n,c=a-n;return c>dn&&(c=dn),function(){if(i===c)return Xn;var e=t?--c:i++;return r&&r[e]}}function i(e,r,i){var s,u=e&&e.array,c=i>o?0:o-i>>r,l=1+(a-i>>r);return l>dn&&(l=dn),function(){for(;;){if(s){var e=s();if(e!==Xn)return e;s=null}if(c===l)return Xn;var o=t?--l:c++;s=n(u&&u[o],r-hn,i+(o<=e.size||t<0)return e.withMutations(function(e){t<0?Xe(e,t).set(0,n):Xe(e,0,t+1).set(t,n)});t+=e._origin;var r=e._tail,i=e._root,o=l(yn);return t>=$e(e._capacity)?r=Ve(r,e.__ownerID,0,t,n,o):i=Ve(i,e.__ownerID,e._level,t,n,o),o.value?e.__ownerID?(e._root=i,e._tail=r,e.__hash=void 0,e.__altered=!0,e):We(e._origin,e._capacity,e._level,i,r):e}function Ve(e,t,n,r,i,o){var a=r>>>n&mn,s=e&&a0){var c=e&&e.array[a],l=Ve(c,t,n-hn,r,i,o);return l===c?e:(u=Ge(e,t),u.array[a]=l,u)}return s&&e.array[a]===i?e:(p(o),u=Ge(e,t),void 0===i&&a===u.array.length-1?u.array.pop():u.array[a]=i,u)}function Ge(e,t){return t&&e&&t===e.ownerID?e:new qe(e?e.array.slice():[],t)}function Je(e,t){if(t>=$e(e._capacity))return e._tail;if(t<1<0;)n=n.array[t>>>r&mn],r-=hn;return n}}function Xe(e,t,n){void 0!==t&&(t|=0),void 0!==n&&(n|=0);var r=e.__ownerID||new f,i=e._origin,o=e._capacity,a=i+t,s=void 0===n?o:n<0?o+n:i+n;if(a===i&&s===o)return e;if(a>=s)return e.clear();for(var u=e._level,c=e._root,l=0;a+l<0;)c=new qe(c&&c.array.length?[void 0,c]:[],r),u+=hn,l+=1<=1<p?new qe([],r):d;if(d&&h>p&&ahn;g-=hn){var y=p>>>g&mn;v=v.array[y]=Ge(v.array[y],r)}v.array[p>>>hn&mn]=d}if(s=h)a-=h,s-=h,u=hn,c=null,m=m&&m.removeBefore(r,0,a);else if(a>i||h>>u&mn;if(_!==h>>>u&mn)break;_&&(l+=(1<i&&(c=c.removeBefore(r,u,a-l)),c&&ha&&(a=c.size),o(u)||(c=c.map(function(e){return H(e)})),i.push(c)}return a>e.size&&(e=e.setSize(a)),Ie(e,t,i)}function $e(e){return e>>hn<=dn&&a.size>=2*o.size?(i=a.filter(function(e,t){return void 0!==e&&s!==t}),r=i.toKeyedSeq().map(function(e){return e[0]}).flip().toMap(),e.__ownerID&&(r.__ownerID=i.__ownerID=e.__ownerID)):(r=o.remove(t),i=s===a.size-1?a.pop():a.set(s,void 0))}else if(u){if(n===a.get(s)[1])return e;r=o,i=a.set(s,[t,n])}else r=o.set(t,a.size),i=a.set(a.size,[t,n]);return e.__ownerID?(e.size=r.size,e._map=r,e._list=i,e.__hash=void 0,e):et(r,i)}function rt(e,t){this._iter=e,this._useKeys=t,this.size=e.size}function it(e){this._iter=e,this.size=e.size}function ot(e){this._iter=e,this.size=e.size}function at(e){this._iter=e,this.size=e.size}function st(e){var t=Dt(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var t=e.reverse.apply(this);return t.flip=function(){return e.reverse()},t},t.has=function(t){return e.includes(t)},t.includes=function(t){return e.has(t)},t.cacheResult=Mt,t.__iterateUncached=function(t,n){var r=this;return e.__iterate(function(e,n){return!1!==t(n,e,r)},n)},t.__iteratorUncached=function(t,n){if(t===xn){var r=e.__iterator(t,n);return new x(function(){var e=r.next();if(!e.done){var t=e.value[0];e.value[0]=e.value[1],e.value[1]=t}return e})}return e.__iterator(t===bn?_n:bn,n)},t}function ut(e,t,n){var r=Dt(e);return r.size=e.size,r.has=function(t){return e.has(t)},r.get=function(r,i){var o=e.get(r,vn);return o===vn?i:t.call(n,o,r,e)},r.__iterateUncached=function(r,i){var o=this;return e.__iterate(function(e,i,a){return!1!==r(t.call(n,e,i,a),i,o)},i)},r.__iteratorUncached=function(r,i){var o=e.__iterator(xn,i);return new x(function(){var i=o.next();if(i.done)return i;var a=i.value,s=a[0];return w(r,s,t.call(n,a[1],s,e),i)})},r}function ct(e,t){var n=Dt(e);return n._iter=e,n.size=e.size,n.reverse=function(){return e},e.flip&&(n.flip=function(){var t=st(e);return t.reverse=function(){return e.flip()},t}),n.get=function(n,r){return e.get(t?n:-1-n,r)},n.has=function(n){return e.has(t?n:-1-n)},n.includes=function(t){return e.includes(t)},n.cacheResult=Mt,n.__iterate=function(t,n){var r=this;return e.__iterate(function(e,n){return t(e,n,r)},!n)},n.__iterator=function(t,n){return e.__iterator(t,!n)},n}function lt(e,t,n,r){var i=Dt(e);return r&&(i.has=function(r){var i=e.get(r,vn);return i!==vn&&!!t.call(n,i,r,e)},i.get=function(r,i){var o=e.get(r,vn);return o!==vn&&t.call(n,o,r,e)?o:i}),i.__iterateUncached=function(i,o){var a=this,s=0;return e.__iterate(function(e,o,u){if(t.call(n,e,o,u))return s++,i(e,r?o:s-1,a)},o),s},i.__iteratorUncached=function(i,o){var a=e.__iterator(xn,o),s=0;return new x(function(){for(;;){var o=a.next();if(o.done)return o;var u=o.value,c=u[0],l=u[1];if(t.call(n,l,c,e))return w(i,r?c:s++,l,o)}})},i}function pt(e,t,n){var r=pe().asMutable();return e.__iterate(function(i,o){r.update(t.call(n,i,o,e),0,function(e){return e+1})}),r.asImmutable()}function ft(e,t,n){var r=a(e),i=(c(e)?Ze():pe()).asMutable();e.__iterate(function(o,a){i.update(t.call(n,o,a,e),function(e){return e=e||[],e.push(r?[a,o]:o),e})});var o=At(e);return i.map(function(t){return Et(e,o(t))})}function ht(e,t,n,r){var i=e.size;if(void 0!==t&&(t|=0),void 0!==n&&(n===1/0?n=i:n|=0),g(t,n,i))return e;var o=y(t,i),a=_(n,i);if(o!==o||a!==a)return ht(e.toSeq().cacheResult(),t,n,r);var s,u=a-o;u===u&&(s=u<0?0:u);var c=Dt(e);return c.size=0===s?s:e.size&&s||void 0,!r&&F(e)&&s>=0&&(c.get=function(t,n){return t=m(this,t),t>=0&&ts)return k();var e=i.next();return r||t===bn?e:t===_n?w(t,u-1,void 0,e):w(t,u-1,e.value[1],e)})},c}function dt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterate(r,i);var a=0;return e.__iterate(function(e,i,s){return t.call(n,e,i,s)&&++a&&r(e,i,o)}),a},r.__iteratorUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterator(r,i);var a=e.__iterator(xn,i),s=!0;return new x(function(){if(!s)return k();var e=a.next();if(e.done)return e;var i=e.value,u=i[0],c=i[1];return t.call(n,c,u,o)?r===xn?e:w(r,u,c,e):(s=!1,k())})},r}function mt(e,t,n,r){var i=Dt(e);return i.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,u=0;return e.__iterate(function(e,o,c){if(!s||!(s=t.call(n,e,o,c)))return u++,i(e,r?o:u-1,a)}),u},i.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(xn,o),u=!0,c=0;return new x(function(){var e,o,l;do{if(e=s.next(),e.done)return r||i===bn?e:i===_n?w(i,c++,void 0,e):w(i,c++,e.value[1],e);var p=e.value;o=p[0],l=p[1],u&&(u=t.call(n,l,o,a))}while(u);return i===xn?e:w(i,o,l,e)})},i}function vt(e,t){var r=a(e),i=[e].concat(t).map(function(e){return o(e)?r&&(e=n(e)):e=r?L(e):z(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===i.length)return e;if(1===i.length){var u=i[0];if(u===e||r&&a(u)||s(e)&&s(u))return u}var c=new I(i);return r?c=c.toKeyedSeq():s(e)||(c=c.toSetSeq()),c=c.flatten(!0),c.size=i.reduce(function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}},0),c}function gt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){function a(e,c){var l=this;e.__iterate(function(e,i){return(!t||c0}function kt(e,n,r){var i=Dt(e);return i.size=new I(r).map(function(e){return e.size}).min(),i.__iterate=function(e,t){for(var n,r=this.__iterator(bn,t),i=0;!(n=r.next()).done&&!1!==e(n.value,i++,this););return i},i.__iteratorUncached=function(e,i){var o=r.map(function(e){return e=t(e),C(i?e.reverse():e)}),a=0,s=!1;return new x(function(){var t;return s||(t=o.map(function(e){return e.next()}),s=t.some(function(e){return e.done})),s?k():w(e,a++,n.apply(null,t.map(function(e){return e.value})))})},i}function Et(e,t){return F(e)?t:e.constructor(t)}function St(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function Ct(e){return le(e.size),d(e)}function At(e){return a(e)?n:s(e)?r:i}function Dt(e){return Object.create((a(e)?O:s(e)?T:P).prototype)}function Mt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):M.prototype.cacheResult.call(this)}function Ot(e,t){return e>t?1:et?-1:0}function on(e){if(e.size===1/0)return 0;var t=c(e),n=a(e),r=t?1:0;return an(e.__iterate(n?t?function(e,t){r=31*r+sn(oe(e),oe(t))|0}:function(e,t){r=r+sn(oe(e),oe(t))|0}:t?function(e){r=31*r+oe(e)|0}:function(e){r=r+oe(e)|0}),r)}function an(e,t){return t=On(t,3432918353),t=On(t<<15|t>>>-15,461845907),t=On(t<<13|t>>>-13,5),t=(t+3864292196|0)^e,t=On(t^t>>>16,2246822507),t=On(t^t>>>13,3266489909),t=ie(t^t>>>16)}function sn(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}var un=Array.prototype.slice;e(n,t),e(r,t),e(i,t),t.isIterable=o,t.isKeyed=a,t.isIndexed=s,t.isAssociative=u,t.isOrdered=c,t.Keyed=n,t.Indexed=r,t.Set=i;var cn="@@__IMMUTABLE_ITERABLE__@@",ln="@@__IMMUTABLE_KEYED__@@",pn="@@__IMMUTABLE_INDEXED__@@",fn="@@__IMMUTABLE_ORDERED__@@",hn=5,dn=1<r?k():w(e,i,n[t?r-i++:i++])})},e(j,O),j.prototype.get=function(e,t){return void 0===t||this.has(e)?this._object[e]:t},j.prototype.has=function(e){return this._object.hasOwnProperty(e)},j.prototype.__iterate=function(e,t){for(var n=this._object,r=this._keys,i=r.length-1,o=0;o<=i;o++){var a=r[t?i-o:o];if(!1===e(n[a],a,this))return o+1}return o},j.prototype.__iterator=function(e,t){var n=this._object,r=this._keys,i=r.length-1,o=0;return new x(function(){var a=r[t?i-o:o];return o++>i?k():w(e,a,n[a])})},j.prototype[fn]=!0,e(N,T),N.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);var n=this._iterable,r=C(n),i=0;if(S(r))for(var o;!(o=r.next()).done&&!1!==e(o.value,i++,this););return i},N.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var n=this._iterable,r=C(n);if(!S(r))return new x(k);var i=0;return new x(function(){var t=r.next();return t.done?t:w(e,i++,t.value)})},e(R,T),R.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);for(var n=this._iterator,r=this._iteratorCache,i=0;i=r.length){var t=n.next();if(t.done)return t;r[i]=t.value}return w(e,i,r[i++])})};var Cn;e($,T),$.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},$.prototype.get=function(e,t){return this.has(e)?this._value:t},$.prototype.includes=function(e){return X(this._value,e)},$.prototype.slice=function(e,t){var n=this.size;return g(e,t,n)?this:new $(this._value,_(t,n)-y(e,n))},$.prototype.reverse=function(){return this},$.prototype.indexOf=function(e){return X(this._value,e)?0:-1},$.prototype.lastIndexOf=function(e){return X(this._value,e)?this.size:-1},$.prototype.__iterate=function(e,t){for(var n=0;n=0&&t=0&&nn?k():w(e,o++,a)})},Q.prototype.equals=function(e){return e instanceof Q?this._start===e._start&&this._end===e._end&&this._step===e._step:Y(this,e)};var Dn;e(ee,t),e(te,ee),e(ne,ee),e(re,ee),ee.Keyed=te,ee.Indexed=ne,ee.Set=re;var Mn,On="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(e,t){e|=0,t|=0;var n=65535&e,r=65535&t;return n*r+((e>>>16)*r+n*(t>>>16)<<16>>>0)|0},Tn=Object.isExtensible,Pn=function(){try{return Object.defineProperty({},"@",{}),!0}catch(e){return!1}}(),In="function"==typeof WeakMap;In&&(Mn=new WeakMap);var jn=0,Nn="__immutablehash__";"function"==typeof Symbol&&(Nn=Symbol(Nn));var Rn=16,Fn=255,Bn=0,Ln={};e(pe,te),pe.of=function(){var e=un.call(arguments,0);return we().withMutations(function(t){for(var n=0;n=e.length)throw new Error("Missing value for key: "+e[n]);t.set(e[n],e[n+1])}})},pe.prototype.toString=function(){return this.__toString("Map {","}")},pe.prototype.get=function(e,t){return this._root?this._root.get(0,void 0,e,t):t},pe.prototype.set=function(e,t){return ke(this,e,t)},pe.prototype.setIn=function(e,t){return this.updateIn(e,vn,function(){return t})},pe.prototype.remove=function(e){return ke(this,e,vn)},pe.prototype.deleteIn=function(e){return this.updateIn(e,function(){return vn})},pe.prototype.update=function(e,t,n){return 1===arguments.length?e(this):this.updateIn([e],t,n)},pe.prototype.updateIn=function(e,t,n){n||(n=t,t=void 0);var r=je(this,Tt(e),t,n);return r===vn?void 0:r},pe.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):we()},pe.prototype.merge=function(){return Oe(this,void 0,arguments)},pe.prototype.mergeWith=function(e){return Oe(this,e,un.call(arguments,1))},pe.prototype.mergeIn=function(e){var t=un.call(arguments,1);return this.updateIn(e,we(),function(e){return"function"==typeof e.merge?e.merge.apply(e,t):t[t.length-1]})},pe.prototype.mergeDeep=function(){return Oe(this,Te,arguments)},pe.prototype.mergeDeepWith=function(e){var t=un.call(arguments,1);return Oe(this,Pe(e),t)},pe.prototype.mergeDeepIn=function(e){var t=un.call(arguments,1);return this.updateIn(e,we(),function(e){return"function"==typeof e.mergeDeep?e.mergeDeep.apply(e,t):t[t.length-1]})},pe.prototype.sort=function(e){return Ze(bt(this,e))},pe.prototype.sortBy=function(e,t){return Ze(bt(this,t,e))},pe.prototype.withMutations=function(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this},pe.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new f)},pe.prototype.asImmutable=function(){return this.__ensureOwner()},pe.prototype.wasAltered=function(){return this.__altered},pe.prototype.__iterator=function(e,t){return new ye(this,e,t)},pe.prototype.__iterate=function(e,t){var n=this,r=0;return this._root&&this._root.iterate(function(t){return r++,e(t[1],t[0],n)},t),r},pe.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?xe(this.size,this._root,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},pe.isMap=fe;var zn="@@__IMMUTABLE_MAP__@@",qn=pe.prototype;qn[zn]=!0,qn.delete=qn.remove,qn.removeIn=qn.deleteIn,he.prototype.get=function(e,t,n,r){for(var i=this.entries,o=0,a=i.length;o=Wn)return Ae(e,u,r,i);var d=e&&e===this.ownerID,m=d?u:h(u);return f?s?c===l-1?m.pop():m[c]=m.pop():m[c]=[r,i]:m.push([r,i]),d?(this.entries=m,this):new he(e,m)}},de.prototype.get=function(e,t,n,r){void 0===t&&(t=oe(n));var i=1<<((0===e?t:t>>>e)&mn),o=this.bitmap;return 0==(o&i)?r:this.nodes[Ne(o&i-1)].get(e+hn,t,n,r)},de.prototype.update=function(e,t,n,r,i,o,a){void 0===n&&(n=oe(r));var s=(0===t?n:n>>>t)&mn,u=1<=Kn)return Me(e,f,c,s,d);if(l&&!d&&2===f.length&&Se(f[1^p]))return f[1^p];if(l&&d&&1===f.length&&Se(d))return d;var m=e&&e===this.ownerID,v=l?d?c:c^u:c|u,g=l?d?Re(f,p,d,m):Be(f,p,m):Fe(f,p,d,m);return m?(this.bitmap=v,this.nodes=g,this):new de(e,v,g)},me.prototype.get=function(e,t,n,r){void 0===t&&(t=oe(n));var i=(0===e?t:t>>>e)&mn,o=this.nodes[i];return o?o.get(e+hn,t,n,r):r},me.prototype.update=function(e,t,n,r,i,o,a){void 0===n&&(n=oe(r));var s=(0===t?n:n>>>t)&mn,u=i===vn,c=this.nodes,l=c[s];if(u&&!l)return this;var p=Ee(l,e,t+hn,n,r,i,o,a);if(p===l)return this;var f=this.count;if(l){if(!p&&--f=0&&e>>t&mn;if(r>=this.array.length)return new qe([],e);var i,o=0===r;if(t>0){var a=this.array[r];if((i=a&&a.removeBefore(e,t-hn,n))===a&&o)return this}if(o&&!i)return this;var s=Ge(this,e);if(!o)for(var u=0;u>>t&mn;if(r>=this.array.length)return this;var i;if(t>0){var o=this.array[r];if((i=o&&o.removeAfter(e,t-hn,n))===o&&r===this.array.length-1)return this}var a=Ge(this,e);return a.array.splice(r+1),i&&(a.array[r]=i),a};var Jn,Xn={};e(Ze,pe),Ze.of=function(){return this(arguments)},Ze.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Ze.prototype.get=function(e,t){var n=this._map.get(e);return void 0!==n?this._list.get(n)[1]:t},Ze.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):tt()},Ze.prototype.set=function(e,t){return nt(this,e,t)},Ze.prototype.remove=function(e){return nt(this,e,vn)},Ze.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Ze.prototype.__iterate=function(e,t){var n=this;return this._list.__iterate(function(t){return t&&e(t[1],t[0],n)},t)},Ze.prototype.__iterator=function(e,t){return this._list.fromEntrySeq().__iterator(e,t)},Ze.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._map.__ensureOwner(e),n=this._list.__ensureOwner(e);return e?et(t,n,e,this.__hash):(this.__ownerID=e,this._map=t,this._list=n,this)},Ze.isOrderedMap=Qe,Ze.prototype[fn]=!0,Ze.prototype.delete=Ze.prototype.remove;var Yn;e(rt,O),rt.prototype.get=function(e,t){return this._iter.get(e,t)},rt.prototype.has=function(e){return this._iter.has(e)},rt.prototype.valueSeq=function(){return this._iter.valueSeq()},rt.prototype.reverse=function(){var e=this,t=ct(this,!0);return this._useKeys||(t.valueSeq=function(){return e._iter.toSeq().reverse()}),t},rt.prototype.map=function(e,t){var n=this,r=ut(this,e,t);return this._useKeys||(r.valueSeq=function(){return n._iter.toSeq().map(e,t)}),r},rt.prototype.__iterate=function(e,t){var n,r=this;return this._iter.__iterate(this._useKeys?function(t,n){return e(t,n,r)}:(n=t?Ct(this):0,function(i){return e(i,t?--n:n++,r)}),t)},rt.prototype.__iterator=function(e,t){if(this._useKeys)return this._iter.__iterator(e,t);var n=this._iter.__iterator(bn,t),r=t?Ct(this):0;return new x(function(){var i=n.next();return i.done?i:w(e,t?--r:r++,i.value,i)})},rt.prototype[fn]=!0,e(it,T),it.prototype.includes=function(e){return this._iter.includes(e)},it.prototype.__iterate=function(e,t){var n=this,r=0;return this._iter.__iterate(function(t){return e(t,r++,n)},t)},it.prototype.__iterator=function(e,t){var n=this._iter.__iterator(bn,t),r=0;return new x(function(){var t=n.next();return t.done?t:w(e,r++,t.value,t)})},e(ot,P),ot.prototype.has=function(e){return this._iter.includes(e)},ot.prototype.__iterate=function(e,t){var n=this;return this._iter.__iterate(function(t){return e(t,t,n)},t)},ot.prototype.__iterator=function(e,t){var n=this._iter.__iterator(bn,t);return new x(function(){var t=n.next();return t.done?t:w(e,t.value,t.value,t)})},e(at,O),at.prototype.entrySeq=function(){return this._iter.toSeq()},at.prototype.__iterate=function(e,t){var n=this;return this._iter.__iterate(function(t){if(t){St(t);var r=o(t);return e(r?t.get(1):t[1],r?t.get(0):t[0],n)}},t)},at.prototype.__iterator=function(e,t){var n=this._iter.__iterator(bn,t);return new x(function(){for(;;){var t=n.next();if(t.done)return t;var r=t.value;if(r){St(r);var i=o(r);return w(e,i?r.get(0):r[0],i?r.get(1):r[1],t)}}})},it.prototype.cacheResult=rt.prototype.cacheResult=ot.prototype.cacheResult=at.prototype.cacheResult=Mt,e(Pt,te),Pt.prototype.toString=function(){return this.__toString(jt(this)+" {","}")},Pt.prototype.has=function(e){return this._defaultValues.hasOwnProperty(e)},Pt.prototype.get=function(e,t){if(!this.has(e))return t;var n=this._defaultValues[e];return this._map?this._map.get(e,n):n},Pt.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var e=this.constructor;return e._empty||(e._empty=It(this,we()))},Pt.prototype.set=function(e,t){if(!this.has(e))throw new Error('Cannot set unknown key "'+e+'" on '+jt(this));if(this._map&&!this._map.has(e)){if(t===this._defaultValues[e])return this}var n=this._map&&this._map.set(e,t);return this.__ownerID||n===this._map?this:It(this,n)},Pt.prototype.remove=function(e){if(!this.has(e))return this;var t=this._map&&this._map.remove(e);return this.__ownerID||t===this._map?this:It(this,t)},Pt.prototype.wasAltered=function(){return this._map.wasAltered()},Pt.prototype.__iterator=function(e,t){var r=this;return n(this._defaultValues).map(function(e,t){return r.get(t)}).__iterator(e,t)},Pt.prototype.__iterate=function(e,t){var r=this;return n(this._defaultValues).map(function(e,t){return r.get(t)}).__iterate(e,t)},Pt.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._map&&this._map.__ensureOwner(e);return e?It(this,t,e):(this.__ownerID=e,this._map=t,this)};var $n=Pt.prototype;$n.delete=$n.remove,$n.deleteIn=$n.removeIn=qn.removeIn,$n.merge=qn.merge,$n.mergeWith=qn.mergeWith,$n.mergeIn=qn.mergeIn,$n.mergeDeep=qn.mergeDeep,$n.mergeDeepWith=qn.mergeDeepWith,$n.mergeDeepIn=qn.mergeDeepIn,$n.setIn=qn.setIn,$n.update=qn.update,$n.updateIn=qn.updateIn,$n.withMutations=qn.withMutations,$n.asMutable=qn.asMutable,$n.asImmutable=qn.asImmutable,e(Ft,re),Ft.of=function(){return this(arguments)},Ft.fromKeys=function(e){return this(n(e).keySeq())},Ft.prototype.toString=function(){return this.__toString("Set {","}")},Ft.prototype.has=function(e){return this._map.has(e)},Ft.prototype.add=function(e){return Lt(this,this._map.set(e,!0))},Ft.prototype.remove=function(e){return Lt(this,this._map.remove(e))},Ft.prototype.clear=function(){return Lt(this,this._map.clear())},Ft.prototype.union=function(){var e=un.call(arguments,0);return e=e.filter(function(e){return 0!==e.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(t){for(var n=0;n=0;n--)t={value:arguments[n],next:t};return this.__ownerID?(this.size=e,this._head=t,this.__hash=void 0,this.__altered=!0,this):Jt(e,t)},Vt.prototype.pushAll=function(e){if(e=r(e),0===e.size)return this;le(e.size);var t=this.size,n=this._head;return e.reverse().forEach(function(e){t++,n={value:e,next:n}}),this.__ownerID?(this.size=t,this._head=n,this.__hash=void 0,this.__altered=!0,this):Jt(t,n)},Vt.prototype.pop=function(){return this.slice(1)},Vt.prototype.unshift=function(){return this.push.apply(this,arguments)},Vt.prototype.unshiftAll=function(e){return this.pushAll(e)},Vt.prototype.shift=function(){return this.pop.apply(this,arguments)},Vt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Xt()},Vt.prototype.slice=function(e,t){if(g(e,t,this.size))return this;var n=y(e,this.size);if(_(t,this.size)!==this.size)return ne.prototype.slice.call(this,e,t);for(var r=this.size-n,i=this._head;n--;)i=i.next;return this.__ownerID?(this.size=r,this._head=i,this.__hash=void 0,this.__altered=!0,this):Jt(r,i)},Vt.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Jt(this.size,this._head,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},Vt.prototype.__iterate=function(e,t){if(t)return this.reverse().__iterate(e);for(var n=0,r=this._head;r&&!1!==e(r.value,n++,this);)r=r.next;return n},Vt.prototype.__iterator=function(e,t){if(t)return this.reverse().__iterator(e);var n=0,r=this._head;return new x(function(){if(r){var t=r.value;return r=r.next,w(e,n++,t)}return k()})},Vt.isStack=Gt;var rr="@@__IMMUTABLE_STACK__@@",ir=Vt.prototype;ir[rr]=!0,ir.withMutations=qn.withMutations,ir.asMutable=qn.asMutable,ir.asImmutable=qn.asImmutable,ir.wasAltered=qn.wasAltered;var or;t.Iterator=x,Yt(t,{toArray:function(){le(this.size);var e=new Array(this.size||0);return this.valueSeq().__iterate(function(t,n){e[n]=t}),e},toIndexedSeq:function(){return new it(this)},toJS:function(){return this.toSeq().map(function(e){return e&&"function"==typeof e.toJS?e.toJS():e}).__toJS()},toJSON:function(){return this.toSeq().map(function(e){return e&&"function"==typeof e.toJSON?e.toJSON():e}).__toJS()},toKeyedSeq:function(){return new rt(this,!0)},toMap:function(){return pe(this.toKeyedSeq())},toObject:function(){le(this.size);var e={};return this.__iterate(function(t,n){e[n]=t}),e},toOrderedMap:function(){return Ze(this.toKeyedSeq())},toOrderedSet:function(){return Ut(a(this)?this.valueSeq():this)},toSet:function(){return Ft(a(this)?this.valueSeq():this)},toSetSeq:function(){return new ot(this)},toSeq:function(){return s(this)?this.toIndexedSeq():a(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Vt(a(this)?this.valueSeq():this)},toList:function(){return Le(a(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(e,t){return 0===this.size?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){return Et(this,vt(this,un.call(arguments,0)))},includes:function(e){return this.some(function(t){return X(t,e)})},entries:function(){return this.__iterator(xn)},every:function(e,t){le(this.size);var n=!0;return this.__iterate(function(r,i,o){if(!e.call(t,r,i,o))return n=!1,!1}),n},filter:function(e,t){return Et(this,lt(this,e,t,!0))},find:function(e,t,n){var r=this.findEntry(e,t);return r?r[1]:n},forEach:function(e,t){return le(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){le(this.size),e=void 0!==e?""+e:",";var t="",n=!0;return this.__iterate(function(r){n?n=!1:t+=e,t+=null!==r&&void 0!==r?r.toString():""}),t},keys:function(){return this.__iterator(_n)},map:function(e,t){return Et(this,ut(this,e,t))},reduce:function(e,t,n){le(this.size);var r,i;return arguments.length<2?i=!0:r=t,this.__iterate(function(t,o,a){i?(i=!1,r=t):r=e.call(n,r,t,o,a)}),r},reduceRight:function(e,t,n){var r=this.toKeyedSeq().reverse();return r.reduce.apply(r,arguments)},reverse:function(){return Et(this,ct(this,!0))},slice:function(e,t){return Et(this,ht(this,e,t,!0))},some:function(e,t){return!this.every(Qt(e),t)},sort:function(e){return Et(this,bt(this,e))},values:function(){return this.__iterator(bn)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(e,t){return d(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return pt(this,e,t)},equals:function(e){return Y(this,e)},entrySeq:function(){var e=this;if(e._cache)return new I(e._cache);var t=e.toSeq().map(Zt).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(Qt(e),t)},findEntry:function(e,t,n){var r=n;return this.__iterate(function(n,i,o){if(e.call(t,n,i,o))return r=[i,n],!1}),r},findKey:function(e,t){var n=this.findEntry(e,t);return n&&n[0]},findLast:function(e,t,n){return this.toKeyedSeq().reverse().find(e,t,n)},findLastEntry:function(e,t,n){return this.toKeyedSeq().reverse().findEntry(e,t,n)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(){return this.find(v)},flatMap:function(e,t){return Et(this,yt(this,e,t))},flatten:function(e){return Et(this,gt(this,e,!0))},fromEntrySeq:function(){return new at(this)},get:function(e,t){return this.find(function(t,n){return X(n,e)},void 0,t)},getIn:function(e,t){for(var n,r=this,i=Tt(e);!(n=i.next()).done;){var o=n.value;if((r=r&&r.get?r.get(o,vn):vn)===vn)return t}return r},groupBy:function(e,t){return ft(this,e,t)},has:function(e){return this.get(e,vn)!==vn},hasIn:function(e){return this.getIn(e,vn)!==vn},isSubset:function(e){return e="function"==typeof e.includes?e:t(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e="function"==typeof e.isSubset?e:t(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return X(t,e)})},keySeq:function(){return this.toSeq().map($t).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return xt(this,e)},maxBy:function(e,t){return xt(this,t,e)},min:function(e){return xt(this,e?en(e):rn)},minBy:function(e,t){return xt(this,t?en(t):rn,e)},rest:function(){return this.slice(1)},skip:function(e){return this.slice(Math.max(0,e))},skipLast:function(e){return Et(this,this.toSeq().reverse().skip(e).reverse())},skipWhile:function(e,t){return Et(this,mt(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(Qt(e),t)},sortBy:function(e,t){return Et(this,bt(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return Et(this,this.toSeq().reverse().take(e).reverse())},takeWhile:function(e,t){return Et(this,dt(this,e,t))},takeUntil:function(e,t){return this.takeWhile(Qt(e),t)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=on(this))}});var ar=t.prototype;ar[cn]=!0,ar[En]=ar.values,ar.__toJS=ar.toArray,ar.__toStringMapper=tn,ar.inspect=ar.toSource=function(){return this.toString()},ar.chain=ar.flatMap,ar.contains=ar.includes,Yt(n,{flip:function(){return Et(this,st(this))},mapEntries:function(e,t){var n=this,r=0;return Et(this,this.toSeq().map(function(i,o){return e.call(t,[o,i],r++,n)}).fromEntrySeq())},mapKeys:function(e,t){var n=this;return Et(this,this.toSeq().flip().map(function(r,i){return e.call(t,r,i,n)}).flip())}});var sr=n.prototype;return sr[ln]=!0,sr[En]=ar.entries,sr.__toJS=ar.toObject,sr.__toStringMapper=function(e,t){return JSON.stringify(t)+": "+tn(e)},Yt(r,{toKeyedSeq:function(){return new rt(this,!1)},filter:function(e,t){return Et(this,lt(this,e,t,!1))},findIndex:function(e,t){var n=this.findEntry(e,t);return n?n[0]:-1},indexOf:function(e){var t=this.keyOf(e);return void 0===t?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return void 0===t?-1:t},reverse:function(){return Et(this,ct(this,!1))},slice:function(e,t){return Et(this,ht(this,e,t,!1))},splice:function(e,t){var n=arguments.length;if(t=Math.max(0|t,0),0===n||2===n&&!t)return this;e=y(e,e<0?this.count():this.size);var r=this.slice(0,e);return Et(this,1===n?r:r.concat(h(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var n=this.findLastEntry(e,t);return n?n[0]:-1},first:function(){return this.get(0)},flatten:function(e){return Et(this,gt(this,e,!1))},get:function(e,t){return e=m(this,e),e<0||this.size===1/0||void 0!==this.size&&e>this.size?t:this.find(function(t,n){return n===e},void 0,t)},has:function(e){return(e=m(this,e))>=0&&(void 0!==this.size?this.size===1/0||e)(<)(\/*)/g,f=/[ ]*(.*)[ ]+\n/g,t=/(<.+>)(.+\n)/g,e=e.replace(/\r\n/g,"\n").replace(l,"$1\n$2$3").replace(f,"$1\n").replace(t,"$1\n$2"),r="",u=e.split("\n"),i=0,a="other",p={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0},n=function(e){var t,n,o,s,u,c;u={single:Boolean(e.match(/<.+\/>/)),closing:Boolean(e.match(/<\/.+>/)),opening:Boolean(e.match(/<[^!?].*>/))},s=function(){var e;e=[];for(n in u)(c=u[n])&&e.push(n);return e}()[0],s=void 0===s?"other":s,t=a+"->"+s,a=s,o="",i+=p[t],o=function(){var e,t,n;for(n=[],e=0,t=i;0<=t?et;0<=t?++e:--e)n.push(" ");return n}().join(""),"opening->closing"===t?r=r.substr(0,r.length-1)+e+"\n":r+=o+e+"\n"},o=0,s=u.length;o5e3)return e.textContent;return function(e){for(var n,r,i,o,a,s=e.textContent,u=0,c=s[0],l=1,p=e.innerHTML="",f=0;r=n,n=f<7&&"\\"==n?1:l;){if(l=c,c=s[++u],o=p.length>1,!l||f>8&&"\n"==l||[/\S/.test(l),1,1,!/[$\w]/.test(l),("/"==n||"\n"==n)&&o,'"'==n&&o,"'"==n&&o,s[u-4]+r+n=="--\x3e",r+n=="*/"][f])for(p&&(e.appendChild(a=t.createElement("span")).setAttribute("style",["color: #555; font-weight: bold;","","","color: #555;",""][f?f<3?2:f>6?4:f>3?3:+/^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)$/.test(p):0]),a.appendChild(t.createTextNode(p))),i=f&&f<7?f:i,p="",f=11;![1,/[\/{}[(\-+*=<>:;|\\.,?!&@~]/.test(l),/[\])]/.test(l),/[$\w]/.test(l),"/"==l&&i<2&&"<"!=n,'"'==l,"'"==l,l+c+s[u+1]+s[u+2]=="\x3c!--",l+c=="/*",l+c=="//","#"==l][--f];);p+=l}}(e)}function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:R.default.Map();if(!R.default.Map.isMap(e)||!e.size)return R.default.List();if(Array.isArray(t)||(t=[t]),t.length<1)return e.merge(n);var r=R.default.List(),i=t[0],o=!0,a=!1,s=void 0;try{for(var u,c=(0,D.default)(e.entries());!(o=(u=c.next()).done);o=!0){var l=u.value,p=(0,C.default)(l,2),f=p[0],h=p[1],d=b(h,t.slice(1),n.set(i,f));r=R.default.List.isList(d)?r.concat(d):r.push(d)}}catch(e){a=!0,s=e}finally{try{!o&&c.return&&c.return()}finally{if(a)throw s}}return r}function x(e){return(0,z.default)((0,B.default)(e))}function w(e){return x(e.replace(/\.[^.\/]*$/,""))}Object.defineProperty(t,"__esModule",{value:!0}),t.shallowEqualKeys=t.buildFormData=t.sorters=t.btoa=t.parseSearch=t.getSampleSchema=t.validateParam=t.validateString=t.validateBoolean=t.validateFile=t.validateInteger=t.validateNumber=t.propChecker=t.errorLog=t.memoize=t.isImmutable=void 0;var k=n(41),E=r(k),S=n(19),C=r(S),A=n(90),D=r(A),M=n(31),O=r(M),T=n(42),P=r(T),I=n(52),j=r(I);t.objectify=i,t.arrayify=o,t.fromJSOrdered=a,t.bindToState=s,t.normalizeArray=u,t.isFn=c,t.isObject=l,t.isFunc=p,t.isArray=f,t.objMap=h,t.objReduce=d,t.systemThunkMiddleware=m,t.defaultStatusCode=v,t.getList=g,t.formatXml=y,t.highlight=_,t.mapToList=b,t.pascalCase=x,t.pascalCaseFilename=w;var N=n(10),R=r(N),F=n(866),B=r(F),L=n(395),z=r(L),q=n(393),U=r(q),W=n(387),K=r(W),H=n(881),V=r(H),G=n(110),J=r(G),X=n(163),Y=n(51),$=r(Y),Z="default",Q=t.isImmutable=function(e){return R.default.Iterable.isIterable(e)},ee=(t.memoize=U.default,t.errorLog=function(e){return function(){return function(t){return function(n){try{t(n)}catch(t){e().errActions.newThrownErr(t,n)}}}}},t.propChecker=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return(0,j.default)(e).length!==(0,j.default)(t).length||((0,V.default)(e,function(e,n){if(r.includes(n))return!1;var i=t[n];return R.default.Iterable.isIterable(e)?!R.default.is(e,i):("object"!==(void 0===e?"undefined":(0,P.default)(e))||"object"!==(void 0===i?"undefined":(0,P.default)(i)))&&e!==i})||n.some(function(n){return!(0,J.default)(e[n],t[n])}))},t.validateNumber=function(e){if(!/^-?\d+(\.?\d+)?$/.test(e))return"Value must be a number"}),te=t.validateInteger=function(e){if(!/^-?\d+$/.test(e))return"Value must be an integer"},ne=t.validateFile=function(e){if(e&&!(e instanceof $.default.File))return"Value must be a file"},re=t.validateBoolean=function(e){if("true"!==e&&"false"!==e&&!0!==e&&!1!==e)return"Value must be a boolean"},ie=t.validateString=function(e){if(e&&"string"!=typeof e)return"Value must be a string"};t.validateParam=function(e,t){var n=[],r=t&&"body"===e.get("in")?e.get("value_xml"):e.get("value"),i=e.get("required"),o=e.get("type");if(o&&(i||r)){var a="string"===o&&r&&!ie(r),s="array"===o&&Array.isArray(r)&&r.length,u="array"===o&&R.default.List.isList(r)&&r.count(),c="file"===o&&r instanceof $.default.File,l="boolean"===o&&!re(r),p="number"===o&&!ee(r),f="integer"===o&&!te(r);if(i&&!(a||s||u||c||l||p||f))return n.push("Required field is not provided"),n;if("string"===o){var h=ie(r);if(!h)return n;n.push(h)}else if("boolean"===o){var d=re(r);if(!d)return n;n.push(d)}else if("number"===o){var m=ee(r);if(!m)return n;n.push(m)}else if("integer"===o){var v=te(r);if(!v)return n;n.push(v)}else if("array"===o){var g=void 0;if(!r.count())return n;g=e.getIn(["items","type"]),r.forEach(function(e,t){var r=void 0;"number"===g?r=ee(e):"integer"===g?r=te(e):"string"===g&&(r=ie(e)),r&&n.push({index:t,error:r})})}else if("file"===o){var y=ne(r);if(!y)return n;n.push(y)}}return n},t.getSampleSchema=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(/xml/.test(t)){if(!e.xml||!e.xml.name){if(e.xml=e.xml||{},!e.$$ref)return e.type||e.items||e.properties||e.additionalProperties?'\n\x3c!-- XML example cannot be generated --\x3e':null;var r=e.$$ref.match(/\S*\/(\S+)$/);e.xml.name=r[1]}return(0,X.memoizedCreateXMLExample)(e,n)}return(0,E.default)((0,X.memoizedSampleFromSchema)(e,n),null,2)},t.parseSearch=function(){var e={},t=window.location.search;if(""!=t){var n=t.substr(1).split("&");for(var r in n)r=n[r].split("="),e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e},t.btoa=function(t){var n=void 0;return n=t instanceof e?t:new e(t.toString(),"utf-8"),n.toString("base64")},t.sorters={operationsSorter:{alpha:function(e,t){return e.get("path").localeCompare(t.get("path"))},method:function(e,t){return e.get("method").localeCompare(t.get("method"))}},tagsSorter:{alpha:function(e,t){return e.localeCompare(t)}}},t.buildFormData=function(e){var t=[];for(var n in e){var r=e[n];void 0!==r&&""!==r&&t.push([n,"=",encodeURIComponent(r).replace(/%20/g,"+")].join(""))}return t.join("&")},t.shallowEqualKeys=function(e,t,n){return!!(0,K.default)(n,function(n){return(0,J.default)(e[n],t[n])})}}).call(t,n(44).Buffer)},function(e,t,n){"use strict";function r(e,t){return 1===e.nodeType&&e.getAttribute(d)===String(t)||8===e.nodeType&&e.nodeValue===" react-text: "+t+" "||8===e.nodeType&&e.nodeValue===" react-empty: "+t+" "}function i(e){for(var t;t=e._renderedComponent;)e=t;return e}function o(e,t){var n=i(e);n._hostNode=t,t[v]=n}function a(e){var t=e._hostNode;t&&(delete t[v],e._hostNode=null)}function s(e,t){if(!(e._flags&m.hasCachedChildNodes)){var n=e._renderedChildren,a=t.firstChild;e:for(var s in n)if(n.hasOwnProperty(s)){var u=n[s],c=i(u)._domID;if(0!==c){for(;null!==a;a=a.nextSibling)if(r(a,c)){o(u,a);continue e}p("32",c)}}e._flags|=m.hasCachedChildNodes}}function u(e){if(e[v])return e[v];for(var t=[];!e[v];){if(t.push(e),!e.parentNode)return null;e=e.parentNode}for(var n,r;e&&(r=e[v]);e=t.pop())n=r,t.length&&s(r,e);return n}function c(e){var t=u(e);return null!=t&&t._hostNode===e?t:null}function l(e){if(void 0===e._hostNode&&p("33"),e._hostNode)return e._hostNode;for(var t=[];!e._hostNode;)t.push(e),e._hostParent||p("34"),e=e._hostParent;for(;t.length;e=t.pop())s(e,e._hostNode);return e._hostNode}var p=n(9),f=n(83),h=n(406),d=(n(7),f.ID_ATTRIBUTE_NAME),m=h,v="__reactInternalInstance$"+Math.random().toString(36).slice(2),g={getClosestInstanceFromNode:u,getInstanceFromNode:c,getNodeFromInstance:l,precacheChildNodes:s,precacheNode:o,uncacheNode:a};e.exports=g},function(e,t){var n=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(e,t,n){"use strict";function r(e){var t={};return null!==e&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function i(e,t){if(t=t||{},Object.keys(t).forEach(function(t){if(-1===a.indexOf(t))throw new o('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=r(t.styleAliases||null),-1===s.indexOf(this.kind))throw new o('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var o=n(105),a=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],s=["scalar","sequence","mapping"];e.exports=i},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){var r=n(180)("wks"),i=n(128),o=n(23).Symbol,a="function"==typeof o;(e.exports=function(e){return r[e]||(r[e]=a&&o[e]||(a?o:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(31),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=i.default||function(e){for(var t=1;t=55296&&e<=57343)&&(!(e>=64976&&e<=65007)&&(65535!=(65535&e)&&65534!=(65535&e)&&(!(e>=0&&e<=8)&&(11!==e&&(!(e>=14&&e<=31)&&(!(e>=127&&e<=159)&&!(e>1114111)))))))}function c(e){if(e>65535){e-=65536;var t=55296+(e>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function l(e,t){var n=0;return o(y,t)?y[t]:35===t.charCodeAt(0)&&g.test(t)&&(n="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10),u(n))?c(n):e}function p(e){return e.indexOf("&")<0?e:e.replace(v,l)}function f(e){return x[e]}function h(e){return _.test(e)?e.replace(b,f):e}var d=Object.prototype.hasOwnProperty,m=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g,v=/&([a-z#][a-z0-9]{1,31});/gi,g=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i,y=n(442),_=/[&<>"]/,b=/[&<>"]/g,x={"&":"&","<":"<",">":">",'"':"""};t.assign=a,t.isString=i,t.has=o,t.unescapeMd=s,t.isValidEntityCode=u,t.fromCodePoint=c,t.replaceEntities=p,t.escapeHtml=h},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t,n){var r=n(616)("wks"),i=n(339),o=n(26).Symbol;e.exports=function(e){return r[e]||(r[e]=o&&o[e]||(o||i)("Symbol."+e))}},function(e,t,n){"use strict";function r(e){return function(){return e}}var i=function(){};i.thatReturns=r,i.thatReturnsFalse=r(!1),i.thatReturnsTrue=r(!0),i.thatReturnsNull=r(null),i.thatReturnsThis=function(){return this},i.thatReturnsArgument=function(e){return e},e.exports=i},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function o(e){if(p===clearTimeout)return clearTimeout(e);if((p===r||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(e);try{return p(e)}catch(t){try{return p.call(null,e)}catch(t){return p.call(this,e)}}}function a(){m&&h&&(m=!1,h.length?d=h.concat(d):v=-1,d.length&&s())}function s(){if(!m){var e=i(a);m=!0;for(var t=d.length;t;){for(h=d,d=[];++v1)for(var n=1;n6?s-6:0),c=6;c5?c-5:0),p=5;p5?a-5:0),u=5;u key("+l[p]+")"].concat(s));if(h instanceof Error)return h}}return i(t)}function u(e){return a(e,"List",b.List.isList)}function c(e,t,n,r){function o(){for(var i=arguments.length,o=Array(i),u=0;u5?s-5:0),c=5;c5?c-5:0),p=5;p>",w={listOf:u,mapOf:l,orderedMapOf:p,setOf:f,orderedSetOf:h,stackOf:d,iterableOf:m,recordOf:v,shape:y,contains:y,mapContains:_,list:o("List",b.List.isList),map:o("Map",b.Map.isMap),orderedMap:o("OrderedMap",b.OrderedMap.isOrderedMap),set:o("Set",b.Set.isSet),orderedSet:o("OrderedSet",b.OrderedSet.isOrderedSet),stack:o("Stack",b.Stack.isStack),seq:o("Seq",b.Seq.isSeq),record:o("Record",function(e){return e instanceof b.Record}),iterable:o("Iterable",b.Iterable.isIterable)};e.exports=w},function(e,t){var n=Array.isArray;e.exports=n},function(e,t,n){e.exports={default:n(537),__esModule:!0}},function(e,t,n){var r=n(34);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){var r=n(23),i=n(14),o=n(59),a=n(54),s=function(e,t,n){var u,c,l,p=e&s.F,f=e&s.G,h=e&s.S,d=e&s.P,m=e&s.B,v=e&s.W,g=f?i:i[t]||(i[t]={}),y=g.prototype,_=f?r:h?r[t]:(r[t]||{}).prototype;f&&(n=t);for(u in n)(c=!p&&_&&void 0!==_[u])&&u in g||(l=c?_[u]:n[u],g[u]=f&&"function"!=typeof _[u]?n[u]:m&&c?o(l,r):v&&_[u]==l?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(l):d&&"function"==typeof l?o(Function.call,l):l,d&&((g.virtual||(g.virtual={}))[u]=l,e&s.R&&y&&!y[u]&&a(y,u,l)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var r=n(32),i=n(319),o=n(182),a=Object.defineProperty;t.f=n(43)?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){var r=n(377),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},function(e,t,n){"use strict";function r(){A.ReactReconcileTransaction&&x||l("123")}function i(){this.reinitializeTransaction(),this.dirtyComponentsLength=null,this.callbackQueue=f.getPooled(),this.reconcileTransaction=A.ReactReconcileTransaction.getPooled(!0)}function o(e,t,n,i,o,a){return r(),x.batchedUpdates(e,t,n,i,o,a)}function a(e,t){return e._mountOrder-t._mountOrder}function s(e){var t=e.dirtyComponentsLength;t!==g.length&&l("124",t,g.length),g.sort(a),y++;for(var n=0;n0&&(a=this.buffer[u-1],e.call(r,a)<0);)if(u--,this.pointer-u>n/2-1){o=" ... ",u+=5;break}for(c="",i=this.pointer;in/2-1){c=" ... ",i-=5;break}return""+new Array(t).join(" ")+o+this.buffer.slice(u,i)+c+"\n"+new Array(t+this.pointer-u+o.length).join(" ")+"^"},t.prototype.toString=function(){var e,t;return e=this.get_snippet(),t=" on line "+(this.line+1)+", column "+(this.column+1),e?t:t+":\n"+e},t}(),this.YAMLError=function(e){function n(e){this.message=e,n.__super__.constructor.call(this),this.stack=this.toString()+"\n"+(new Error).stack.split("\n").slice(1).join("\n")}return t(n,e),n.prototype.toString=function(){return this.message},n}(Error),this.MarkedYAMLError=function(e){function n(e,t,r,i,o){this.context=e,this.context_mark=t,this.problem=r,this.problem_mark=i,this.note=o,n.__super__.constructor.call(this)}return t(n,e),n.prototype.toString=function(){var e;return e=[],null!=this.context&&e.push(this.context),null==this.context_mark||null!=this.problem&&null!=this.problem_mark&&this.context_mark.line===this.problem_mark.line&&this.context_mark.column===this.problem_mark.column||e.push(this.context_mark.toString()),null!=this.problem&&e.push(this.problem),null!=this.problem_mark&&e.push(this.problem_mark.toString()),null!=this.note&&e.push(this.note),e.join("\n")},n}(this.YAMLError)}).call(this)},function(e,t,n){e.exports={default:n(536),__esModule:!0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=n(531),o=r(i),a=n(530),s=r(a),u="function"==typeof s.default&&"symbol"==typeof o.default?function(e){return typeof e}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":typeof e};t.default="function"==typeof s.default&&"symbol"===u(o.default)?function(e){return void 0===e?"undefined":u(e)}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":void 0===e?"undefined":u(e)}},function(e,t,n){e.exports=!n(60)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";(function(e){function r(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),o.alloc(+e)}function v(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(e).length;default:if(r)return K(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return D(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return A(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function y(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,i);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,s=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,n/=2}var c;if(i){var l=-1;for(c=n;cs&&(n=s-u),c=n;c>=0;c--){for(var p=!0,f=0;fi&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+s<=n){var u,c,l,p;switch(s){case 1:o<128&&(a=o);break;case 2:u=e[i+1],128==(192&u)&&(p=(31&o)<<6|63&u)>127&&(a=p);break;case 3:u=e[i+1],c=e[i+2],128==(192&u)&&128==(192&c)&&(p=(15&o)<<12|(63&u)<<6|63&c)>2047&&(p<55296||p>57343)&&(a=p);break;case 4:u=e[i+1],c=e[i+2],l=e[i+3],128==(192&u)&&128==(192&c)&&128==(192&l)&&(p=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&l)>65535&&p<1114112&&(a=p)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),i+=s}return M(r)}function M(e){var t=e.length;if(t<=Q)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var i="",o=t;on)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,n,r,i,a){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i>>8*(r?i:1-i)}function F(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}function B(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return i||B(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),$.write(e,t,n,r,23,4),n+4}function z(e,t,n,r,i){return i||B(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),$.write(e,t,n,r,52,8),n+8}function q(e){if(e=U(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function U(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function W(e){return e<16?"0"+e.toString(16):e.toString(16)}function K(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],a=0;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function H(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function G(e){return Y.toByteArray(q(e))}function J(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function X(e){return e!==e}/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var Y=n(583),$=n(696),Z=n(359);t.Buffer=o,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=r(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,n){return a(null,e,t,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,n){return u(null,e,t,n)},o.allocUnsafe=function(e){return c(null,e)},o.allocUnsafeSlow=function(e){return c(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,a=Math.min(n,r);i0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},o.prototype.compare=function(e,t,n,r,i){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var a=i-r,s=n-t,u=Math.min(a,s),c=this.slice(r,i),l=e.slice(t,n),p=0;pi)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return x(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return k(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)r+=this[e+--t]*i;return r},o.prototype.readUInt8=function(e,t){return t||j(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||j(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||j(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||j(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||j(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},o.prototype.readInt8=function(e,t){return t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||j(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||j(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||j(e,4,this.length),$.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||j(e,4,this.length),$.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||j(e,8,this.length),$.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||j(e,8,this.length),$.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){N(this,e,t,n,Math.pow(2,8*n)-1,0)}var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):F(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):F(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);N(this,e,t,n,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);N(this,e,t,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):F(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):F(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return z(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return z(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a=n?e:e.length+1===n?""+t+e:""+new Array(n-e.length+1).join(t)+e},this.to_hex=function(e){return"string"==typeof e&&(e=e.charCodeAt(0)),e.toString(16)}}).call(this)}).call(t,n(16))},function(e,t,n){"use strict";t.__esModule=!0;var r=n(316),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(e,t,n){return t in e?(0,i.default)(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t,n){var r=n(166);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){var r=n(174),i=n(170);e.exports=function(e){return r(i(e))}},function(e,t){var n=Object;e.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(e,t,n){"use strict";var r=n(657),i=Math.max;e.exports=function(e){return i(0,r(e))}},function(e,t,n){function r(e,t){var n=o(e,t);return i(n)?n:void 0}var i=n(781),o=n(821);e.exports=r},function(e,t,n){function r(e){return a(e)?i(e):o(e)}var i=n(366),o=n(783),a=n(111);e.exports=r},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=n(9),i=(n(7),function(e){var t=this;if(t.instancePool.length){var n=t.instancePool.pop();return t.call(n,e),n}return new t(e)}),o=function(e,t){var n=this;if(n.instancePool.length){var r=n.instancePool.pop();return n.call(r,e,t),r}return new n(e,t)},a=function(e,t,n){var r=this;if(r.instancePool.length){var i=r.instancePool.pop();return r.call(i,e,t,n),i}return new r(e,t,n)},s=function(e,t,n,r){var i=this;if(i.instancePool.length){var o=i.instancePool.pop();return i.call(o,e,t,n,r),o}return new i(e,t,n,r)},u=function(e){var t=this;e instanceof t||r("25"),e.destructor(),t.instancePool.length`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*/?>",u="]",c=new RegExp("^(?:<[A-Za-z][A-Za-z0-9-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*/?>|]|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|[<][?].*?[?][>]|]*>|)","i"),l=/[\\&]/,p="[!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]",f=new RegExp("\\\\"+p+"|"+a,"gi"),h=new RegExp('[&<>"]',"g"),d=new RegExp(a+'|[&<>"]',"gi"),m=function(e){return 92===e.charCodeAt(0)?e.charAt(1):o(e)},v=function(e){return l.test(e)?e.replace(f,m):e},g=function(e){try{return r(i(e))}catch(t){return e}},y=function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";default:return e}},_=function(e,t){return h.test(e)?t?e.replace(d,y):e.replace(h,y):e};e.exports={unescapeString:v,normalizeURI:g,escapeXml:_,reHtmlTag:c,OPENTAG:s,CLOSETAG:u,ENTITY:a,ESCAPABLE:p}},function(e,t,n){var r=n(62),i=n(337);e.exports=n(191)?function(e,t,n){return r.setDesc(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){"use strict";var r=n(344)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";function r(e){return void 0===e||null===e}function i(e){return"object"==typeof e&&null!==e}function o(e){return Array.isArray(e)?e:r(e)?[]:[e]}function a(e,t){var n,r,i,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n1){for(var d=Array(h),m=0;m1){for(var g=Array(v),y=0;y1?t-1:0),i=1;i2?n-2:0),o=2;o=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(570);for(var r=n(23),i=n(54),o=n(71),a=n(17)("toStringTag"),s=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var c=s[u],l=r[c],p=l&&l.prototype;p&&!p[a]&&i(p,a,c),o[c]=o.Array}},function(e,t,n){var r=n(130);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t){var n=e.exports={version:"1.2.6"};"number"==typeof __e&&(__e=n)},function(e,t,n){var r=n(189);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports={}},function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===v(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function a(e){return"number"==typeof e}function s(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function l(e){return"[object RegExp]"===v(e)}function p(e){return"object"==typeof e&&null!==e}function f(e){return"[object Date]"===v(e)}function h(e){return"[object Error]"===v(e)||e instanceof Error}function d(e){return"function"==typeof e}function m(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function v(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=r,t.isNull=i,t.isNullOrUndefined=o,t.isNumber=a,t.isString=s,t.isSymbol=u,t.isUndefined=c,t.isRegExp=l,t.isObject=p,t.isDate=f,t.isError=h,t.isFunction=d,t.isPrimitive=m,t.isBuffer=e.isBuffer}).call(t,n(44).Buffer)},function(e,t){e.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(e){return"tag"===e.type||"script"===e.type||"style"===e.type}}},function(e,t,n){"use strict";var r=n(76);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";var r={};e.exports=r},function(e,t,n){function r(t,n){return delete e.exports[t],e.exports[t]=n,n}var i=n(352),o=n(632);e.exports={Parser:i,Tokenizer:n(353),ElementType:n(101),DomHandler:o,get FeedHandler(){return r("FeedHandler",n(693))},get Stream(){return r("Stream",n(695))},get WritableStream(){return r("WritableStream",n(354))},get ProxyHandler(){return r("ProxyHandler",n(694))},get DomUtils(){return r("DomUtils",n(634))},get CollectingHandler(){return r("CollectingHandler",n(692))},DefaultHandler:o,get RssHandler(){return r("RssHandler",this.FeedHandler)},parseDOM:function(e,t){var n=new o(t);return new i(n,t).end(e),n.dom},parseFeed:function(t,n){var r=new e.exports.FeedHandler(n);return new i(r,n).end(t),r.dom},createDomStream:function(e,t,n){var r=new o(e,t,n);return new i(r,t)},EVENTS:{attribute:2,cdatastart:0,cdataend:0,text:1,processinginstruction:2,comment:1,commentend:0,closetag:1,opentag:2,opentagname:1,error:1,end:0}}},function(e,t,n){"use strict";function r(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.prototype.toString=function(e){var t=this.name+": ";return t+=this.reason||"(unknown reason)",!e&&this.mark&&(t+=" "+this.mark.toString()),t},e.exports=r},function(e,t,n){"use strict";var r=n(78);e.exports=new r({include:[n(361)],implicit:[n(744),n(737)],explicit:[n(729),n(739),n(740),n(742)]})},function(e,t,n){function r(e){return"function"==typeof e?e:null==e?a:"object"==typeof e?s(e)?o(e[0],e[1]):i(e):u(e)}var i=n(785),o=n(786),a=n(389),s=n(21),u=n(878);e.exports=r},function(e,t,n){function r(e,t,n,r){var a=!n;n||(n={});for(var s=-1,u=t.length;++s0&&void 0!==arguments[0]?arguments[0]:{};return{type:d,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.CLEAR=t.NEW_AUTH_ERR=t.NEW_SPEC_ERR=t.NEW_THROWN_ERR_BATCH=t.NEW_THROWN_ERR=void 0,t.newThrownErr=r,t.newThrownErrBatch=i,t.newSpecErr=o,t.newAuthErr=a,t.clear=s;var u=n(248),c=function(e){return e&&e.__esModule?e:{default:e}}(u),l=t.NEW_THROWN_ERR="err_new_thrown_err",p=t.NEW_THROWN_ERR_BATCH="err_new_thrown_err_batch",f=t.NEW_SPEC_ERR="err_new_spec_err",h=t.NEW_AUTH_ERR="err_new_auth_err",d=t.CLEAR="err_clear"},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(527),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0?i(r(e),9007199254740991):0}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var r=n(26),i=n(75),o=n(339)("src"),a=Function.toString,s=(""+a).split("toString");n(97).inspectSource=function(e){return a.call(e)},(e.exports=function(e,t,n,a){"function"==typeof n&&(n.hasOwnProperty(o)||i(n,o,e[t]?""+e[t]:s.join(String(t))),n.hasOwnProperty("name")||i(n,"name",t)),e===r?e[t]=n:(a||delete e[t],i(e,t,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[o]||a.call(this)})},function(e,t,n){"use strict";var r,i=n(345),o=n(348),a=n(661),s=n(666);r=e.exports=function(e,t){var n,r,a,u,c;return arguments.length<2||"string"!=typeof e?(u=t,t=e,e=null):u=arguments[2],null==e?(n=a=!0,r=!1):(n=s.call(e,"c"),r=s.call(e,"e"),a=s.call(e,"w")),c={value:t,configurable:n,enumerable:r,writable:a},u?i(o(u),c):c},r.gs=function(e,t,n){var r,u,c,l;return"string"!=typeof e?(c=n,n=t,t=e,e=null):c=arguments[3],null==t?t=void 0:a(t)?null==n?n=void 0:a(n)||(c=n,n=void 0):(c=t,t=n=void 0),null==e?(r=!0,u=!1):(r=s.call(e,"c"),u=s.call(e,"e")),l={get:t,set:n,configurable:r,enumerable:u},c?i(o(c),l):l}},function(e,t,n){"use strict";e.exports=n(658)("forEach")},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,s,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(n=this._events[e],a(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(o(n))for(s=Array.prototype.slice.call(arguments,1),c=n.slice(),i=c.length,u=0;u0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,a,s;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],a=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(s=a;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){i=s;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";function r(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!==e&&t!==t}function i(e,t){if(r(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var a=0;a]/;e.exports=i},function(e,t,n){"use strict";var r,i=n(20),o=n(224),a=/^[ \r\n\t\f]/,s=/<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/,u=n(232),c=u(function(e,t){if(e.namespaceURI!==o.svg||"innerHTML"in e)e.innerHTML=t;else{r=r||document.createElement("div"),r.innerHTML=""+t+"";for(var n=r.firstChild;n.firstChild;)e.appendChild(n.firstChild)}});if(i.canUseDOM){var l=document.createElement("div");l.innerHTML=" ",""===l.innerHTML&&(c=function(e,t){if(e.parentNode&&e.parentNode.replaceChild(e,e),a.test(t)||"<"===t[0]&&s.test(t)){e.innerHTML=String.fromCharCode(65279)+t;var n=e.firstChild;1===n.data.length?e.removeChild(n):n.deleteData(0,1)}else e.innerHTML=t}),l=null}e.exports=c},function(e,t,n){"use strict";e.exports=function(e,t){var n,r,i,o=-1,a=e.posMax,s=e.pos,u=e.isInLabel;if(e.isInLabel)return-1;if(e.labelUnmatchedScopes)return e.labelUnmatchedScopes--,-1;for(e.pos=t+1,e.isInLabel=!0,n=1;e.pos1&&void 0!==arguments[1])||arguments[1];return e=(0,s.normalizeArray)(e),{type:p,payload:{thing:e,shown:t}}}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e=(0,s.normalizeArray)(e),{type:l,payload:{thing:e,mode:t}}}Object.defineProperty(t,"__esModule",{value:!0}),t.SHOW=t.UPDATE_MODE=t.UPDATE_FILTER=t.UPDATE_LAYOUT=void 0,t.updateLayout=r,t.updateFilter=i,t.show=o,t.changeMode=a;var s=n(12),u=t.UPDATE_LAYOUT="layout_update_layout",c=t.UPDATE_FILTER="layout_update_filter",l=t.UPDATE_MODE="layout_update_mode",p=t.SHOW="layout_show"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=h(e,t);if(n)return(0,s.default)(n,{declaration:!0,indent:"\t"})}Object.defineProperty(t,"__esModule",{value:!0}),t.memoizedSampleFromSchema=t.memoizedCreateXMLExample=t.sampleXmlFromSchema=t.inferSchema=t.sampleFromSchema=void 0,t.createXMLExample=i;var o=n(12),a=n(1223),s=r(a),u=n(896),c=r(u),l={string:function(){return"string"},string_email:function(){return"user@example.com"},"string_date-time":function(){return(new Date).toISOString()},number:function(){return 0},number_float:function(){return 0},integer:function(){return 0},boolean:function(e){return"boolean"!=typeof e.default||e.default}},p=function(e){e=(0,o.objectify)(e);var t=e,n=t.type,r=t.format,i=l[n+"_"+r]||l[n];return(0,o.isFunc)(i)?i(e):"Unknown Type: "+e.type},f=t.sampleFromSchema=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,o.objectify)(t),i=r.type,a=r.example,s=r.properties,u=r.additionalProperties,c=r.items,l=n.includeReadOnly;if(void 0!==a)return a;if(!i)if(s)i="object";else{if(!c)return;i="array"}if("object"===i){var f=(0,o.objectify)(s),h={};for(var d in f)f[d].readOnly&&!l||(h[d]=e(f[d],{includeReadOnly:l}));if(!0===u)h.additionalProp1={};else if(u)for(var m=(0,o.objectify)(u),v=e(m,{includeReadOnly:l}),g=1;g<4;g++)h["additionalProp"+g]=v;return h}return"array"===i?[e(c,{includeReadOnly:l})]:t.enum?t.default?t.default:(0,o.normalizeArray)(t.enum)[0]:"file"!==i?p(t):void 0},h=(t.inferSchema=function(e){return e.schema&&(e=e.schema),e.properties&&(e.type="object"),e},t.sampleXmlFromSchema=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,o.objectify)(t),i=r.type,a=r.properties,s=r.additionalProperties,u=r.items,c=r.example,l=n.includeReadOnly,f=r.default,h={},d={},m=t.xml,v=m.name,g=m.prefix,y=m.namespace,_=r.enum,b=void 0,x=void 0;if(!i)if(a||s)i="object";else{if(!u)return;i="array"}if(v=v||"notagname",b=(g?g+":":"")+v,y){d[g?"xmlns:"+g:"xmlns"]=y}if("array"===i&&u){if(u.xml=u.xml||m||{},u.xml.name=u.xml.name||m.name,m.wrapped)return h[b]=[],Array.isArray(c)?c.forEach(function(t){u.example=t,h[b].push(e(u,n))}):Array.isArray(f)?f.forEach(function(t){u.default=t,h[b].push(e(u,n))}):h[b]=[e(u,n)],d&&h[b].push({_attr:d}),h;var w=[];return Array.isArray(c)?(c.forEach(function(t){u.example=t,w.push(e(u,n))}),w):Array.isArray(f)?(f.forEach(function(t){u.default=t,w.push(e(u,n))}),w):e(u,n)}if("object"===i){var k=(0,o.objectify)(a);h[b]=[],c=c||{};for(var E in k)if(!k[E].readOnly||l)if(k[E].xml=k[E].xml||{},k[E].xml.attribute){var S=Array.isArray(k[E].enum)&&k[E].enum[0],C=k[E].example,A=k[E].default;d[k[E].xml.name||E]=void 0!==C&&C||void 0!==c[E]&&c[E]||void 0!==A&&A||S||p(k[E])}else{k[E].xml.name=k[E].xml.name||E,k[E].example=void 0!==k[E].example?k[E].example:c[E];var D=e(k[E]);Array.isArray(D)?h[b]=h[b].concat(D):h[b].push(D)}return!0===s?h[b].push({additionalProp:"Anything can be here"}):s&&h[b].push({additionalProp:p(s)}),d&&h[b].push({_attr:d}),h}return x=void 0!==c?c:void 0!==f?f:Array.isArray(_)?_[0]:p(t),h[b]=d?[{_attr:d},x]:x,h});t.memoizedCreateXMLExample=(0,c.default)(i),t.memoizedSampleFromSchema=(0,c.default)(f)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e){return e instanceof Error?{type:O,error:!0,payload:e}:"string"==typeof e?{type:O,payload:e.replace(/\t/g," ")||""}:{type:O,payload:""}}function o(e){return{type:U,payload:e}}function a(e){return{type:T,payload:e}}function s(e){if(!e||"object"!==(void 0===e?"undefined":(0,k.default)(e)))throw new Error("updateJson must only accept a simple JSON object");return{type:P,payload:e}}function u(e,t,n,r){return{type:I,payload:{path:e,value:n,paramName:t,isXml:r}}}function c(e){return{type:j,payload:{pathMethod:e}}}function l(e){return{type:z,payload:{pathMethod:e}}}function p(e,t){return{type:q,payload:{path:e,value:t,key:"consumes_value"}}}function f(e,t){return{type:q,payload:{path:e,value:t,key:"produces_value"}}}function h(e,t){return{type:B,payload:{path:e,method:t}}}function d(e,t){return{type:L,payload:{path:e,method:t}}}function m(e,t,n){return{type:W,payload:{scheme:e,path:t,method:n}}}Object.defineProperty(t,"__esModule",{value:!0}),t.execute=t.executeRequest=t.logRequest=t.setRequest=t.setResponse=t.formatIntoYaml=t.resolveSpec=t.parseToJson=t.SET_SCHEME=t.UPDATE_RESOLVED=t.UPDATE_OPERATION_VALUE=t.ClEAR_VALIDATE_PARAMS=t.CLEAR_REQUEST=t.CLEAR_RESPONSE=t.LOG_REQUEST=t.SET_REQUEST=t.SET_RESPONSE=t.VALIDATE_PARAMS=t.UPDATE_PARAM=t.UPDATE_JSON=t.UPDATE_URL=t.UPDATE_SPEC=void 0;var v=n(18),g=r(v),y=n(122),_=r(y),b=n(31),x=r(b),w=n(42),k=r(w);t.updateSpec=i,t.updateResolved=o,t.updateUrl=a,t.updateJsonSpec=s,t.changeParam=u,t.validateParams=c,t.clearValidateParams=l,t.changeConsumesValue=p,t.changeProducesValue=f,t.clearResponse=h,t.clearRequest=d,t.setScheme=m;var E=n(360),S=r(E),C=n(1213),A=r(C),D=n(248),M=r(D),O=t.UPDATE_SPEC="spec_update_spec",T=t.UPDATE_URL="spec_update_url",P=t.UPDATE_JSON="spec_update_json",I=t.UPDATE_PARAM="spec_update_param",j=t.VALIDATE_PARAMS="spec_validate_param",N=t.SET_RESPONSE="spec_set_response",R=t.SET_REQUEST="spec_set_request",F=t.LOG_REQUEST="spec_log_request",B=t.CLEAR_RESPONSE="spec_clear_response",L=t.CLEAR_REQUEST="spec_clear_request",z=t.ClEAR_VALIDATE_PARAMS="spec_clear_validate_param",q=t.UPDATE_OPERATION_VALUE="spec_update_operation_value",U=t.UPDATE_RESOLVED="spec_update_resolved",W=t.SET_SCHEME="set_scheme",K=(t.parseToJson=function(e){return function(t){var n=t.specActions,r=t.specSelectors,i=t.errActions,o=r.specStr,a=null;try{e=e||o(),i.clear({source:"parser"}),a=S.default.safeLoad(e)}catch(e){return console.error(e),i.newSpecErr({source:"parser",level:"error",message:e.reason,line:e.mark&&e.mark.line?e.mark.line+1:void 0})}return n.updateJsonSpec(a)}},t.resolveSpec=function(e,t){return function(n){var r=n.specActions,i=n.specSelectors,o=n.errActions,a=n.fn,s=a.fetch,u=a.resolve,c=a.AST,l=n.getConfigs,p=l(),f=p.modelPropertyMacro,h=p.parameterMacro;void 0===e&&(e=i.specJson()),void 0===t&&(t=i.url());var d=c.getLineNumberForPath,m=i.specStr();return u({fetch:s,spec:e,baseDoc:t,modelPropertyMacro:f,parameterMacro:h}).then(function(e){var t=e.spec,n=e.errors;if(o.clear({type:"thrown"}),n.length>0){var i=n.map(function(e){return console.error(e),e.line=e.fullPath?d(m,e.fullPath):null,e.path=e.fullPath?e.fullPath.join("."):null,e.level="error",e.type="thrown",e.source="resolver",Object.defineProperty(e,"message",{enumerable:!0,value:e.message}),e});o.newThrownErrBatch(i)}return r.updateResolved(t)})}},t.formatIntoYaml=function(){return function(e){var t=e.specActions,n=e.specSelectors,r=n.specStr,i=t.updateSpec;try{var o=S.default.safeDump(S.default.safeLoad(r()),{indent:2});i(o)}catch(e){i(e)}}},t.setResponse=function(e,t,n){return{payload:{path:e,method:t,res:n},type:N}},t.setRequest=function(e,t,n){return{payload:{path:e,method:t,req:n},type:R}},t.logRequest=function(e){return{payload:e,type:F}},t.executeRequest=function(e){return function(t){var n=t.fn,r=t.specActions,i=t.specSelectors,o=e.pathName,a=e.method,s=e.operation,u=s.toJS();e.contextUrl=(0,A.default)(i.url()).toString(),u&&u.operationId?e.operationId=u.operationId:u&&o&&a&&(e.operationId=n.opId(u,o,a));var c=(0,x.default)({},e);c=n.buildRequest(c),r.setRequest(e.pathName,e.method,c);var l=Date.now();return n.execute(e).then(function(t){t.duration=Date.now()-l,r.setResponse(e.pathName,e.method,t)}).catch(function(t){return r.setResponse(e.pathName,e.method,{error:!0,err:(0,M.default)(t)})})}},function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.path,n=e.method,r=(0,_.default)(e,["path","method"]);return function(e){var i=e.fn.fetch,o=e.specSelectors,a=e.specActions,s=o.spec().toJS(),u=o.operationScheme(t,n),c=o.contentTypeValues([t,n]).toJS(),l=c.requestContentType,p=c.responseContentType,f=/xml/i.test(l),h=o.parameterValues([t,n],f).toJS();return a.executeRequest((0,g.default)({fetch:i,spec:s,pathName:t,method:n,parameters:h,requestContentType:l,scheme:u,responseContentType:p},r))}});t.execute=K},function(e,t,n){"use strict";var r=n(12),i=n(1234);i.keys().forEach(function(t){if("./index.js"!==t){var n=i(t);e.exports[(0,r.pascalCaseFilename)(t)]=n.default?n.default:n}})},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){var r=n(59),i=n(174),o=n(73),a=n(127),s=n(550);e.exports=function(e,t){var n=1==e,u=2==e,c=3==e,l=4==e,p=6==e,f=5==e||p,h=t||s;return function(t,s,d){for(var m,v,g=o(t),y=i(g),_=r(s,d,3),b=a(y.length),x=0,w=n?h(t,b):u?h(t,0):void 0;b>x;x++)if((f||x in y)&&(m=y[x],v=_(m,x,g),e))if(n)w[x]=v;else if(v)switch(e){case 3:return!0;case 5:return m;case 6:return x;case 2:w.push(m)}else if(l)return!1;return p?-1:c||l?l:w}}},function(e,t,n){var r=n(91),i=n(17)("toStringTag"),o="Arguments"==r(function(){return arguments}()),a=function(e,t){try{return e[t]}catch(e){}};e.exports=function(e){var t,n,s;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=a(t=Object(e),i))?n:o?r(t):"Object"==(s=r(t))&&"function"==typeof t.callee?"Arguments":s}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(34),i=n(23).document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){var r=n(59),i=n(322),o=n(320),a=n(32),s=n(127),u=n(185),c={},l={},t=e.exports=function(e,t,n,p,f){var h,d,m,v,g=f?function(){return e}:u(e),y=r(n,p,t?2:1),_=0;if("function"!=typeof g)throw TypeError(e+" is not iterable!");if(o(g)){for(h=s(e.length);h>_;_++)if((v=t?y(a(d=e[_])[0],d[1]):y(e[_]))===c||v===l)return v}else for(m=g.call(e);!(d=m.next()).done;)if((v=i(m,y,d.value,t))===c||v===l)return v};t.BREAK=c,t.RETURN=l},function(e,t,n){var r=n(91);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t,n){var r=n(32),i=n(560),o=n(172),a=n(179)("IE_PROTO"),s=function(){},u=function(){var e,t=n(171)("iframe"),r=o.length;for(t.style.display="none",n(318).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("