-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,067 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# http://editorconfig.org | ||
# https://github.com/airbnb/javascript/blob/master/.editorconfig | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
# editorconfig-tools is unable to ignore longs strings or urls | ||
max_line_length = null | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
#Temporary data | ||
.tmp | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# Deployed apps should consider commenting this line out: | ||
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git | ||
node_modules | ||
doc | ||
startup.sh | ||
spec/intergration.spec.js | ||
config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"js": { | ||
"jslint_happy": true, | ||
"indent_size": 2, | ||
"wrap_line_length": 80 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"bitwise": true, | ||
"browser": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"esnext": true, | ||
"immed": true, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"node": true, | ||
"proto": true, | ||
"mocha": true, | ||
"quotmark": "single", | ||
"strict": true, | ||
"undef": true, | ||
"unused": true, | ||
"ignore": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
node_modules | ||
ssl | ||
.DS_STORE | ||
*~ | ||
.idea | ||
nbproject | ||
test | ||
.git | ||
.gitignore | ||
.tmp | ||
*.swo | ||
*.swp | ||
*.swn | ||
*.swm | ||
*.log | ||
.jshintrc | ||
.editorconfig | ||
docs | ||
config | ||
views | ||
spec/intergration.spec.js | ||
doc.html | ||
.travis.yml | ||
Gruntfile.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: node_js | ||
services: | ||
- mongodb | ||
- redis-server | ||
node_js: | ||
- "6.9.2" | ||
before_script: | ||
- npm install -g grunt-cli | ||
- redis-cli config set notify-keyspace-events Ex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# v0.1.0 / 2018-05-22 | ||
|
||
* Common apidoc definitions | ||
* Common environment variables access | ||
* Common schema options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
// add grunt tasks. | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
grunt.initConfig({ | ||
mochaTest: { | ||
unit: { | ||
options: { | ||
reporter: 'spec', | ||
timeout: 20000 | ||
}, | ||
src: [ | ||
'test/**/*.js', | ||
'test/unit/**/*.js', | ||
'!test/integration/**/*.js' | ||
] | ||
}, | ||
integration: { | ||
options: { | ||
reporter: 'spec', | ||
timeout: 20000 | ||
}, | ||
src: [ | ||
'test/**/*.js', | ||
'test/integration/**/*.js', | ||
'!test/unit/**/*.js' | ||
] | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
reporter: require('jshint-stylish'), | ||
jshintrc: '.jshintrc' | ||
}, | ||
main: { | ||
src: [ | ||
'Gruntfile.js', | ||
'index.js', | ||
'lib/**/*.js', | ||
] | ||
}, | ||
test: { | ||
options: { | ||
jshintrc: 'test/.jshintrc' | ||
}, | ||
src: [ | ||
'test/**/*.js' | ||
] | ||
} | ||
}, | ||
watch: { | ||
all: { | ||
files: [ | ||
'Gruntfile.js', | ||
'index.js', | ||
'lib/**/*.js', | ||
'test/**/*.js' | ||
], | ||
tasks: ['default'] | ||
} | ||
} | ||
}); | ||
|
||
//custom tasks | ||
grunt.registerTask('default', ['jshint', 'mochaTest', 'watch']); | ||
grunt.registerTask('test', ['jshint', 'mochaTest']); | ||
grunt.registerTask('integration', ['jshint', 'mochaTest:integration']); | ||
grunt.registerTask('unit', ['jshint', 'mochaTest:unit']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 CodeTanzania & Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
majifix-common | ||
===================== | ||
|
||
[![Build module-starter](https://travis-ci.org/CodeTanzania/majifix-common.svg?branch=develop)](https://travis-ci.org/CodeTanzania/majifix-common) | ||
[![Dependencies module-starter](https://david-dm.org/CodeTanzania/majifix-common/module-starter.svg?style=flat-square)](https://david-dm.org/CodeTanzania/majifix-common) | ||
|
||
Common utilities for majifix | ||
|
||
## Requirements | ||
- [NodeJS v9.9.0+](https://nodejs.org) | ||
- [MongoDB v3.4.10+](https://www.mongodb.com/) | ||
- [Mongoose v5.0.14+](https://github.com/Automattic/mongoose) | ||
|
||
## Installation | ||
```sh | ||
$ npm install --save @codetanzania/majifix-common | ||
``` | ||
|
||
## Usage | ||
```js | ||
const { env } = require('@codetanzania/majifix-common'); | ||
``` | ||
|
||
## Test | ||
* Clone this repository | ||
|
||
* Install all dependencies | ||
```sh | ||
$ npm install | ||
``` | ||
|
||
* Then run test | ||
```sh | ||
$ npm test | ||
``` | ||
|
||
## Contribute | ||
It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding. | ||
|
||
|
||
## Licence | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 CodeTanzania & Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
/* dependencies */ | ||
const path = require('path'); | ||
|
||
/* declarations */ | ||
const env = require(path.join(__dirname, 'lib', 'env')); | ||
const schema = require(path.join(__dirname, 'lib', 'schema')); | ||
|
||
Object.defineProperties(exports, { | ||
env: { | ||
get: function () { | ||
return env; | ||
} | ||
}, | ||
schema: { | ||
get: function () { | ||
return schema; | ||
} | ||
} | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
|
||
/* | ||
* ------------------------------------------------ | ||
* Headers | ||
* ------------------------------------------------ | ||
*/ | ||
|
||
/** | ||
* @apiDefine RequestHeaders | ||
* @apiHeader {String} [Accept=application/json] Accepted content type | ||
* @apiHeader {String} Authorization Authorization token | ||
* @apiHeader {String} [Accept-Encoding='gzip, deflate'] Accepted encoding type | ||
*/ | ||
|
||
|
||
/** | ||
* @apiDefine RequestHeadersExample | ||
* @apiHeaderExample {json} Header-Example: | ||
* { | ||
* "Accept": "application/json" | ||
* "Authorization": "Bearer ey6utFreRdy5" | ||
* "Accept-Encoding": "gzip, deflate" | ||
* } | ||
*/ | ||
|
||
|
||
/* | ||
* ---------------------------------------------------- | ||
* Errors | ||
* ---------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* @apiDefine JWTError | ||
* @apiError JWTExpired Authorization token has expired | ||
*/ | ||
|
||
|
||
/** | ||
* @apiDefine JWTErrorExample | ||
* @apiErrorExample {json} Error-Response: | ||
* HTTP/1.1 403 Forbidden | ||
* { | ||
* "success":false, | ||
* "message :"jwt expired", | ||
* "error":{} | ||
* } | ||
*/ | ||
|
||
|
||
/** | ||
* @apiDefine AuthorizationHeaderError | ||
* @apiError AuthorizationHeaderRequired Authorization header is required | ||
*/ | ||
|
||
|
||
/** | ||
* @apiDefine AuthorizationHeaderErrorExample | ||
* @apiErrorExample {json} Error-Response: | ||
* HTTP/1.1 403 Forbidden | ||
* { | ||
* "success":false, | ||
* "message :"Authorization header required", | ||
* "error":{} | ||
* } | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
/* dependencies */ | ||
const _ = require('lodash'); | ||
|
||
//country data | ||
|
||
/** | ||
* @example | ||
* const { LOCALES } = require('majifix-common').env; | ||
*/ | ||
Object.defineProperties(exports, { | ||
LOCALES: { | ||
get: function () { | ||
let locales = _.get(process, 'env.LOCALES', '').split(','); | ||
locales = ([].concat(exports.DEFAULT_LOCALE).concat(locales)); | ||
locales = _.compact(locales); | ||
locales = _.uniq(locales); | ||
return locales; | ||
} | ||
}, | ||
API_VERSION: { | ||
get: function () { | ||
return process.env.API_VERSION || '1.0.0'; | ||
} | ||
}, | ||
DEFAULT_LOCALE: { | ||
get: function () { | ||
return process.env.DEFAULT_LOCALE || 'en'; | ||
} | ||
}, | ||
DEFAULT_CALLING_CODE: { | ||
get: function () { | ||
return process.env.DEFAULT_CALLING_CODE || '255'; | ||
} | ||
} | ||
}); |
Empty file.
Oops, something went wrong.