Skip to content

Commit

Permalink
Merge pull request getneil#3 from getneil/matthew
Browse files Browse the repository at this point in the history
Render Views
  • Loading branch information
getneil committed Sep 30, 2014
2 parents 883cf30 + aa7104a commit 3062c98
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"good": "^2.3.0",
"hapi": "^6.9.0",
"jade": "^1.7.0"
"jade": "^1.7.0",
"require-directory": "^2.0.0"
}
}
18 changes: 3 additions & 15 deletions src/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@ Hapi = require "hapi"
Good = require "good"
Path = require "path"
config = require "./config/settings"
routes = require './config/routes'

server = new Hapi.Server config.port,config.hapi.options

initialize = (cb)->

server.route
method: "GET"
path: "/"
handler: (request, reply) ->
reply "hello world"
return

server.route
method:"GET"
path:"/assets/{param*}"
handler:
directory:
path:"./assets/"
listing:true

server.route routes

server.pack.register Good, (err) ->
throw err if err # something bad happened loading the plugin
server.start ->
Expand Down
17 changes: 17 additions & 0 deletions src/config/routes.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
directory = require 'require-directory'
controller = directory module, '../controllers'
module.exports = [
{
method: 'GET'
path: '/'
config: controller.index.index
}
{
method: 'GET'
path: '/assets/{param*}'
handler:
directory:
path: './assets/'
listing: true
}
]
4 changes: 2 additions & 2 deletions src/config/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module.exports =
hapi:
options:
views:
path:"./app/views"
path: "./app/views"
engines:
html: require "jade"
jade: require "jade"
5 changes: 5 additions & 0 deletions src/controllers/index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports =
index:
handler: (request, reply) ->
reply.view 'index'

0 comments on commit 3062c98

Please sign in to comment.