Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bonniernews/b0rker

Package Overview
Dependencies
Maintainers
0
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonniernews/b0rker - npm Package Compare versions

Comparing version 10.2.1 to 10.3.0

lib/validator.js

6

lib/error-handler.js

@@ -37,2 +37,8 @@ import { logger } from "lu-logger";

if (err.validation) {
logger.error(`Validation error: ${err.message}`);
await sendToDlx(req, `Validation error: ${err.message}`);
return res.status(200).send({ type: "validation_error", message: err.message });
}
logger.error(`Unexpected error ${err.message}: ${err.stack}`);

@@ -39,0 +45,0 @@

11

lib/recipe-repo.js

@@ -15,3 +15,3 @@ import joi from "joi";

const sequenceSchema = joi.object().keys({
namespace: joi.string().valid("event", "action", "sequence", "sub-sequence").required(),
namespace: joi.string().valid("action", "sequence", "sub-sequence").required(),
name: joi

@@ -26,11 +26,4 @@ .string()

.items(joi.object().length(1)),
executionDelay: joi.alternatives().conditional("namespace", {
is: "sub-sequence",
then: joi
.number()
.min(0)
.max(60 * 60 * 1000),
}),
unrecoverable: joi.array().items(joi.object().length(1)),
useParentCorrelationId: joi.boolean().default(false),
schema: joi.object().schema().optional(),
});

@@ -37,0 +30,0 @@

@@ -5,10 +5,11 @@ import { Router as expressRouter } from "express";

import buildContext from "./context.js";
import { sendToDlx } from "./dlx.js";
import { errorHandler } from "./error-handler.js";
import jobStorage from "./job-storage/index.js";
import { router as middlewareRouter } from "./middleware/index.js";
import { errorHandler } from "./error-handler.js";
import { publishTask, publishTasksBulk } from "./publish-task.js";
import resend from "./resend.js";
import { appendData, buildNextKeyMapper, buildUrl, keyToUrl, sequenceIterator } from "./utils/sequences.js";
import buildContext from "./context.js";
import jobStorage from "./job-storage/index.js";
import { sendToDlx } from "./dlx.js";
import resend from "./resend.js";
import validate from "./validator.js";

@@ -40,5 +41,5 @@ // Ugly hack to make lu-logger accept the same interface as pino.

function buildCloudTaskSequenceRoutes(router, { namespace, name, sequence, unrecoverable }, nextKeyMapper) {
function buildCloudTaskSequenceRoutes(router, { namespace, name, sequence, unrecoverable, schema }, nextKeyMapper) {
for (const { key, func } of sequenceIterator(sequence)) {
router.post(buildUrl(namespace, name, key), messageHandler(func, nextKeyMapper(`${namespace}.${name}.${key}`)));
router.post(buildUrl(namespace, name, key), messageHandler(func, nextKeyMapper(`${namespace}.${name}.${key}`), schema));
}

@@ -67,4 +68,6 @@ // Allow to start a sequence/sub-sequence by posting to the sequence name

function messageHandler(func, { nextKey, queue } = {}) {
function messageHandler(func, { nextKey, queue } = {}, schema) {
return async (req, res) => {
const body = schema ? validate(req.body, schema) : req.body;
const {

@@ -81,5 +84,5 @@ key,

const result = await func(req.body, context);
const result = await func(body, context);
const nextBody = appendData(req.body, result);
const nextBody = appendData(body, result);

@@ -141,3 +144,3 @@ if (result?.type === "trigger") {

}
} else if ([ "sequence", "event" ].some((s) => result.key.startsWith(s))) {
} else if (result.key.startsWith("sequence")) {
// If we trigger another main sequence, we fire-and-forget and continue with the main sequence immediately

@@ -144,0 +147,0 @@ await triggerOtherSequences(body, result, {

{
"name": "@bonniernews/b0rker",
"version": "10.2.1",
"version": "10.3.0",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=18"

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