-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds lout to api/server.js to provide api docs. dwyl/learn-hapi#6
- Loading branch information
Showing
3 changed files
with
39 additions
and
6 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,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; |
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
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