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

enonic-fp

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-fp - npm Package Compare versions

Comparing version 0.3.0-beta3 to 0.3.0-beta4

7

controller.d.ts

@@ -21,3 +21,8 @@ import { Request, Response, ResponseType } from "enonic-types/controller";

*/
export declare function errorResponse(req?: Request, i18nPrefix?: string): AsErrorResponse;
export declare function errorResponse(req?: Request): AsErrorResponse;
export declare function errorResponse(params: ErrorResponseParams): AsErrorResponse;
export interface ErrorResponseParams {
readonly req?: Request;
readonly i18nPrefix?: string;
}
/**

@@ -24,0 +29,0 @@ * Creates a Response based on a thymeleaf view, and an EnonicError

25

controller.js

@@ -42,17 +42,17 @@ "use strict";

exports.badGateway = asResponseFromStatus(502);
/**
* Returns an error response where the "title"-field is translated with i18nLib.localize()
*/
function errorResponse(req, i18nPrefix) {
if (i18nPrefix === void 0) { i18nPrefix = 'errors'; }
function errorResponse(paramsOrReq) {
var params = isRequest(paramsOrReq)
? { req: paramsOrReq }
: paramsOrReq;
return function (err, extras) {
var _a, _b;
if (extras === void 0) { extras = {}; }
var result = {
type: err.type,
title: translateField(i18nPrefix, "title", err),
instance: req === null || req === void 0 ? void 0 : req.path,
title: translateField("title", err, params === null || params === void 0 ? void 0 : params.i18nPrefix),
instance: (_a = params === null || params === void 0 ? void 0 : params.req) === null || _a === void 0 ? void 0 : _a.path,
status: err.status,
detail: translateField(i18nPrefix, "detail", err),
detail: translateField("detail", err, params === null || params === void 0 ? void 0 : params.i18nPrefix),
// don't expose server internals on live site
errors: (err.status >= 500 && (req === null || req === void 0 ? void 0 : req.mode) !== 'live')
errors: (err.status >= 500 && ((_b = params === null || params === void 0 ? void 0 : params.req) === null || _b === void 0 ? void 0 : _b.mode) !== 'live')
? err.errors

@@ -65,3 +65,8 @@ : undefined

exports.errorResponse = errorResponse;
function translateField(i18nPrefix, fieldName, err) {
function isRequest(value) {
var req = value;
return req.method !== undefined && req.url !== undefined;
}
function translateField(fieldName, err, i18nPrefix) {
if (i18nPrefix === void 0) { i18nPrefix = "errors"; }
var typeString = utils_1.substringAfter(err.type, "/");

@@ -68,0 +73,0 @@ // keys to try to look up in order

{
"name": "enonic-fp",
"version": "0.3.0-beta3",
"version": "0.3.0-beta4",
"sideEffects": false,
"description": "Functional programming helpers for Enonic XP",
"scripts": {
"clean": "rimraf ./*.d.ts && rimraf ./*.js",
"clean": "rimraf ./*.d.ts ./*.js",
"build": "npm run clean && tsc",

@@ -9,0 +9,0 @@ "lint": "eslint --fix 'src/**/*.ts'",

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