
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@0x57/hono-array-map
Advanced tools
Hono middleware that allows consumers to pass ?list=map
to your API in order to transform arrays of uniquely identifiable objects to a keyed object. This is useful for frontend applications that store information this way as cached state.
For example, say your API returns this JSON result:
GET /search
:
{
"results": [
{ "id": 1, "name": "Ian" },
{ "id": 2, "name": "Leah" }
]
}
By instead requesting GET /search?list=map
this middleware will transform the JSON response to this:
{
"results": {
"1": { "id": 1, "name": "Ian" },
"2": { "id": 2, "name": "Leah" }
}
}
Install the package with your package manager of choice
npm i @0x57/hono-array-map
Then apply the Hono middleware
import { arrayMap } from "@0x57/hono-array-map";
import { Hono } from "hono";
const app = new Hono();
app.use("*", arrayMap());
This middleware exposes two options: query
and extractor
.
query?: string
(default: list
)Set this option to change the query parameter the middleware reads from. By default, the middleware checks for ?list=map
. By setting query
to array
, consumers would instead pass array=map
.
extractor?: (value: JSONObject) => string
Set this option to override the builtin key extractor. If your API uses guid
instead of id
as the entity unique identifier, you would use something like this to extract the list identifier:
import { arrayMap, type JSONObject } from "@0x57/hono-camel-snake";
import { Hono } from "hono";
const app = new Hono();
app.use(
"*",
arrayMap({
extractor: (value: JSONObject) => {
if ("guid" in value) {
if (typeof value.guid === "string") {
return value.guid;
}
if (typeof value.guid === "number") {
return value.guid.toString();
}
}
return "unknown";
},
}),
);
FAQs
Unknown package
The npm package @0x57/hono-array-map receives a total of 532 weekly downloads. As such, @0x57/hono-array-map popularity was classified as not popular.
We found that @0x57/hono-array-map demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.