-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💡 Adding client side javascript ideation #13
- Loading branch information
Showing
6 changed files
with
67 additions
and
11 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
coverage | ||
compiled.js |
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 |
---|---|---|
|
@@ -41,3 +41,5 @@ db | |
|
||
#goodparts symlink | ||
.eslintrc.js | ||
|
||
compiled.js |
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,46 @@ | ||
'use strict'; | ||
|
||
var Hapi = require('hapi'); | ||
var Vision = require('vision'); | ||
var assert = require('assert'); | ||
var HapiRiot = require('../../lib/index.js'); | ||
var Inert = require('inert'); | ||
var Path = require('path'); | ||
|
||
var server = new Hapi.Server(); | ||
var port = process.env.PORT || 8000; | ||
|
||
server.connection({ port: port }); | ||
|
||
server.register([Vision, Inert], function (err) { | ||
assert(!err); // Halt start if Vision fails to load. | ||
|
||
server.views({ | ||
engines: { tag: HapiRiot }, | ||
relativeTo: __dirname, | ||
path: 'views', | ||
compileOptions: {} | ||
}); | ||
|
||
server.route({ | ||
method: 'GET', | ||
path: '/', | ||
handler: function (request, reply) { | ||
reply.view('index', { counter: 5 }); | ||
} | ||
}); | ||
|
||
server.route({ | ||
method: 'GET', | ||
path: '/riot.js', | ||
handler: function (request, reply) { | ||
reply.file(Path.join(__dirname, 'compiled.js')); | ||
} | ||
}); | ||
|
||
server.start(function () { | ||
console.log('Server is listening at ' + server.info.uri); // eslint-disable-line | ||
}); | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<index> | ||
<label>{title}</label> | ||
<button onclick="{changeName}">{ 'Counter: ' + counter }</button> | ||
<script> | ||
this.counter = opts.counter; | ||
|
||
changeName() { this.counter += 1 } | ||
</script> | ||
</index> |
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