### Serve Static Files from Tar with Hapi.js Source: https://github.com/kanongil/tarm/blob/master/README.md Demonstrates setting up a hapi.js server to serve static assets from a tar file using the `tarmount` handler. Requires `@hapi/inert` registration. ```javascript const Path = require('path'); const Hapi = require('@hapi/hapi'); const Inert = require('@hapi/inert'); const Tarm = require('tarm'); const server = Hapi.Server({ port: 3000 }); const provision = async () => { await server.register([Inert, Tarm]); server.route({ method: 'GET', path: '/{param*}', handler: { tarmount: { path: Path.join(__dirname, 'site.tar') } } }); await server.start(); console.log('Server running at:', server.info.uri); }; provision(); ``` -------------------------------- ### tarmount Handler Configuration Source: https://github.com/kanongil/tarm/blob/master/README.md Details the configuration options for the `tarmount` route handler in hapi.js, enabling serving static content from tar archives. Includes path resolution, hidden file serving, and ETag calculation methods. ```APIDOC tarmount Handler Configuration Description: Generates a directory endpoint for serving static content from a tar file. Usage: Routes using the directory handler must include a path parameter at the end of the path string (e.g. `/path/to/somewhere/{param}`). The parameter name does not matter. The parameter can use any of the parameter options (e.g. `{param}` for one level files only, `{param?}` for one level files or the directory root, `{param*}` for any level, or `{param*3}` for a specific level). If additional path parameters are present, they are ignored for the purpose of selecting the tar file resource. Options: path: (required) the tar file path (relative paths are resolved based on the route [`files`](https://github.com/hapijs/hapi/blob/master/API.md#route.config.files) configuration). Value can be: - a single path string pointing to the tar file. - an array of path strings. Each path will be attempted in order until a match is found. - a function with the signature `function(request)` which returns the path string or an array of path strings. Any thrown error is passed back to the client in the response. showHidden: (optional) determines if hidden files will be shown and served. - type: boolean - default: false etagMethod: (optional) specifies the method used to calculate the `ETag` header response. Available values: - 'hash': SHA1 sum of the file contents, suitable for distributed deployments. Default value. - 'simple': Hex encoded size and modification date, suitable when files are stored on a single server. - false: Disable ETag computation. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.