{"id":47712037,"url":"https://github.com/inyourtime/hapi-scalar","last_synced_at":"2026-04-02T18:36:33.205Z","repository":{"id":309553250,"uuid":"1032552397","full_name":"inyourtime/hapi-scalar","owner":"inyourtime","description":"Hapi plugin that serves API documentation using Scalar, with built-in support for hapi-swagger.","archived":false,"fork":false,"pushed_at":"2026-01-13T10:59:26.000Z","size":26,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T13:45:44.860Z","etag":null,"topics":["api","documentation","hapi","hapi-plugin","hapijs","openapi","scalar","swagger"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hapi-scalar","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/inyourtime.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-05T13:25:46.000Z","updated_at":"2026-01-13T10:59:26.000Z","dependencies_parsed_at":"2025-08-12T15:28:51.449Z","dependency_job_id":"3448556e-aa51-4761-96a6-837eecac4588","html_url":"https://github.com/inyourtime/hapi-scalar","commit_stats":null,"previous_names":["inyourtime/hapi-scalar"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/inyourtime/hapi-scalar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Fhapi-scalar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Fhapi-scalar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Fhapi-scalar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Fhapi-scalar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inyourtime","download_url":"https://codeload.github.com/inyourtime/hapi-scalar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inyourtime%2Fhapi-scalar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31313005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","documentation","hapi","hapi-plugin","hapijs","openapi","scalar","swagger"],"created_at":"2026-04-02T18:36:32.590Z","updated_at":"2026-04-02T18:36:33.182Z","avatar_url":"https://github.com/inyourtime.png","language":"JavaScript","readme":"# hapi-scalar\n\n[![CI](https://github.com/inyourtime/hapi-scalar/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/inyourtime/hapi-scalar/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/hapi-scalar.svg?style=flat)](https://www.npmjs.com/package/hapi-scalar)\n[![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat\u0026logo=biome)](https://biomejs.dev)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](./LICENSE)\n\nA Hapi plugin that serves [Scalar](https://github.com/scalar/scalar) API documentation UI for your Hapi server. It provides a modern, interactive OpenAPI/Swagger documentation interface that can be used standalone or alongside [hapi-swagger](https://github.com/glennjones/hapi-swagger).\n\n## Features\n\n- Serves the beautiful Scalar UI at a configurable route (default: `/scalar`)\n- Auto-detects and integrates with hapi-swagger configurations\n- Supports both static and dynamic configuration\n- TypeScript support\n\n## Installation\n\n```bash\nnpm install hapi-scalar\n```\n\n## Quick Start\n\n### Standalone Usage\n\n```js\nimport Hapi from '@hapi/hapi'\nimport hapiScalar from 'hapi-scalar'\n\nconst server = Hapi.server({\n  port: 3000,\n  host: 'localhost',\n})\n\nawait server.register({\n  plugin: hapiScalar,\n  options: {\n    scalarConfig: {\n      url: '/path/to/your/openapi.json', // Your OpenAPI spec URL\n    },\n  },\n})\n\nawait server.start()\nconsole.log('Documentation available at: http://localhost:3000/scalar')\n```\n\nVisit [http://localhost:3000/scalar](http://localhost:3000/scalar) to view the Scalar UI.\n\n### With hapi-swagger\n\nWhen used with hapi-swagger, the plugin automatically detects your OpenAPI/Swagger configuration:\n\n```js\nimport Hapi from '@hapi/hapi'\nimport Inert from '@hapi/inert'\nimport Vision from '@hapi/vision'\nimport HapiSwagger from 'hapi-swagger'\nimport hapiScalar from 'hapi-scalar'\n\nconst server = Hapi.server({\n  port: 3000,\n  host: 'localhost',\n})\n\n// Configure hapi-swagger\nconst swaggerOptions = {\n  info: {\n    title: 'My API Documentation',\n    version: '1.0.0',\n    description: 'This is my awesome API',\n  },\n  OAS: 'v3.0', // Use OpenAPI 3.0\n}\n\n// Register dependencies and hapi-swagger\nawait server.register([\n  Inert,\n  Vision,\n  { plugin: HapiSwagger, options: swaggerOptions },\n])\n\n// Register hapi-scalar - it will automatically use the OpenAPI spec from hapi-swagger\nawait server.register({\n  plugin: hapiScalar,\n  options: {\n    // Optional: customize the documentation route\n    routePrefix: '/docs',\n    // Optional: customize Scalar UI\n    scalarConfig: {\n      hideClientButton: false,\n      theme: 'purple',\n    },\n  },\n})\n\nawait server.start()\nconsole.log('API Documentation available at: http://localhost:3000/docs')\n```\n\n\u003e Note: When hapi-swagger is registered, hapi-scalar automatically uses `/openapi.json` if `OAS` is `'v3.0'`, otherwise `/swagger.json`. You don’t need to set `scalarConfig.url` manually.\n\n## Configuration Options\n\n### Plugin Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `routePrefix` | `string` | `'/scalar'` | The path where the Scalar documentation UI will be served. |\n| `scalarConfig` | `object \\| function(request) =\u003e object \\| Promise\u003cobject\u003e` | `{}` | Configuration passed to the Scalar UI. Can be a static object or a dynamic function that receives the Hapi request. |\n\n**Example:**\n\n```js\nawait server.register({\n  plugin: hapiScalar,\n  options: {\n    routePrefix: '/docs',           // → http://localhost:3000/docs\n    scalarConfig: { /* ... */ },    // Scalar UI configuration\n  },\n})\n```\n\nThe `scalarConfig` object supports all [Scalar configuration options](https://github.com/scalar/scalar/blob/main/documentation/configuration.md).\n\n### Dynamic Configuration\n\nUse a function to provide dynamic configuration based on the request:\n\n```js\noptions: {\n  scalarConfig: (request) =\u003e {\n    return { \n      theme: request.query.theme ?? 'default',\n      hideClientButton: true\n    }\n  }\n}\n\n// You can also return a Promise or use an async function:\noptions: {\n  scalarConfig: async (request) =\u003e {\n    // e.g., fetch from a database or remote config service\n    const url = request.query.specUrl || '/openapi.json'\n    return { url }\n  },\n}\n```\n\n## TypeScript\n\nType definitions are included. Example:\n\n```ts\nimport Hapi from '@hapi/hapi'\nimport hapiScalar from 'hapi-scalar'\n\nconst options: hapiScalar.RegisterOptions = {\n  routePrefix: '/scalar',\n  scalarConfig: {\n    url: '/openapi.json',\n    hideClientButton: true,\n  },\n}\n\nawait server.register({\n  plugin: hapiScalar,\n  options,\n})\n```\n\n## Contributing\n\nContributions are welcome. Please open an issue or pull request.\n\n## License\n\nMIT\n\n---\n\n## Related Projects\n\n- [Scalar](https://github.com/scalar/scalar) - The beautiful API documentation UI\n- [hapi-swagger](https://github.com/glennjones/hapi-swagger) - Swagger/OpenAPI plugin for Hapi\n- [@hapi/hapi](https://github.com/hapijs/hapi) - The Hapi web framework\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finyourtime%2Fhapi-scalar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finyourtime%2Fhapi-scalar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finyourtime%2Fhapi-scalar/lists"}