Skip to content

Commit

Permalink
v0.7.0
Browse files Browse the repository at this point in the history
See CHANGELOG.md
  • Loading branch information
GochoMugo committed Nov 16, 2016
2 parents ecf44d7 + 60063b1 commit 2e1d7b6
Show file tree
Hide file tree
Showing 26 changed files with 488 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ web/css/

# vendor files
web/vendor/

# coverage reports
coverage/
4 changes: 0 additions & 4 deletions .openshift/action_hooks/pre_start

This file was deleted.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- '6'
after_script: npm run test-coverage && cat ./coverage/lcov.info | coveralls
deploy:
provider: openshift
user: mugo@forfuture.co.ke
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).



## [0.7.0][0.7.0] - 2016-11-16

Changed:

* `/api/networks/:network` returns content of data file under `network` key


## [0.6.0][0.6.0] - 2016-11-14

Added:
Expand Down Expand Up @@ -92,4 +99,5 @@ This is the very first version.
[0.4.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.4.0
[0.5.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.5.0
[0.6.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.6.0
[Unreleased]: https://github.com/forfuturellc/mmtc-ke/compare/v0.6.0...HEAD
[0.7.0]:https://github.com/forfuturellc/mmtc-ke/releases/tag/v0.7.0
[Unreleased]: https://github.com/forfuturellc/mmtc-ke/compare/v0.7.0...HEAD
8 changes: 7 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ exports = module.exports = (grunt) => {
'Gruntfile.js',
'routes/**/*.js',
'web/js/*.js',
'test/**/*.js',
],
},
mochaTest: {
test: [
'test/test.*.js',
],
},
sass: {
Expand All @@ -30,5 +36,5 @@ exports = module.exports = (grunt) => {

grunt.registerTask('build', ['sass']);
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('test', ['lint']);
grunt.registerTask('test', ['lint', 'mochaTest']);
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Supported Node.js Versions](https://img.shields.io/badge/node->=6-green.svg)](https://github.com/forfuturellc/mmtc-ke)
[![Build Status](https://travis-ci.org/forfuturellc/mmtc-ke.svg?branch=master)](https://travis-ci.org/forfuturellc/mmtc-ke)
<!--[![Coverage Status](https://coveralls.io/repos/github/forfuturellc/mmtc-ke/badge.svg?branch=master)](https://coveralls.io/github/forfuturellc/mmtc-ke?branch=master)-->
[![Coverage Status](https://coveralls.io/repos/github/forfuturellc/mmtc-ke/badge.svg?branch=master)](https://coveralls.io/github/forfuturellc/mmtc-ke?branch=master)
[![Dependency Status](https://gemnasium.com/forfuturellc/mmtc-ke.svg)](https://gemnasium.com/forfuturellc/mmtc-ke)


Expand Down
32 changes: 27 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
*/


exports = module.exports = {
run,
};


// built-in modules
const path = require('path');

Expand Down Expand Up @@ -94,8 +99,25 @@ app.use(function(err, req, res, next) { // eslint-disable-line no-unused-vars
});


debug('starting server');
app.listen(config.get('server.port'), config.get('server.ip'), function() {
logger.info('server listening');
debug('server started at http://%s:%s', config.get('server.ip'), config.get('server.port'));
});
function run(options, done) {
options = options || {};
if (!options.host) {
options.host = config.get('server.ip');
}
if (!options.port) {
options.port = config.get('server.port');
}

debug('starting server');
app.listen(options.port, options.host, function() {
logger.info('server listening');
debug('server started at http://%s:%s', options.host, options.port);
if (done) return done();
});
}


if (require.main === module) {
debug('running as script');
run();
}
2 changes: 0 additions & 2 deletions data/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ additions:
this transaction can **not** be determined using our data (depends on
external factors, e.g. merchant reputation)

Therefore, the cost is accurate to **1 KES**.


<a name="type-ussdcode"></a>
### USSDCode
Expand Down
16 changes: 16 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and `https://mmtcke-forfutureco.rhcloud.com/api`

API Characteristics:

* <u>**Beta**: we are working on this API. Please watch the
[Github repository][repo] for updates. Some of these updates may break
the API, until we declare the API **stable**</u>
* **JSON**: data back-and-forth is formatted in JSON
* **Status codes**: responses are sent back with sensible status codes
* **Unauthenticated**: no authentication token is required, currently
Expand Down Expand Up @@ -77,6 +80,18 @@ GET /networks/:network
Retrieve data for `network`. This basically returns the content of
the data file for `network`.

Example partial response:

```http
200 OK
```

```json
{
"network": { /* CONTENT of the data file */ }
}
```


---
<a href="#post-cost" name="post-cost"># <i class="fa fa-file-text"></i></a>
Expand Down Expand Up @@ -108,3 +123,4 @@ Example response:


[data-files]:https://github.com/forfuturellc/mmtc-ke/tree/master/data
[repo]:https://github.com/forfuturellc/mmtc-ke
12 changes: 12 additions & 0 deletions docs/news.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<h2>API Change <small>2016-11-16</small></h2>

There has been change in our API at
[endpoint `/networks/:network`][endpoint]. This change breaks the
API. Update your software to reflect this.

Please note that we are <strong>not</strong> going through the process of
deprecation. The API is still in <strong>beta</strong>.

[endpoint]:http://mmtc.forfuture.co.ke/api/#get-networks-network


<h2>Updated Mpesa data <small>2016-11-11</small></h2>

The [recent change in M-pesa tariffs][change-in-tariffs] has necessitated
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "mmtc-ke",
"version": "0.6.0",
"version": "0.7.0",
"private": true,
"scripts": {
"build": "grunt build",
"postinstall": "HOME=${BOWER_HOME:-${HOME}} bower install",
"start": "forever app.js",
"start-dev": "DEBUG=mmtc-ke:* nodemon app.js",
"test": "grunt test"
"test": "grunt test",
"test-coverage": "istanbul cover _mocha --report lcovonly -- -R spec test/test.*.js"
},
"dependencies": {
"body-parser": "^1.15.2",
Expand Down Expand Up @@ -35,11 +36,17 @@
"node": ">=6"
},
"devDependencies": {
"coveralls": "^2.11.15",
"elbow": "^1.0.0",
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-eslint": "^19.0.0",
"grunt-mocha-test": "^0.13.2",
"grunt-sass": "^1.2.1",
"istanbul": "^0.4.5",
"load-grunt-tasks": "^3.5.2",
"mocha": "^3.1.2",
"mocha-lcov-reporter": "^1.2.0",
"nodemon": "^1.11.0"
}
}
2 changes: 1 addition & 1 deletion routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ router.get('/networks/:network', function(req, res, next) {
networkNotFoundError.statusCode = 404;
return next(networkNotFoundError);
}
return res.json(network);
return res.json({ network });
});


Expand Down
137 changes: 137 additions & 0 deletions schema/definitions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@

{
"$schema": "http://json-schema.org/schema#",

"network": {
"type": "object",
"properties": {
"name": {
"$ref": "#/name"
},
"meta": {
"$ref": "#/metadata"
},
"transactions": {
"type": "array",
"items": {
"$ref": "#/transaction"
}
},
"ussd_codes": {
"type": "array",
"items": {
"$ref": "#/ussd-code"
}
}
}
},

"metadata": {
"type": "object",
"properties": {
"spec": {
"type": "string"
},
"date_updated": {
"$ref": "#/date"
},
"url": {
"type": "string"
}
}
},

"transaction": {
"type": "object",
"properties": {
"name": {
"$ref": "#/name"
},
"classes": {
"type": "array",
"items": {
"$ref": "#/class"
}
},
"amount_input": {
"type": "boolean"
}
}
},

"class": {
"type": "object",
"properties": {
"name": {
"$ref": "#/name"
},
"ranges": {
"type": "array",
"items": {
"$ref": "#/range"
}
},
"amount": {
"$ref": "#/cost"
},
"message": {
"type": "string"
}
}
},

"range": {
"type": "object",
"properties": {
"low": {
"$ref": "#/cost"
},
"high": {
"$ref": "#/cost"
},
"amount": {
"$ref": "#/cost"
}
}
},

"cost": {
"type": ["number", "string"]
},

"ussd-code": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"description": {
"type": "string"
}
}
},

"name": {
"type": "string"
},

"date": {
"type": "string"
},

"error": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"name": {
"type": "string"
},
"statusCode": {
"type": "integer"
}
},
"required": ["message", "name", "statusCode"]
}
}
18 changes: 18 additions & 0 deletions test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
env:
es6: true
node: true
mocha: true
extends: 'eslint:recommended'
rules:
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
17 changes: 17 additions & 0 deletions test/elbow/404.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

{
"$schema": "http://json-schema.org/schema#",

"endpoint": "/404",
"description": "Fetching data file for a missing network",
"methods": ["get"],

"status": 404,
"type": "object",
"properties": {
"error": {
"$ref": "http://localhost:9667/definitions.json#/error"
}
},
"required": ["error"]
}
Loading

0 comments on commit 2e1d7b6

Please sign in to comment.