Installations
npm install @podium/hapi-layout
Developer Guide
Typescript
No
Module System
ESM
Node Version
20.17.0
NPM Version
10.8.3
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
podium-lib
Download Statistics
Total Downloads
12,781
Last Day
1
Last Week
10
Last Month
103
Last Year
2,770
GitHub Statistics
1 Stars
289 Commits
1 Forks
3 Watching
10 Branches
10 Contributors
Bundle Size
8.06 kB
Minified
2.61 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.0.9
Package Id
@podium/hapi-layout@4.0.9
Unpacked Size
14.68 kB
Size
4.33 kB
File Count
5
NPM Version
10.8.3
Node Version
20.17.0
Publised On
23 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
12,781
Last day
0%
1
Compared to previous day
Last week
-16.7%
10
Compared to previous week
Last month
-40.1%
103
Compared to previous month
Last year
-22.5%
2,770
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@podium/hapi-layout
Hapi plugin for @podium/layout.
Module for building @podium/layout servers with hapi. For writing layouts, please see the Podium documentation.
Installation
1$ npm install @podium/hapi-layout @podium/layout
Requirements
The v3.x of this module require Hapi v19 or newer and node v12 or newer. Please use v2.x of this module for Hapi v18 or older.
Simple usage
Build a simple layout server including a single podlet:
1import HapiLayout from '@podium/hapi-layout'; 2import Layout from '@podium/layout'; 3import Hapi from '@hapi/hapi'; 4 5const server = Hapi.Server({ 6 host: 'localhost', 7 port: 7000, 8}); 9 10const layout = new Layout({ 11 pathname: '/', 12 name: 'layout', 13}); 14 15const podlet = layout.client.register({ 16 name: 'myPodlet', 17 uri: 'http://localhost:7100/manifest.json' 18}); 19 20await server.register({ 21 plugin: new HapiLayout(), 22 options: layout, 23}); 24 25server.route({ 26 method: 'GET', 27 path: layout.pathname(), 28 handler: (request, h) => { 29 const incoming = request.app.podium; 30 const result = await podlet.fetch(incoming); 31 return h.podiumSend(result.content); 32 }, 33}); 34 35server.start(); 36console.log("Server running on %s", server.info.uri);
Register plugin
The plugin is registered by passing an instance of this plugin to the hapi
server .register()
method together with an instance of the @podium/layout
class.
1await server.register({ 2 plugin: new HapiLayout(), 3 options: new Layout(), 4});
Request params
On each request @podium/layout will run a set of operations on the request and
create an [incoming] object. The [incoming] object is stored at
request.app.podium
which is accessible inside request handlers.
1server.route({ 2 method: 'GET', 3 path: '/', 4 handler: async (request, h) => { 5 const incoming = request.app.podium; 6 const result = await podlet.fetch(incoming); 7 return h.podiumSend(result.content); 8 }, 9});
Its possible to pass request bound parameters to @podium/context parsers by
setting an object at request.app.params
.
Example: To pass a value to the @podium/context locale parser it should be set
on request.app.params.locale
by a extension executed previously of this
extension.
h.podiumSend(fragment)
This method will wrap the given fragment in a default document template before dispatching.
See document template for further information.
License
Copyright (c) 2019 FINN.no
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish.yml:31
Reason
branch protection is not maximal on development and all release branches
Details
- Info: 'allow deletion' disabled on branch 'main'
- Info: 'force pushes' disabled on branch 'main'
- Info: 'branch protection settings apply to administrators' is required to merge on branch 'main'
- Warn: could not determine whether codeowners review is allowed
- Warn: no status checks found to merge onto branch 'main'
- Warn: PRs are not required to make changes on branch 'main'; or we don't have data to detect it.If you think it might be the latter, make sure to run Scorecard with a PAT or use Repo Rules (that are always public) instead of Branch Protection settings
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/podium-lib/hapi-layout/test.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:44
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:23
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:20
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v4.0.9 not signed: https://api.github.com/repos/podium-lib/hapi-layout/releases/176313321
- Warn: release artifact v4.0.8 not signed: https://api.github.com/repos/podium-lib/hapi-layout/releases/174052060
- Warn: release artifact v4.0.7 not signed: https://api.github.com/repos/podium-lib/hapi-layout/releases/170795386
- Warn: release artifact v4.0.6 not signed: https://api.github.com/repos/podium-lib/hapi-layout/releases/157559350
- Warn: release artifact v4.0.5 not signed: https://api.github.com/repos/podium-lib/hapi-layout/releases/155431704
- Warn: release artifact v4.0.9 does not have provenance: https://api.github.com/repos/podium-lib/hapi-layout/releases/176313321
- Warn: release artifact v4.0.8 does not have provenance: https://api.github.com/repos/podium-lib/hapi-layout/releases/174052060
- Warn: release artifact v4.0.7 does not have provenance: https://api.github.com/repos/podium-lib/hapi-layout/releases/170795386
- Warn: release artifact v4.0.6 does not have provenance: https://api.github.com/repos/podium-lib/hapi-layout/releases/157559350
- Warn: release artifact v4.0.5 does not have provenance: https://api.github.com/repos/podium-lib/hapi-layout/releases/155431704
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 18 are checked with a SAST tool
Score
3.8
/10
Last Scanned on 2025-01-06
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More