New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bonniernews/fake-tool-api

Package Overview
Dependencies
Maintainers
33
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonniernews/fake-tool-api - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

37

index.js

@@ -72,2 +72,5 @@ import nock from "nock";

.persist()
.post("/search")
.reply(interceptable(search))
.persist()
.get("/types")

@@ -100,3 +103,3 @@ .reply(interceptable(getTypes))

}
contentByType[type][id] = { updated: new Date().toISOString(), ...content, sequenceNumber: 1 };
contentByType[type][id] = { created: new Date().toISOString(), updated: new Date().toISOString(), ...content, sequenceNumber: 1 };
if (types[type]?.versioned) {

@@ -490,2 +493,32 @@ storeVersion(type, id, { ...contentByType[type][id], updated: new Date().toISOString() });

function search(url, body) {
let matchingContent = Object.keys(contentByType).flatMap((typeName) => {
const ofType = contentByType[typeName];
const ids = Object.keys(ofType);
return ids.map((id) => {
const content = ofType[id];
const hit = {
type: typeName,
id,
title: content.attributes?.name,
};
if (body.returnContent) {
hit.content = content;
}
return hit;
});
});
if (body.q) {
matchingContent = matchingContent.filter((potentialHit) => {
const titleTokens = (potentialHit.title || "").split(" ").map((t) => t.toLowerCase());
return titleTokens.includes(body.q.toLocaleLowerCase());
});
}
return [ 200, { hits: matchingContent, total: matchingContent.length } ];
}
function getTypes() {

@@ -508,3 +541,3 @@ return [ 200, Object.values(types) ];

name: "article",
properties: { attributes: { type: "object", properties: { headline: { type: "string" } } } },
properties: { attributes: { type: "object", properties: { name: { type: "string" }, headline: { type: "string" } } } },
});

@@ -511,0 +544,0 @@ }

2

package.json
{
"name": "@bonniernews/fake-tool-api",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Mocked Bonnier News tool api, for use in automated tests",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc