{"id":19020236,"url":"https://github.com/trailsjs/trailpack-hapi","last_synced_at":"2025-04-23T05:25:23.273Z","repository":{"id":57378912,"uuid":"46914697","full_name":"trailsjs/trailpack-hapi","owner":"trailsjs","description":":package: Hapi.js Trailpack","archived":false,"fork":false,"pushed_at":"2018-04-01T22:42:25.000Z","size":177,"stargazers_count":19,"open_issues_count":7,"forks_count":9,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-25T22:21:51.070Z","etag":null,"topics":["hapi","trailpack","trails","web-server"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trailsjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-26T08:47:54.000Z","updated_at":"2023-11-03T17:12:04.000Z","dependencies_parsed_at":"2022-09-02T21:21:15.563Z","dependency_job_id":null,"html_url":"https://github.com/trailsjs/trailpack-hapi","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-hapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-hapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-hapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-hapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trailsjs","download_url":"https://codeload.github.com/trailsjs/trailpack-hapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223746909,"owners_count":17195810,"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":["hapi","trailpack","trails","web-server"],"created_at":"2024-11-08T20:16:13.796Z","updated_at":"2024-11-08T20:16:14.456Z","avatar_url":"https://github.com/trailsjs.png","language":"JavaScript","readme":"# trailpack-hapi\n\n[![Gitter][gitter-image]][gitter-url]\n[![NPM version][npm-image]][npm-url]\n[![Build status][ci-image]][ci-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n\nHapi Trailpack. This pack binds the routes compiled in [trailpack-router](https://github.com/trailsjs/trailpack-router)\nto a [Hapi Server](http://hapijs.com/api#server).\n\n## Usage\nLoad in your trailpack config.\n\n```js\n// config/main.js\nmodule.exports = {\n  // ...\n  packs: [\n    require('trailpack-core'),\n    require('trailpack-router'),\n    require('trailpack-hapi')\n  ]\n}\n```\n\n### View Config\nChoose a template engine.\n\n```js\n// config/views.js\nmodule.exports = {\n  engine: 'handlebars'\n}\n```\n\nThen simply write your views in a directory called 'templates'! This feature has been tested with Jade and Handlebars.\n\n## Configuration\nSee [`config/web.js`](https://github.com/trailsjs/trails-example-app/blob/master/config/web.js) for an example.\n\n#### `port`\nThe port to listen on. `3000` by default. Can also be set via the `PORT` environment variable.\n\n#### Server configuration\nConfigure your `Hapi.Server` by adding `options` property to the `web.js` config in typical\nHapi.server format. See: http://hapijs.com/api#new-serveroptions\n\n```js\n\n// config/web.js\nmodule.exports = {\n  options: {\n\n    routes: {\n      cors: true\n    }\n  }\n}\n```\n\n#### Hapi Plugins\nRegister your hapi plugins by adding them to the `config/web.js` config in typical Hapi\nplugin format. See: http://hapijs.com/tutorials/plugins#loading-a-plugin\n\n```js\n// config/web.js\nmodule.exports = {\n  plugins: [\n    {\n      register: require('vision'),\n      options: { }\n    },\n    {\n      register: require('inert'),\n      options: { }\n    },\n    {\n      register: require('hapi-auth-hawk'),\n      options: { }\n    }\n    // ...\n  ],\n\n  onPluginsLoaded: function (err) {\n    // Note that `this` is Trails `app` instance\n    this.packs.hapi.server.auth.strategy('default', 'hawk', { getCredentialsFunc: getCredentials });\n  }\n}\n```\n\n#### Hapi Views\n```js\n// config/web.js\nmodule.exports = {\n  views: {\n    engines: {\n      html: require('some-view-engine')\n    },\n    path: 'views'\n  }\n}\n```\n\n#### Static Assets\n```js\n// config/main.js\nmodule.exports = {\n  paths: {\n    ...\n    www: path.resolve(__dirname, '..', 'static')\n    ...\n  }\n}\n```\nThis allows static files such as js or images to be served in the /static directory.\nIf you prefer, feel free to use a name other than 'static'!\n\n#### Multiple Static Assets\n```js\n// config/main.js\nmodule.exports = {\n  paths: {\n    ...\n    www: [\n      {\n        path: path.resolve(__dirname, '..', 'static'),\n        humanUrl: '/admin'\n      },\n      {\n        path: path.resolve(__dirname, '..', 'uploads', 'pictures', 'cats'),\n        humanUrl: '/cats'\n      }\n    ]\n    ...\n  }\n}\n```\nAlso you can make multiple static assets with human url.\nFor example your static files in `/uploads/pictures/cats` with `humanUrl` you url look like `http://example.com/cats`\n`humanUrl` - not require\n\n## Contributing\nWe love contributions! Please check out our [Contributor's Guide](https://github.com/trailsjs/trails/blob/master/.github/CONTRIBUTING.md) for more\ninformation on how our projects are organized and how to get started.\n\n## License\n[MIT](https://github.com/trailsjs/trailpack-hapi/blob/master/LICENSE)\n\n\u003cimg src=\"http://i.imgur.com/dCjNisP.png\"\u003e\n\n[npm-image]: https://img.shields.io/npm/v/trailpack-hapi.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/trailpack-hapi\n[ci-image]: https://img.shields.io/travis/trailsjs/trailpack-hapi/master.svg?style=flat-square\n[ci-url]: https://travis-ci.org/trailsjs/trailpack-hapi\n[daviddm-image]: http://img.shields.io/david/trailsjs/trailpack-hapi.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/trailsjs/trailpack-hapi\n[codeclimate-image]: https://img.shields.io/codeclimate/github/trailsjs/trailpack-hapi.svg?style=flat-square\n[codeclimate-url]: https://codeclimate.com/github/trailsjs/trailpack-hapi\n[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square\n[gitter-url]: https://gitter.im/trailsjs/trails\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-hapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrailsjs%2Ftrailpack-hapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-hapi/lists"}