diff --git a/README.md b/README.md index 9bda87b..37c2096 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,10 @@ Pure pragmatic NodeJS stack For updates, read [changelog](changelog.md) -### Last update: 0.6.1 +### Last update: 0.6.2 ### Features ### -After years of dealing with Sinatra (Ruby) and Backbone, and a brief ExpressJS side project, I figure out that: - * **AngularJS 1.3.2** * **Hapi 8.0.0** * **Jasmine 2.0**: Both Angular Protractor and Facebook Jest are based on Jasmine. Using Mocha/Chai combo just adds to your learning curve. Jasmine 2.0 has been given more updates than ever before. Is a must have. @@ -36,6 +34,8 @@ After years of dealing with Sinatra (Ruby) and Backbone, and a brief ExpressJS s * [Istanbul code coverage support](http://gotwarlost.github.io/istanbul/) * Uses canned responses / server mocks / nobackend inspired by Euge's [canned responses](https://github.com/euge/canned-responses) * [Angular Hint](https://github.com/angular/angular-hint) +* [Hapi Swagger](https://github.com/glennjones/hapi-swagger) +* [Grunt JSDoc3](https://github.com/krampstudio/grunt-jsdoc) ### Installing ### 1. Clone repo @@ -58,6 +58,7 @@ After years of dealing with Sinatra (Ruby) and Backbone, and a brief ExpressJS s * `grunt migrate:create [--name]`: Creates a migration task. Args: --name: migration name (optional) * `grunt migrate:up [--revision]`: Migrates up. Args: --revision: revision name (optional) * `grunt migrate:down [--revision]`: Migrates down. Args: --revision: revision name (optional) +* `grunt docs`: Builds jsdoc3 documentation. ### Grunt Help (Frontend) ### diff --git a/changelog.md b/changelog.md index 2af3592..47d415d 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,11 @@ Pure pragmatic NodeJS stack ### Changelog ### +#### 0.6.2 + +* Adding `grunt-jsdoc` in service (with `rutha-grunt-tasks-service`). Closes issue #21. +* Adding `hapi-swagger` in service. Closes issue #12. + #### 0.6.1 * Adding missing `bcrypt-nodejs` dependency in service diff --git a/package.json b/package.json index 96ea84e..ac608c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rutha_stack", - "version": "0.6.1", + "version": "0.6.2", "main": "ui/lib/hapi/server.js", "description": "Rutha Dev Stack", "scripts": { diff --git a/service/.gitignore b/service/.gitignore index 13a4453..0ad5728 100644 --- a/service/.gitignore +++ b/service/.gitignore @@ -3,6 +3,7 @@ node_modules/ logs/ test/ +docs/ # Files # test.pdf diff --git a/service/jsdoc.conf.json b/service/jsdoc.conf.json new file mode 100644 index 0000000..6da02a3 --- /dev/null +++ b/service/jsdoc.conf.json @@ -0,0 +1,28 @@ +{ + "tags" : { + "allowUnknownTags" : true + }, + "plugins" : ["plugins/markdown"], + + "templates" : { + "cleverLinks" : false, + "monospaceLinks" : false, + "dateFormat" : "ddd MMM Do YYYY", + "outputSourceFiles" : true, + "outputSourcePath" : true, + "systemName" : "Rutha", + "footer" : "", + "copyright" : "Rutha © 2015", + "navType" : "vertical", + "theme" : "cosmo", + "linenums" : true, + "collapseSymbols" : false, + "inverseNav" : true, + "highlightTutorialCode" : true, + "protocol": "fred://" + }, + "markdown" : { + "parser" : "gfm", + "hardwrap" : true + } +} \ No newline at end of file diff --git a/service/lib/controllers/users/index.js b/service/lib/controllers/users/index.js index 8ea704d..0816602 100644 --- a/service/lib/controllers/users/index.js +++ b/service/lib/controllers/users/index.js @@ -1,13 +1,16 @@ var debug = require('debug')('users'); -var createHandler = require('./v1/create.js'); +var users = require('./v1'); exports.register = function(plugin, options, next) { plugin.route({ method: 'POST', path: '/v1/users', - handler: createHandler, + handler: users.create, config: { + description: 'A new account', + notes: 'Creates a new account', + tags: ['api'], auth: 'token' } }); diff --git a/service/lib/controllers/users/v1/create.js b/service/lib/controllers/users/v1/index.js similarity index 65% rename from service/lib/controllers/users/v1/create.js rename to service/lib/controllers/users/v1/index.js index f93f4f6..5f80e77 100644 --- a/service/lib/controllers/users/v1/create.js +++ b/service/lib/controllers/users/v1/index.js @@ -1,7 +1,14 @@ var debug = require('debug')('users:list'); +/** @module users */ -module.exports = function(request, reply) { +/** + * Creates a new user + * @function + * @param {Object} request - A Hapi Request + * @param {Object} reply - A Hapi Reply + */ +exports.create = function(request, reply) { var server = request.server; var UserModel = server.app.mongoose.models.User; diff --git a/service/lib/hapi/index.js b/service/lib/hapi/index.js index 06efd30..4680f46 100644 --- a/service/lib/hapi/index.js +++ b/service/lib/hapi/index.js @@ -37,23 +37,43 @@ server.app = { logger: logger }; - // add server methods to IoC mongoose models var controllers = [ { - register: require('lout'), + register: require('../controllers/users'), + } +]; + +var serverPlugins = [ + { + register: require('hapi-auth-bearer-token') + }, + { + register: require('hapi-swagger'), options: { - endpoint: '/api/docs' + basePath: 'http://localhost:' + config.get('apiServer:port'), + apiVersion: '1.0', + documentationPath: '/api_docs', + endpoint: '/rest_docs', + authorizations: { + token: { + type: "apiKey", + passAs: "header", + keyname: "authentication" + } + }, + info: { + title: 'Rutha REST API Documentation', + description: 'REST API Docs.', + contact: 'molekilla@gmail.com', + license: 'MIT' + } } - }, - { - register: require('../controllers/users'), } ]; - -server.register(require('hapi-auth-bearer-token'), function(err) { +server.register(serverPlugins, function(err) { server.auth.strategy('token', 'bearer-access-token', { validateFunc: function(token, callback) { diff --git a/service/package.json b/service/package.json index 16bf2d4..f785eae 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "rutha_stack_service", - "version": "0.6.1", + "version": "0.6.2", "description": "Rutha REST API Service", "main": "lib/hapi/index.js", "scripts": { @@ -23,6 +23,7 @@ "grunt-env": "~0.4.1", "grunt-istanbul": "~0.3.0", "grunt-jasmine-node": "~0.2.1", + "grunt-jsdoc": "^0.6.2", "grunt-node-inspector": "~0.1.5", "grunt-nodemon": "~0.2.1", "grunt-nsp-package": "0.0.5", @@ -31,7 +32,7 @@ "load-grunt-config": "~0.13.1", "mongodb": "^1.4.18", "rutha-grunt-mongo-migrations": "^0.1.1", - "rutha-grunt-tasks-service": "~0.1.4", + "rutha-grunt-tasks-service": "~0.1.5", "time-grunt": "~0.4.0" }, "dependencies": { @@ -40,9 +41,10 @@ "debug": "~2.1.0", "hapi": "~8.0.0", "hapi-auth-bearer-token": "^3.1.0", + "hapi-swagger": "^0.6.1", "joi": "^5.0.2", - "mongoose": "^3.8.21", "lout": "^6.0.1", + "mongoose": "^3.8.21", "rutha-utils": "^1.0.0", "underscore": "~1.7.0" } diff --git a/ui/.gitignore b/ui/.gitignore index 35b7de4..5f62661 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -3,6 +3,7 @@ node_modules/ logs/ dist/ +docs/ # Files # test.pdf diff --git a/ui/package.json b/ui/package.json index a01dc1d..87fea83 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "rutha_stack_frontend", - "version": "0.6.1", + "version": "0.6.2", "description": "Rutha Front End", "main": "lib/hapi/index.js", "scripts": { @@ -28,8 +28,10 @@ "grunt-contrib-uglify": "~0.5.0", "grunt-contrib-watch": "~0.6.1", "grunt-jasmine-node": "~0.2.1", + "grunt-jsdoc": "^0.6.2", "grunt-karma": "^0.9.0", "grunt-ng-annotate": "~0.4.0", + "grunt-ngdocs": "^0.2.6", "grunt-node-inspector": "~0.1.5", "grunt-nodemon": "~0.2.1", "grunt-nsp-package": "0.0.5",