Skip to content

Instantly share code, notes, and snippets.

Avatar

devin ivy devinivy

View GitHub Profile
@devinivy
devinivy / deep-hapi-routes.js
Last active Mar 2, 2018
recursive require-dir for hapi routes
View deep-hapi-routes.js
'use strict';
const tree = require('require-dir')(null, {
recurse: true // Consider also adding filter() to ignore e.g. helper directories
});
const flatten = (routes, obj) => {
if (Array.isArray(obj) || (obj.path && obj.method)) {
return routes.concat(obj);
@devinivy
devinivy / deploy.sh
Last active Mar 18, 2020
Publish a hapi pal flavor
View deploy.sh
#!/usr/bin/env bash
branch=$(git symbolic-ref --short HEAD)
version=$1
if ! [[ $branch =~ ^flavor- ]]; then
echo "Not on a flavor branch" >&2
exit 1
fi
@devinivy
devinivy / index.js
Created Nov 22, 2016
Underdog with vision
View index.js
'use strict';
const Hapi = require('hapi');
const Underdog = require('underdog');
const Vision = require('vision');
const Handlebars = require('handlebars');
const Spdy = require('spdy');
const Http2 = require('http2');
const agent = new Http2.Agent({ rejectUnauthorized: false });
View example.json
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@pobox.com",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
@devinivy
devinivy / push-me.js
Last active Aug 27, 2016
hapi with HTTP/2 server push
View push-me.js
document.write('i was pushed!');
@devinivy
devinivy / app.conf
Created Jul 14, 2016
Nginx reverse-proxy config for many apps
View app.conf
include /etc/nginx/conf.d/real-scheme.block;
upstream <app> {
server 127.0.0.1:<port>;
keepalive 16;
}
server {
listen 80;
server_name <server>;
@devinivy
devinivy / sam-redux.md
Last active Jun 29, 2016
SAM meets Redux
View sam-redux.md
  • model is a redux store.
  • actions are thunks.
  • nap() via model.subscribe().
  • present() is model.dispatch().
  • acceptor logic is redux middleware.
  • state/learner is implemented with ReactRedux.connect() and selectors (i.e. reselect).
@devinivy
devinivy / test-npmignore.sh
Created Jun 13, 2016
List the files that .npmignore will pack-up
View test-npmignore.sh
# from https://github.com/hapijs/contrib/issues/90#issuecomment-224889568
tar -tf $(npm pack) && rm *.tgz
@devinivy
devinivy / index.js
Last active May 5, 2016
Knex locked connections
View index.js
'use strict';
const Knex = require('./knex');
const knex = Knex({
dialect: 'postgres',
connection: {
adapter: 'postgresql',
database: 'test',
user: 'postgres'
@devinivy
devinivy / server.js
Created Jan 20, 2016
Testing an initialized hapi server
View server.js
var Hapi = require('hapi');
// Keep track of the server's init state
var internals = {
initialized: false
};
var server = new Hapi.Server();
server.connection();
You can’t perform that action at this time.