{"id":13516317,"url":"https://github.com/hapipal/boilerplate","last_synced_at":"2025-08-22T10:35:23.361Z","repository":{"id":51386128,"uuid":"26237751","full_name":"hapipal/boilerplate","owner":"hapipal","description":"A friendly, proven starting place for your next hapi plugin or deployment","archived":false,"fork":false,"pushed_at":"2023-12-17T08:41:50.000Z","size":305,"stargazers_count":184,"open_issues_count":2,"forks_count":28,"subscribers_count":10,"default_branch":"pal","last_synced_at":"2025-03-30T22:41:44.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hapipal.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hapipal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-11-05T20:13:42.000Z","updated_at":"2025-01-23T23:45:27.000Z","dependencies_parsed_at":"2024-01-13T19:26:44.202Z","dependency_job_id":"a81de010-ac35-435c-b83b-e0dc7a051579","html_url":"https://github.com/hapipal/boilerplate","commit_stats":null,"previous_names":[],"tags_count":94,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Fboilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Fboilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Fboilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapipal%2Fboilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapipal","download_url":"https://codeload.github.com/hapipal/boilerplate/tar.gz/refs/heads/pal","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252548477,"owners_count":21766185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:01:21.298Z","updated_at":"2025-05-05T17:58:54.637Z","avatar_url":"https://github.com/hapipal.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://hapipal.com\"\u003e\u003cimg src=\"https://imgur.com/shaShr0.png\" alt=\"hapi pal\" width=\"200\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003ch3 align=\"center\"\u003e\n  the pal boilerplate\n\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n  A friendly, proven starting place for your next hapi plugin or deployment\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://join.slack.com/t/hapihour/shared_invite/zt-g5ortpsk-ErlnRA2rUcPIWES21oXBOg\"\u003e\n    \u003cimg alt=\"Slack: hapihour/hapipal\" src=\"https://img.shields.io/badge/slack-hapihour/hapipal-orange.svg?logo=slack\u0026style=flat-square\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nLead Maintainer - [Devin Ivy](https://github.com/devinivy)\n\n**Features**\n - Supports hapi v20+ and Node.js v12+.\n - Setup with [hpal-debug](https://github.com/hapipal/hpal-debug) hapi CLI debugging tools.\n - Provides clear, customizable hapi file and folder conventions using [haute-couture](https://github.com/hapipal/haute-couture).\n - Designed to allow you to deploy your plugin on its own or as part of a larger application.\n - Textbook integrations with Objection ORM, Swagger UI, and more via [flavors](#flavors).\n - Fully setup with a [lab](https://github.com/hapijs/lab) test suite and [eslint](https://github.com/eslint/eslint) configuration.\n - Powerful [12factor](https://12factor.net/)-oriented deployment configuration using\n [confidence](https://github.com/hapipal/confidence) and [dotenv](https://github.com/motdotla/dotenv).\n - Up-to-date versions of all dependencies.\n - Follows established hapi best practices out of the box.\n\n## Getting Started\n\u003e If you're interested to hear about why we came together to create pal, check out our Medium article [Introducing hapi pal](https://medium.com/@hapipal/introducing-hapi-pal-550c13f30c5b).\n\u003e\n\u003e Below is a simple tutorial to create your first route.  For a more in-depth look at the pal ecosystem, database integration, etc. see [our official starting guide](https://hapipal.com/getting-started).\n\n```sh\nnpm init @hapipal my-project\ncd ./my-project\nnpm install\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e \u003ci\u003e(click to expand)\u003c/i\u003e\n\nPerhaps you'd like to perform a manual installation without any fancy CLI tools—that's possible too!  Click [here](https://github.com/hapipal/boilerplate/generate) to create a new repository using this one as a template.  Or expand to find instructions for installation using only git.\n  \u003c/summary\u003e\n\n```sh\ngit clone --depth=1 --origin=pal --branch=pal git@github.com:hapipal/boilerplate.git my-project\ncd my-project\ngit checkout --orphan master # New branch without history\nnpm init\nnpm install\n```\n\u003c/details\u003e\n\n#### Make your first commit to init project history\n```sh\ngit add --all\ngit commit -m \"Initial commit\"\n```\n\n### Creating your first route\nHere we'll will pick-up where we left off (inside a new pal project folder with all dependencies installed) and create a route that serves a random quotation.\n\n```sh\n# hpal comes installed as a dev dependency,\n# so you can invoke within your project using npx.\n\nnpx hpal make route random-quotation\n# Wrote lib/routes/random-quotation.js\n```\n\nNow open the newly-created file in your favorite text editor.  You should find something like this indicating which parts of the route configuration you need to fill-in, and the signature of a route handler.\n```js\n// lib/routes/random-quotation.js\n'use strict';\n\nmodule.exports = {\n    method: '',\n    path: '',\n    options: {\n        handler: async (request, h) =\u003e {}\n    }\n};\n```\n\nLet's fill-in the `method` and `path` so that the route we hit is at `get /random-quotation`, and write the `handler` to serve a random quotation from a list.  Our handler doesn't need to do anything asynchronous or use the [response toolkit](https://hapi.dev/api/#response-toolkit), so the route handler's signature appears a little simpler than before.\n\n```js\n// lib/routes/random-quotation.js\n'use strict';\n\nmodule.exports = {\n    method: 'get',\n    path: '/random-quotation',\n    options: {\n        handler: (request) =\u003e {\n\n            const quotations = [\n                {\n                    quotation: 'I would rather fish any day than go to heaven.',\n                    saidBy: 'Cornelia \"Fly Rod\" Crosby'\n                },\n                {\n                    quotation: 'I want a turkey nut yogurt cane!',\n                    saidBy: 'Stimpy'\n                },\n                {\n                    quotation: 'Streams make programming in node simple, elegant, and composable.',\n                    saidBy: 'substack'\n                }\n            ];\n\n            const randomIndex = Math.floor(Math.random() * quotations.length);\n\n            return quotations[randomIndex];\n        }\n    }\n};\n```\n\nNow start your server and try hitting it in-browser or over `curl`.\n```sh\nnpm start\n# Server started at http://0.0.0.0:3000\n```\n\n```sh\ncurl http://localhost:3000/random-quotation\n# {\"quotation\":\"I would rather fish any day than go to heaven.\",\"saidBy\":\"Cornelia \\\"Fly Rod\\\" Crosby\"}\n```\n\nThis common practice of restarting the server and curling can be simplified by leveraging [hpal-debug](https://github.com/hapipal/hpal-debug)'s curl command, which allows you to hit a route using its name _without having a started server_!\n```sh\nnpx hpal run debug:curl random-quotation\n# { quotation: 'I want a turkey nut yogurt cane!', saidBy: 'Stimpy' }\n```\n\n**And that's it!**  Keep in mind that if you run into anything along the way that's unfamiliar to you, you can always search the hapi API documentation using `hpal`.\n\n```sh\nnpx hpal docs route.options.handler\n```\n\n## Flavors\n\nhapi pal makes it easy to use the boilerplate as a jumping-off point for several different types of projects, which we call \"flavors\" (:lollipop: :fries: :doughnut: :poultry_leg:).  Flavors may be mixed and matched, or skipped altogether.  Only utilize them if they'll be useful to you!\n\nThey're simple little buggers.  We've simply tagged commits that we think will contain useful code patches depending on what direction you'd like to take your project.\n\n**NOTE** Since flavors are just tagged commits, please be aware that you may experience merge conflicts when mixing flavors together.\n\n**Pull down the latest flavors**\n\nIf you used the `hpal` CLI to create a new project then this should already be done for you.  But you can always do it manually as well– simply pull down git tags from the `pal` remote.\n\n```sh\ngit fetch pal --tags\n```\n\n**Use some flavors**\n```sh\ngit cherry-pick flavor-one flavor-two\n```\n\n### Available flavors\n#### Swagger\n\u003e `git cherry-pick swagger` [[view](https://github.com/hapipal/boilerplate/commit/swagger)]\n\nIntegrates [hapi-swagger](https://github.com/glennjones/hapi-swagger) onto the server with a suitable default configuration.  If you need to customize the swagger templates, then use hapi-swagger's [`templates` option](https://github.com/glennjones/hapi-swagger/blob/master/optionsreference.md#ui) to serve your own custom version of the [Swagger UI page templates](https://github.com/glennjones/hapi-swagger/tree/master/templates).\n\n#### Objection ORM\n\u003e `git cherry-pick objection` [[view](https://github.com/hapipal/boilerplate/commit/objection)]\n\nIntegrates [Objection ORM](https://github.com/Vincit/objection.js) into your server and plugin using the hapi plugin [schwifty](https://github.com/hapipal/schwifty).  This is a great way to get started with a SQL-oriented plugin.  Adds a `models/` directory to your plugin where Objection models should be placed, and a `migrations/` directory where your migrations should be placed.  Configured to work with SQLite out of the box.\n\n##### Using the knex CLI\nThe knex CLI is installed locally, and a [knexfile](http://knexjs.org/#knexfile) is added to the root of your project so that the connection info is available to it.  To use the CLI, you may run it using npx.\n\nFor example, to create a new migration:\n```\nnpx knex migrate:make my-first-migration\n```\n\n#### Deployment\n\u003e `git cherry-pick deployment` [[view](https://github.com/hapipal/boilerplate/commit/deployment)]\n\nBy default all deployment-oriented dependencies are placed in package.json's `devDependencies`.  This flavor pulls all the default deployment dependencies up into `dependencies`.  This is useful when you want to use pal primarily as a deployment rather than a harness to author an application plugin.  Note that the other flavors always place their deployment-oriented dependencies in `devDependencies`, and that you will have to pull those into `dependencies` separately.\n\n#### Docker\n\u003e `git cherry-pick docker` [[view](https://github.com/hapipal/boilerplate/commit/docker)]\n\nSets up a Dockerfile and docker-compose.yml file for usage in local development. The Dockerfile is fully production ready, and just needs to integrated into a build system of your choice that supports Docker 17.05 or higher, and Docker Compose files with version v3.4. This flavor also introduces two `build` and four `docker` npm scripts, which are described in the [`DOCKER.md`](https://github.com/hapipal/boilerplate/blob/flavor-docker/DOCKER.md) file that comes with the flavor.\n\n#### Fancy Templated Site\n\u003e `git cherry-pick fancy-templated-site` [[view](https://github.com/hapipal/boilerplate/commit/fancy-templated-site)]\n\nSets-up [handlebars](https://github.com/wycats/handlebars.js/) templating with a useful layout and openly serves the `lib/public` directory, which contains folders to place javascript and CSS.  This flavor introduces several npm scripts: one to minify front-end javascript with [uglify](https://github.com/mishoo/UglifyJS2) (`npm run build:js`); one to minify CSS with [PostCSS](https://github.com/postcss/postcss)/[cssnano](https://github.com/ben-eb/cssnano) (`npm run build:css`); and one to do both (`npm run build`).  A plugin option `developmentMode` controls whether the minified or un-minified javascript and CSS are served on the page.  The `developmentMode` is configured to be active when `NODE_ENV` is not `production`.\n\nThis flavor additionally incorporates [browserify](https://github.com/substack/node-browserify), [Sass](https://www.npmjs.com/package/node-sass), and [Browsersync](https://github.com/Browsersync/browser-sync).  As such, there are scripts to support the pre-building process: one to pre-build javascript from Node.js-style to ES5 using browserify and [Babel](https://github.com/babel/babel) (`npm run prebuild:js`); and one to pre-build CSS from SCSS using node-sass.  When `developmentMode` is active browser-sync will rebuild SCSS and Node.js-style javascript, then reload the page or stylesheets as necessary.\n\n### Versioning\n\u003e Note: most of the time you'll be pulling in flavors at the time you install the pal boilerplate, in which case you don't need to worry much about flavor versioning.\n\nIt's worth noting that over time these flavor tags may point to different commits.  The flavors are updated to keep-up with the latest pal boilerplate.  For this reason, as flavor tags move, we leave static versioned tags for your convenience.  Tags are named as such:\n```\n\u003cflavor-name\u003e-v\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e\n```\nwhere:\n\n - `\u003cflavor-name\u003e` - the name of this flavor.  Identical to the unversioned tag for this flavor.\n - `\u003cmajor\u003e` - the major version of the flavor, identical to the major version of the pal boilerplate that it is compatible with.\n - `\u003cminor\u003e` - the minor version of the flavor, bumped when a feature is added to the flavor (rare), but more typically when its dependencies are updated.\n - `\u003cpatch\u003e` - the patch version of the flavor, bumped when a bug is fixed in the flavor, or the flavor requires update to account for bugs in the version of the pal boilerplate with which it is compatible.\n\nFor example the first version of the \"custom swagger\" flavor is:\n```\ncustom-swagger-v1.0.0\n```\n\n\u003cbr\u003e\n\u003ca href='https://hapipal.com'\u003e\n  \u003cdiv align='center'\u003e\n    \u003cimg width='280' src='https://imgur.com/rWnkFOO.png' /\u003e\n  \u003c/div\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Fboilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapipal%2Fboilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapipal%2Fboilerplate/lists"}