Skip to content

Commit 8acf8f0

Browse files
committed
Initialize
- Implement alert schema & model - Implement alert http api endpoint
1 parent b8978f9 commit 8acf8f0

38 files changed

+5889
-0
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# http://editorconfig.org
2+
# https://github.com/airbnb/javascript/blob/master/.editorconfig
3+
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
end_of_line = lf
13+
# editorconfig-tools is unable to ignore longs strings or urls
14+
max_line_length = null
15+
16+
[*.md]
17+
trim_trailing_whitespace = false

.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
#Temporary data
6+
.tmp
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
13+
# Directory for instrumented libs generated by jscoverage/JSCover
14+
lib-cov
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20+
.grunt
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# Deployed apps should consider commenting this line out:
27+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
28+
node_modules
29+
startup.sh
30+
spec/intergration.spec.js
31+
config

.jsbeautifyrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"js":
3+
{
4+
"jslint_happy": true,
5+
"indent_size": 2,
6+
"wrap_line_length": 80
7+
}
8+
}

.jshintrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bitwise": true,
3+
"browser": true,
4+
"camelcase": true,
5+
"curly": true,
6+
"eqeqeq": true,
7+
"esnext": true,
8+
"immed": true,
9+
"latedef": true,
10+
"newcap": true,
11+
"noarg": true,
12+
"node": true,
13+
"proto": true,
14+
"mocha": true,
15+
"quotmark": "single",
16+
"strict": true,
17+
"undef": true,
18+
"unused": true,
19+
"ignore": true
20+
}

.npmignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
node_modules
2+
ssl
3+
.DS_STORE
4+
*~
5+
.idea
6+
nbproject
7+
.git
8+
.gitignore
9+
.tmp
10+
*.swo
11+
*.swp
12+
*.swn
13+
*.swm
14+
*.log
15+
.jshintrc
16+
.editorconfig
17+
.travis.yml
18+
Gruntfile.js
19+
doc
20+
docs
21+
examples

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
services:
3+
- mongodb
4+
node_js:
5+
- "9.3.0"
6+
before_script:
7+
- npm install -g grunt-cli

CHANGELOG.md

Whitespace-only changes.

Gruntfile.js

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
5+
// add grunt tasks.
6+
grunt.loadNpmTasks('grunt-mocha-test');
7+
grunt.loadNpmTasks('grunt-contrib-jshint');
8+
grunt.loadNpmTasks('grunt-contrib-watch');
9+
grunt.loadNpmTasks('grunt-apidoc');
10+
11+
grunt.initConfig({
12+
apidoc: {
13+
api: {
14+
src: ['node_modules/@codetanzania/majifix-common/lib', 'lib/'],
15+
dest: 'docs/',
16+
options: {
17+
debug: true,
18+
includeFilters: ['.*\\.js$'],
19+
// excludeFilters: ['node_modules/']
20+
}
21+
}
22+
},
23+
mochaTest: {
24+
unit: {
25+
options: {
26+
reporter: 'spec',
27+
timeout: 20000
28+
},
29+
src: [
30+
'test/**/*.js',
31+
'test/unit/**/*.js',
32+
'!test/integration/**/*.js'
33+
]
34+
},
35+
integration: {
36+
options: {
37+
reporter: 'spec',
38+
timeout: 20000
39+
},
40+
src: [
41+
'test/**/*.js',
42+
'test/integration/**/*.js',
43+
'!test/unit/**/*.js'
44+
]
45+
}
46+
},
47+
jshint: {
48+
options: {
49+
reporter: require('jshint-stylish'),
50+
jshintrc: '.jshintrc'
51+
},
52+
main: {
53+
src: [
54+
'Gruntfile.js',
55+
'index.js',
56+
'lib/**/*.js',
57+
]
58+
},
59+
test: {
60+
options: {
61+
jshintrc: 'test/.jshintrc'
62+
},
63+
src: [
64+
'test/**/*.js'
65+
]
66+
}
67+
},
68+
watch: {
69+
all: {
70+
files: [
71+
'Gruntfile.js',
72+
'index.js',
73+
'lib/**/*.js',
74+
'test/**/*.js'
75+
],
76+
tasks: ['default']
77+
}
78+
}
79+
});
80+
81+
//custom tasks
82+
grunt.registerTask('default', ['jshint', 'mochaTest', 'watch']);
83+
grunt.registerTask('test', ['jshint', 'mochaTest']);
84+
grunt.registerTask('integration', ['jshint', 'mochaTest:integration']);
85+
grunt.registerTask('unit', ['jshint', 'mochaTest:unit']);
86+
grunt.registerTask('doc', ['jshint', 'apidoc:api']);
87+
88+
};

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 CodeTanzania & Contributors
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: BASE_PATH=./examples node ./examples/app.js

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# emis-alert
2+
3+
[![Build Status](https://travis-ci.org/CodeTanzania/emis-alert.svg?branch=develop)](https://travis-ci.org/CodeTanzania/emis-alert)
4+
[![Dependencies Status](https://david-dm.org/CodeTanzania/emis-alert/status.svg?style=flat-square)](https://david-dm.org/CodeTanzania/emis-alert)
5+
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/CodeTanzania/emis-alert/tree/develop)
6+
7+
A representation of an entity which provides(or receives) notifications to(or from) source(s).
8+
9+
An alert is generated by a specific situation. The main features of an alert is that it is not predictable and it is not a recurrent data. That means that an alert could be an accident or a high level of pollutants measure.
10+
11+
## Requirements
12+
13+
- [NodeJS v8.11.1+](https://nodejs.org)
14+
- [Npm v5.6.0+](https://www.npmjs.com/)
15+
- [MongoDB v3.4.10+](https://www.mongodb.com/)
16+
- [Mongoose v5.1.2+](https://github.com/Automattic/mongoose)
17+
18+
## Installation
19+
20+
```sh
21+
npm install @codetanzania/emis-alert --save
22+
```
23+
24+
## Usage
25+
26+
```js
27+
const mongoose = require('mongoose');
28+
const { app } = require('@codetanzania/emis-alert');
29+
30+
mongoose.connect(process.env.MONGODB_URI);
31+
32+
app.start(function (error) {
33+
...
34+
});
35+
```
36+
37+
## References
38+
- [Disaster](https://en.wikipedia.org/wiki/Disaster)
39+
- [IRDR Peril Classification and Hazard Glossary](http://www.irdrinternational.org/wp-content/uploads/2014/04/IRDR_DATA-Project-Report-No.-1.pdf)
40+
- [EM-DAT Guidelines](https://www.emdat.be/guidelines)
41+
- [Glide Number](http://www.glidenumber.net/glide/public/search/search.jsp?)
42+
43+
## Testing
44+
45+
- Clone this repository
46+
47+
- Install all development dependencies
48+
49+
```sh
50+
npm install
51+
```
52+
53+
- Run example
54+
55+
```sh
56+
npm run dev
57+
```
58+
59+
- Then run test
60+
61+
```sh
62+
npm test
63+
```
64+
65+
## Contribute
66+
67+
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.
68+
69+
## References
70+
71+
- [Open311 GeoReport v2](http://wiki.open311.org/GeoReport_v2/)
72+
- [popolo project](https://www.popoloproject.com/)
73+
- [http://geojson.org/](http://geojson.org/)
74+
- [https://tools.ietf.org/html/rfc7946](https://tools.ietf.org/html/rfc7946)
75+
- [https://opengovdata.io/](https://opengovdata.io/)
76+
77+
## Licence
78+
79+
The MIT License (MIT)
80+
81+
Copyright (c) 2018 CodeTanzania & Contributors
82+
83+
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:
84+
85+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
86+
87+
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.

apidoc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "emis-alert",
3+
"title": "EMIS - Alert",
4+
"url": "https://emis-alert.herokuapp.com/v1",
5+
"sampleUrl": "https://emis-alert.herokuapp.com/v1",
6+
"template":
7+
{
8+
"withCompare": true,
9+
"withGenerator": true
10+
}
11+
}

app.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "emis-alert",
3+
"description": "A representation of an entity which provides(or receives) notifications to(or from) source(s).",
4+
"repository": "https://github.com/CodeTanzania/emis-alert.git",
5+
"keywords": [
6+
"codetanzania",
7+
"emis",
8+
"emis-module",
9+
"alert",
10+
"incident",
11+
"hazard",
12+
"emergency",
13+
"warning"
14+
],
15+
"addons": [
16+
"mongolab"
17+
],
18+
"env":
19+
{
20+
"NPM_CONFIG_PRODUCTION":
21+
{
22+
"value": "false"
23+
},
24+
"YARN_PRODUCTION":
25+
{
26+
"value": "false"
27+
}
28+
}
29+
}

examples/.env

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# environment
2+
NODE_ENV=development
3+
PORT=5000
4+
5+
# request logger(morgan)
6+
LOG_ENABLED=true
7+
LOG_FORMAT=combined
8+
9+
10+
# static serve
11+
SERVE_STATIC=true
12+
SERVE_STATIC_PATH=public
13+
14+
15+
# body parser
16+
BODY_PARSER_LIMIT=2mb
17+
BODY_PARSER_JSON_TYPE=application/json
18+
19+
# api version
20+
API_VERSION=1.0.0
21+
22+
# helmet
23+
HELMET_HSTS=false
24+
25+
# mquery
26+
MQUERY_LIMIT=10
27+
MQUERY_MAX_LIMIT=50
28+
29+
# locales
30+
DEFAULT_LOCALE=en
31+
LOCALES=en,sw

0 commit comments

Comments
 (0)