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
var Plugin = function (model, options) { | |
// do something with options | |
model.extend({ factoryMethod: function () { /* do stuff */ }}); | |
model.prototype.extend({ instanceMethod: function () { /* do other stuff */ }}); | |
model.extendSchema(Joi.object({ some: 'field' })); | |
}; |
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
var request = new XMLHttpRequest(); | |
request.onload = function () { | |
// request.status is the HTTP status code of the response | |
// request.responseText is whatever data the server sent back | |
// easiest for this would be something like | |
if (response.status === 200) { | |
// form posted ok | |
} else { | |
// form failed to post |
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
var User = new WOG({ | |
name: 'user', | |
schema: { | |
name: Joi.string().required(), | |
age: Joi.number().integer().default(20) | |
} | |
}); | |
var Plugin = function (collection) { |
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
var Hapi = require('hapi'); | |
var server = new Hapi.Server(); | |
server.connection(); | |
if (!module.parent) { | |
server.start(function () { | |
console.log('started 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
exports.index = { | |
auth: 'session', | |
handler: function (request, reply) { | |
reply('resource index'); | |
} | |
}; | |
exports.create = { | |
auth: 'session', | |
handler: function (request, reply) { |
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
var Joi = require('joi'); | |
var obj = { | |
prop6: ["2015-06-07T14:21:46.295-07:00", "2015-06-07T18:21:46.295-07:00", "2015-06-07T20:21:46.295-07:00"] | |
} | |
var schema = Joi.object().keys({ | |
prop6: Joi.array().includes(Joi.date().iso()).required() | |
}); | |
console.log(Joi.validate(obj, schema)) |
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
function go() { | |
CMD=$1 | |
GOBIN=`/usr/bin/which go` | |
OLDPATH="$GOPATH" | |
GOMODS=`pwd`/go_modules | |
if [ $CMD == "init" ]; then | |
echo "Initializing project $(basename `pwd`)..." | |
# Get a list of all (recursive) packages we depend on | |
DEPS=`go list -f '{{ join .Deps "\n" }}' 2>&1` |
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
The question has come up a few times as to how releases are handled in the hapi ecosystem, so I'm going to explain hopefully all of it here for everyone. Let me know if there are questions. | |
The primary release tracking comes from github milestones. There must always be a milestone representing the next version to be released. For sanity's sake, it's assumed that the next version will be a patch release (i.e. if 6.7.0 is released the new milestone created will be "6.7.1"). If it's determined later that the new version should be a major or minor, edit the milestone's title and the paper trail is maintained. When a version is released, mark the milestone as closed and make a new milestone for the next version (i.e. "6.7.2"). This makes sure that when a release is made the milestone accurately documents all of the changes that were made as a result of that version. | |
Every change in functionality or bug fix must have an issue associated with it, and the commit related to the issue should mention the issue number |
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
function riboot() { | |
echo "stopping riak.." | |
riak stop >/dev/null 2>&1 | |
echo "starting riak.." | |
riak start >/dev/null 2>&1 | |
echo -n "waiting.." | |
until riak-admin test >/dev/null 2>&1; do echo -n "."; sleep 1; done | |
echo "done" | |
} |
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
it('assigns an ephemeral port when requested twice', function (done) { | |
var server = new Hapi.Server(0); | |
var server2 = new Hapi.Server(0); | |
server.start(function () { | |
expect(server.info.port).to.be.a('number'); | |
expect(server.info.port).to.be.above(0); | |
server2.start(function () { |