Skip to content

Instantly share code, notes, and snippets.

@chmanie
Last active August 29, 2015 13:56
Show Gist options
  • Save chmanie/8942216 to your computer and use it in GitHub Desktop.
Save chmanie/8942216 to your computer and use it in GitHub Desktop.
yar_25
'use strict';
var expect = require('expect.js');
var Hapi = require('hapi');
var server = Hapi.createServer('0.0.0.0', 8080, {
debug: {
request: ['error']
}
});
var types = Hapi.types;
server.pack.require({
yar: {
cookieOptions: {
password: 'temp', // cookie secret
isSecure: false // required for non-https applications
}
}
}, function (err) {
if (err) throw err;
});
server.route({
method: 'POST',
path: '/users',
config: {
validate: {
payload: {
password: types.String().min(8)
}
},
handler: handler
}
});
function handler(req, reply) {
reply('OK');
}
describe('users resource controller', function () {
it('creates a user who has a password', function (done) {
server.inject({ method: 'POST', url: '/users', payload:
{
password: 'secret'
}
}, function (res) {
expect(res.statusCode).to.equal(200);
done();
}
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment