Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
hal-browser
Advanced tools
This package provides a middleware for HAL APIs.
The middleware looks for HAL and JSON responses, and automatically converts them into a HTML interface if a browser access them.
It does so via the Accept: text/html
header. If this header is not provided,
the middleware does nothing.
An example. If a API normally returns the following HAL format:
{
"_links": {
"self": {
"href": "/testing"
},
"previous": {
"href": "/testing/?page=1",
"title": "Previous page"
},
"next": {
"href": "/testing/?page=2",
"title": "Next page"
},
"author": {
"href": "https://evertpot.com",
"title": "Evert Pot"
},
"help": {
"href": "https://google.com/",
"title": "Google it"
},
"search": {
"href": "https://google.com/"
},
"edit": {
"href": "/testing"
},
"create-form": {
"href": "/testing"
}
},
"msg": "Hello world!",
"version": "0.2.0",
"name": "test resource!"
}
The browser will automatically convert it to this HTML format:
npm install hal-browser
import { Application } from 'curveball/@core';
import halBrowser from 'hal-browser';
const app = new Application();
app.use(halBrowser({
title: 'HAL Browser',
});
The HAL browser ships with 2 really basic stylesheets in the styles
directory:
main.css
- Main interface csssolarized-dark.css
- A syntax highlighting stylesheet lifted from the
Highlight.js project, and originally created by (c) Jeremy HullFor best effect you'll want both stylesheets!
TODO
TODO
The halBrowser function takes an options object, which can take the following settings:
title
- Change the main title.stylesheets
- Provide your own stylesheets. This is an array of strings.
these are relative urls, and they are automatically expanded based on the
assetBaseUrl
setting.navigationLinks
- Specify (or remove) links that show up in the top
navigation.serveAssets
- by default the browser plugin will also take responsibility
for serving icons and stylesheet. If you're hosting these assets elsewhere,
set this to false
.defaultLinks
- A list of links that will show up by default, whether or not
they were specified by the API. By default a home
link is added here.hiddenRels
- List of relationship types that will be hidden from the user by
default. This can be used for links that are simply not interesting for a human
to see. (default: ['self', 'curies']
.Example:
app.use(halBrowser({
title: 'My API',
stylesheets: [
'/my-stylesheet.css',
],
// This should end with a / generally.
assetBaseUrl: 'http://some-cdn.example.org/',
navigationLinks: {
// Create new 'author' button
'author' : {
// optional css class, by default this will be `rel-author`
cssClass: 'rel-blabla',
// Optional title to show when hovering over button
defaultTitle: 'Click me',
// Override icon. Also optional
icon: 'icons/foobar.svg',
},
// passing 'true' will use default setting for the button
'help' : true,
// passing 'null' will remove the icon, if it was a default icon
'up': null,
},
defaultLinks: [
// Every page will have a 'help' link
{
rel: 'help',
href: 'https://example.org/help',
title: 'Support',
}
],
});
alternate
links and create an appropriate interface for allowing
users to select them.text/csv
as a table.search
links and show a search field._embedded
.Last-Modified
FAQs
A HAL browser middleware
The npm package hal-browser receives a total of 2 weekly downloads. As such, hal-browser popularity was classified as not popular.
We found that hal-browser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.