Skip to content

Commit

Permalink
adds lout to api/server.js to provide api docs. dwyl/learn-hapi#6
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Mar 15, 2015
1 parent c172bcd commit 9dca409
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
33 changes: 33 additions & 0 deletions api/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// if you want to run the Just the API server without front-end run this file
var Hapi = require('hapi');
var Basic = require('hapi-auth-basic');
var AuthJWT = require('hapi-auth-jwt2')
var Joi = require('joi');
var lout = require('lout');
var ES = require('esta'); // https://github.com/nelsonic/esta
var port = process.env.PORT || 1337; // heroku define port or use 1337
var server = new Hapi.Server();

server.connection({ port: port });

var routes = require('./routes.js');

server.register([ {register: Basic}, {register: AuthJWT}, { register: lout } ], function (err) {

server.auth.strategy('basic', 'basic', {
validateFunc: require('./lib/auth_basic_validate.js')
});

server.auth.strategy('jwt', 'jwt', 'required', {
key: process.env.JWT_SECRET,
validateFunc: require('./lib/auth_jwt_validate.js')
});

server.route(routes);

});

server.start();
console.log('Now Visit: http://localhost:'+port);

module.exports = server;
5 changes: 2 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ server.register([ {register: Basic}, {register: AuthJWT} ], function (err) {

});

server.start(function() {
console.log('Now Visit: http://localhost:'+port);
});
server.start();
console.log('Now Visit: http://localhost:'+port);

module.exports = server;
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "atimer",
"version": "0.1.2",
"version": "0.1.3",
"description": "Track any time-based activity",
"main": "index.js",
"scripts": {
"api":"node ./api/server.js",
"codeclimate": "CODECLIMATE_REPO_TOKEN=0839d00dd01047ffadfb3c56bf9c9baa0047179de582a47517e3f558ad4eafff ./node_modules/codeclimate-test-reporter/bin/codeclimate.js < ./coverage/lcov.info",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./api/test/*.js | node_modules/tap-spec/bin/cmd.js && ./node_modules/.bin/istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"jshint": "./node_modules/jshint/bin/jshint -c .jshintrc --exclude-path .gitignore .",
"start": "node app.js",
"test": "node ./node_modules/tape/bin/tape ./api/test/*.js | node_modules/tap-spec/bin/cmd.js",
"spec": "node ./node_modules/tape/bin/tape ./api/test/*.js | node_modules/tap-spec/bin/cmd.js"

},
"repository": {
"type": "git",
Expand All @@ -31,13 +31,14 @@
"aguid": "^1.0.3",
"bcrypt": "^0.8.1",
"boom": "^2.6.1",
"esta": "^3.0.1",
"esta": "^3.2.0",
"hapi": "^8.2.0",
"hapi-auth-basic": "^2.0.0",
"hapi-auth-jwt2": "^3.2.1",
"hoek": "^2.11.0",
"joi": "^6.0.0",
"jsonwebtoken": "^4.1.0",
"lout": "^6.2.1",
"perma": "^2.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit 9dca409

Please sign in to comment.