Skip to content

Instantly share code, notes, and snippets.

View devinivy's full-sized avatar

devin ivy devinivy

View GitHub Profile
@devinivy
devinivy / deep-hapi-routes.js
Last active March 2, 2018 14:05
recursive require-dir for hapi routes
'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 May 25, 2021 14:44
Publish a hapi pal flavor
#!/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 November 22, 2016 20:59
Underdog with vision
'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 });
{"web-app": {
"servlet": [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "[email protected]",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
@devinivy
devinivy / push-me.js
Last active August 27, 2016 19:12
hapi with HTTP/2 server push
document.write('i was pushed!');
@devinivy
devinivy / app.conf
Created July 14, 2016 13:06
Nginx reverse-proxy config for many apps
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 June 29, 2016 11:41
SAM meets Redux
  • 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 June 13, 2016 13:28
List the files that .npmignore will pack-up
# 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 12:40
Knex locked connections
'use strict';
const Knex = require('./knex');
const knex = Knex({
dialect: 'postgres',
connection: {
adapter: 'postgresql',
database: 'test',
user: 'postgres'
@devinivy
devinivy / server.js
Created January 20, 2016 03:34
Testing an initialized hapi server
var Hapi = require('hapi');
// Keep track of the server's init state
var internals = {
initialized: false
};
var server = new Hapi.Server();
server.connection();