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

enonic-wizardry

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-wizardry - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

6

es6/controller.d.ts

@@ -1,3 +0,7 @@

import { Response } from "enonic-fp/lib/common";
import { Error, ErrorKey, Response } from "enonic-fp/lib/common";
export declare const defaultStatusNumbers: {
[key in ErrorKey]: number;
};
export declare function status(status: number, body?: string | object): Response;
export declare function errorResponse(i18nPrefix: string): (err: Error) => Response;
export declare const ok: (body: any) => Response;

@@ -4,0 +8,0 @@ export declare const created: (body: any) => Response;

@@ -0,1 +1,13 @@

import { localize } from "enonic-fp/lib/i18n";
import { getOrElse } from 'fp-ts/lib/Option';
export var defaultStatusNumbers = {
"BadRequestError": 400,
"UnauthorizedError": 401,
"ForbiddenError": 403,
"NotFoundError": 404,
"MethodNotAllowedError": 405,
"InternalServerError": 500,
"BadGatewayError": 502,
"PublishError": 500,
};
function contentType(body) {

@@ -13,2 +25,11 @@ return (typeof body === "string")

}
export function errorResponse(i18nPrefix) {
return function (err) {
var i18nKey = i18nPrefix + "." + err.errorKey;
return status(defaultStatusNumbers[err.errorKey], {
message: getOrElse(function () { return i18nKey; })(localize({ key: i18nKey })),
debug: String(err)
});
};
}
export var ok = function (body) { return status(200, body); };

@@ -15,0 +36,0 @@ export var created = function (body) { return status(201, body); };

@@ -1,3 +0,7 @@

import { Response } from "enonic-fp/lib/common";
import { Error, ErrorKey, Response } from "enonic-fp/lib/common";
export declare const defaultStatusNumbers: {
[key in ErrorKey]: number;
};
export declare function status(status: number, body?: string | object): Response;
export declare function errorResponse(i18nPrefix: string): (err: Error) => Response;
export declare const ok: (body: any) => Response;

@@ -4,0 +8,0 @@ export declare const created: (body: any) => Response;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var i18n_1 = require("enonic-fp/lib/i18n");
var Option_1 = require("fp-ts/lib/Option");
exports.defaultStatusNumbers = {
"BadRequestError": 400,
"UnauthorizedError": 401,
"ForbiddenError": 403,
"NotFoundError": 404,
"MethodNotAllowedError": 405,
"InternalServerError": 500,
"BadGatewayError": 502,
"PublishError": 500,
};
function contentType(body) {

@@ -16,2 +28,12 @@ return (typeof body === "string")

exports.status = status;
function errorResponse(i18nPrefix) {
return function (err) {
var i18nKey = i18nPrefix + "." + err.errorKey;
return status(exports.defaultStatusNumbers[err.errorKey], {
message: Option_1.getOrElse(function () { return i18nKey; })(i18n_1.localize({ key: i18nKey })),
debug: String(err)
});
};
}
exports.errorResponse = errorResponse;
exports.ok = function (body) { return status(200, body); };

@@ -18,0 +40,0 @@ exports.created = function (body) { return status(201, body); };

4

package.json
{
"name": "enonic-wizardry",
"version": "0.0.3",
"version": "0.0.4",
"description": "Functional utility library for Enonic XP",

@@ -27,3 +27,3 @@ "main": "lib/index.js",

"dependencies": {
"enonic-fp": "^0.0.8",
"enonic-fp": "^0.0.9",
"fp-ts": "^2.0.5"

@@ -30,0 +30,0 @@ },

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