Socket
Socket
Sign inDemoInstall

@epistemology-factory/crocks-web

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@epistemology-factory/crocks-web - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

validation/validation-failure.js

13

logging/logger.js

@@ -6,2 +6,5 @@ "use strict";

const Async = require("crocks/Async");
const Result = require("crocks/Result");
const compose = require("crocks/helpers/compose");

@@ -92,8 +95,16 @@ const constant = require("crocks/combinators/constant");

// asyncLogK :: (Integer -> String -> a -> a) -> Integer -> String -> a -> Async a
const asyncLogK = logK(Async.Resolved)
// resultLogK :: (Integer -> String -> a -> a) -> Integer -> String -> a -> Result a
const resultLogK = logK(Result.Ok)
module.exports = {
LOG_LEVELS,
LogLineStream,
asyncLogK,
consoleLogger,
logK,
log
log,
resultLogK
}

2

package.json
{
"name": "@epistemology-factory/crocks-web",
"version": "0.1.4",
"version": "0.1.5",
"description": "Functions to help write web applications with crocks",

@@ -5,0 +5,0 @@ "scripts": {

"use strict";
const { makeValidator } = require("./validator");
const { validationError } = require("../validation-error");
const { validationFailure } = require("../validation-failure");
const { CONSTRAINTS, DEFAULT_MESSAGES } = require("./constraints");

@@ -9,3 +9,3 @@

require("crocks/predicates/isDefined"),
validationError(
validationFailure(
CONSTRAINTS.IS_DEFINED,

@@ -12,0 +12,0 @@ DEFAULT_MESSAGES[CONSTRAINTS.IS_DEFINED]

@@ -36,3 +36,3 @@ "use strict";

*/
// isSchemaValid :: Schema -> [String] -> Object -> Result [ValidationError] Object
// isSchemaValid :: Schema -> [String] -> Object -> Result [ValidationFailure] Object
const isSchemaValid = curry((schema, path, object) =>

@@ -39,0 +39,0 @@ pipe(

"use strict";
const { makeValidator } = require("./validator");
const { validationError } = require("../validation-error");
const { validationFailure } = require("../validation-failure");
const { CONSTRAINTS, DEFAULT_MESSAGES } = require("./constraints");
// isString :: [ String ] -> a -> Result ValidationError a
// isString :: [ String ] -> a -> Result ValidationFailure a
const isString = makeValidator(
require("crocks/predicates/isString"),
validationError(
validationFailure(
CONSTRAINTS.IS_STRING,

@@ -12,0 +12,0 @@ DEFAULT_MESSAGES[CONSTRAINTS.IS_STRING]

@@ -9,3 +9,3 @@ "use strict";

// makeValidator :: (a -> Boolean) -> ([ String ] -> a -> ValidationError) -> [ String ] -> a -> Result ValidationError a
// makeValidator :: (a -> Boolean) -> ([ String ] -> a -> ValidationFailure) -> [ String ] -> a -> Result ValidationFailure a
const makeValidator = curry((pred, err) => (path) =>

@@ -12,0 +12,0 @@ ifElse(

@@ -7,7 +7,4 @@ "use strict";

const identity = require("crocks/combinators/identity");
const map = require("crocks/pointfree/map");
const pipe = require("crocks/helpers/pipe");
const { LOG_LEVELS } = require("../../logging/logger");
/**

@@ -25,8 +22,7 @@ * In order to return our response to the caller we have to convert any

*/
// handler :: (Integer -> String -> Object -> Object) -> (Object -> Async Object) -> Promise Object
const handler = curry((logger, fn) =>
// handler :: (Object -> Async Object) -> Object -> Promise Object
const handler = curry((fn) =>
pipe(
fn,
returnResponse,
map(logger(LOG_LEVELS.INFO, "RESULT: %j")),
asyncToPromise

@@ -33,0 +29,0 @@ )

@@ -9,11 +9,8 @@ "use strict";

const isObject = require("crocks/predicates/isObject");
const map = require("crocks/pointfree/map");
const mapProps = require("crocks/helpers/mapProps");
const option = require("crocks/pointfree/option");
const or = require("crocks/logic/or");
const pick = require("crocks/helpers/pick");
const pipe = require("crocks/helpers/pipe");
const safe = require("crocks/Maybe/safe");
const { join, stringify } = require("@epistemology-factory/crocks-ext/String");
const { stringify } = require("@epistemology-factory/crocks-ext/String");

@@ -71,20 +68,5 @@ /**

/**
* Converts ValidationErrors into a Bad Request response.
*/
// invalidInput :: Object -> [ValidationError] -> Object
const invalidInput = curry((headers) =>
pipe(
map(pipe(
pick([ "path", "constraints" ]),
mapProps({ path: join(".") })
)),
badRequest(headers, "Invalid input")
)
)
module.exports = {
badRequest,
internalServerError,
invalidInput,
invalidMediaType,

@@ -91,0 +73,0 @@ respondWith,

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