Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
internals.start = async function () {
const server = Hapi.server({ host: 'localhost', port: 8000 });
await server.register(Bell);
// You'll need to go to https://developers.facebook.com/ and set up a
// Website application to get started
// Once you create your app, fill out Settings and set the App Domains
// Under Settings >> Advanced, set the Valid OAuth redirect URIs to include http:///bell/door
// and enable Client OAuth Login
server.auth.strategy('facebook', 'bell', {
provider: 'facebook',
password: 'cookie_encryption_password_secure',
isSecure: false,
clientId: '',
clientSecret: '',
location: server.info.uri
});
const createServer = async () => {
// Create a server with a host and port
const server = Hapi.server({
port: process.env.PORT || 3000
});
// Register vendors plugins
await server.register([
require('blipp'),
require('@hapi/inert'),
require('@hapi/vision'),
{
plugin: require('hapi-swagger'),
options: {
info: {
title: 'Test API Documentation',
version: Package.version,
},
}
it('authenticates with mock', async (flags) => {
const mock = await Mock.v2(flags);
const server = Hapi.server({ host: 'localhost', port: 80 });
await server.register(Bell);
const custom = Bell.providers.bitbucket();
Hoek.merge(custom, mock.provider);
Mock.override('https://api.bitbucket.org/2.0/user', {
repositories: [{}],
uuid: '1E9C5160-E436-11E5-9897-4FCB70D5A8C7',
username: 'steve',
display_name: 'steve'
});
server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
isSecure: false,
clientId: 'bitbucket',
it('binds onResponse to plugin bind', async () => {
const upstream = Hapi.server();
await upstream.start();
const plugin = {
register: function (server, options) {
const onResponseWithError = function (err, res, request, h, settings, ttl) {
expect(err).to.be.null();
return h.response(h.context.c);
};
const handler = {
proxy: {
host: 'localhost',
port: upstream.info.port,
onResponse: onResponseWithError
it('allows passing in an agent through to Wreck', { parallel: false }, async () => {
const server = Hapi.server();
await server.register(H2o2);
const agent = { name: 'myagent' };
const httpClient = {
request(method, uri, options, callback) {
expect(options.agent).to.equal(agent);
return { statusCode: 200 };
}
};
server.route({ method: 'GET', path: '/agenttest', handler: { proxy: { uri: 'http://localhost', httpClient, agent } } });
await server.inject({ method: 'GET', url: '/agenttest', headers: {} }, (res) => { });
});
const hapi = require('@hapi/hapi')
const laabr = require('../src')
const server = hapi.server({ port: 3000 })
server.route([
{
method: '*',
path: '/response',
handler () {
return 'hello world'
}
},
{
method: 'GET',
path: '/error',
handler () {
throw new Error('foobar')
}
}
async function start () {
const server = Hapi.server({ port: 3000 })
server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})
await server.start()
}
async function start () {
const server = Hapi.server({ port: 3000 })
server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})
await server.register({
plugin: require('..'),
options: {
mergeHapiLogData: true
}
})