Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/docker/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ npm run -s test:integration

# Create coverage report and store in artifacts
echo "Running coverage. Report stored in coverage.lcov"
exec npm run -s coverage -- --reporter=text-lcov > artifacts/coverage.lcov
npm run -s coverage -- --reporter=text-lcov > artifacts/coverage.lcov
9 changes: 9 additions & 0 deletions mini.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set nocompatible
set runtimepath^=~/.config/nvim/plugged/coc.nvim
filetype plugin indent on
syntax on
set hidden

" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent :call CocActionAsync('doHover')
set updatetime=300
93 changes: 63 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"koa-static": "^5.0.0",
"koa2-swagger-ui": "^2.13.2",
"mysql2": "^1.6.5",
"sequelize": "^5.10.1",
"sequelize": "^5.21.1",
"sequelize-cli": "^5.5.0",
"winston": "^3.2.1"
},
Expand Down
24 changes: 11 additions & 13 deletions src/dao-factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const Promise = require('bluebird');
const Message = require('./dao/message');

/**
Expand All @@ -9,6 +8,9 @@ const Message = require('./dao/message');
* Stores and the Buiness Objects ensuring that the
* Business layer is separated completely from the
* Persistence layer
*
* @class DaoFac
* @property {Store} store - Data Store object
*/

module.exports = class DaoFac {
Expand All @@ -21,19 +23,15 @@ module.exports = class DaoFac {
*
* Provides an easy lookup for DAO's in Business Objects
*
* @args {string} daoNam - Name of dao
* @returns {Promise<DAO>} - Promise that resolves to the DAO instance (or errors)
* @param {string} daoName - Name of dao
* @returns {DAO} - The DAO instance (or errors)
*/
daoFor(daoName) {
return new Promise((resolve, reject) => {
switch (daoName) {
case 'message':
return resolve(new Message(this.store));
break;
default:
return reject(new Error(`No DAO for ${daoName}`));
break;
}
});
switch (daoName) {
case 'message':
return new Message(this.store);
default:
throw new Error(`No DAO for ${daoName}`);
}
}
};
70 changes: 36 additions & 34 deletions src/dao/message.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';
const Promise = require('bluebird');

/**
* Data Access layer object for the Message data
*
* @constructor
* @args {Object} store - Instance of the store object
* @class
* @param {Store} store - Instance of the store object
*/
module.exports = class MessageDao {
constructor(store) {
Expand All @@ -19,13 +18,13 @@ module.exports = class MessageDao {
/**
* Returns a single message from storage as identified by its primary key
*
* @args {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @args {integer} id - Id of the message to retrieve
* @param {Object} deps
* @param {KoaServerTimings} deps.timings - Instance of a Koa Server Timings object (option)
* @param {number} id - Id of the message to retrieve
*
* @returns Promise<Object> message
*/
find(deps, id) {
deps = deps || {};
find(deps = {}, id) {
if (deps.timings) {
deps.timings.startSpan('messageDao:find');
}
Expand Down Expand Up @@ -55,13 +54,13 @@ module.exports = class MessageDao {
/**
* Deletes a single message from storage as identified by its primary key
*
* @args {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @args {integer} id - Id of the message to retrieve
* @param {Object} deps
* @param {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @param {number} id - Id of the message to retrieve
*
* @returns Promise<Object> message
*/
delete(deps, id) {
deps = deps || {};
delete(deps = {}, id) {
if (deps.timings) {
deps.timings.startSpan('messageDao:delete');
}
Expand Down Expand Up @@ -91,15 +90,15 @@ module.exports = class MessageDao {
/**
* Update a message in storage
*
* @args {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @args {integer} id - id of the message to update
* @args (string) args.text - Text data of the message
* @args (string) args.owner - onder identifier in remote system
* @args (string) args.updatedBy - Remote System identifier (required)
* @param {Object} deps
* @param {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @param {number} id - id of the message to update
* @param {Object} args
* @param {string} args.text - Text data of the message
* @param {string} args.owner - onder identifier in remote system
* @param {string} args.updatedBy - Remote System identifier (required)
*/
update(deps, id, args) {
deps = deps || {};

update(deps = {}, id, args) {
if (deps.timings) {
deps.timings.startSpan('messageDao:update');
}
Expand Down Expand Up @@ -143,14 +142,14 @@ module.exports = class MessageDao {
/**
* Create a new message in storage
*
* @args {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @args (string) args.text - Text data of the message (required)
* @args (string) args.owner - onder identifier in remote system
* @args (string) args.createdBy - Remote System identifier
* @param {Object} deps - Dependency injection
* @param {Object} deps.timings - Instance of a Koa Server Timings object (option)
* @param {Object} args - Function arguments
* @param {string} args.text - Text data of the message (required)
* @param {string} args.owner - onder identifier in remote system
* @param {string} args.createdBy - Remote System identifier
*/
create(deps, args) {
deps = deps || {};
args = args || {};
create(deps = {}, args = {}) {
if (deps.timings) {
deps.timings.startSpan('messageDao:create');
}
Expand Down Expand Up @@ -189,11 +188,11 @@ module.exports = class MessageDao {
/**
* Return the total number of messages in storage
*
* @args {Object} deps.timings - Instance of a Koa Server Timings object (optional)
* @param {Object} deps
* @param {Object} deps.timings - Instance of a Koa Server Timings object (optional)
*/

totalMessages(deps) {
deps = deps || {};
totalMessages(deps = {}) {
if (deps.timings) {
deps.timings.startSpan('messageDao:totalMessages');
}
Expand All @@ -219,13 +218,16 @@ module.exports = class MessageDao {
/**
* Return all message in storage
*
* @args {Object} deps.timings - Instance of a Koa Server timings
* @args {integer} args.limit - Max number of messages to return
* @args {integer} args.offset - Offset before retrieving messages
* @param {Object} deps
* @param {Object} deps.timings - Instance of a Koa Server timings
* @param {Object} args
* @param {number} args.limit - Max number of messages to return
* @param {number} args.offset - Offset before retrieving messages
*
* @returns {Promise<Array<Messaage>>} messages - All stored messages
*/

getAll(deps, args) {
deps = deps || {};
getAll(deps = {}, args) {
if (deps.timings) {
deps.timings.startSpan('messageDao:getAll');
}
Expand Down
Loading