@blockfrost/blockfrost-utils
Advanced tools
Comparing version 1.0.0-alfa.3 to 1.0.0-alfa.4
@@ -11,3 +11,4 @@ /// <reference types="node" /> | ||
export declare const handle404: (reply: FastifyReply) => FastifyReply; | ||
export declare const handle415: (reply: FastifyReply, error: FastifyError) => FastifyReply; | ||
export declare const handle500: (reply: FastifyReply, error: unknown, request: FastifyRequest) => FastifyReply; | ||
export declare const handleInvalidAddress: (reply: FastifyReply) => FastifyReply<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify/types/route").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handleInvalidAddress = exports.handle500 = exports.handle404 = exports.handle403Custom = exports.handle403 = exports.handle402 = exports.handle400Custom = exports.handle400 = exports.errorHandler = exports.notFoundHandler = void 0; | ||
exports.handleInvalidAddress = exports.handle500 = exports.handle415 = exports.handle404 = exports.handle403Custom = exports.handle403 = exports.handle402 = exports.handle400Custom = exports.handle400 = exports.errorHandler = exports.notFoundHandler = void 0; | ||
const notFoundHandler = (_request, reply) => { | ||
@@ -22,2 +22,5 @@ return reply | ||
} | ||
if (error.statusCode === 415) { | ||
return (0, exports.handle415)(reply, error); | ||
} | ||
// TODO: investigate if these are needed | ||
@@ -30,6 +33,3 @@ if (reply.statusCode === 400) { | ||
} | ||
if (reply.statusCode >= 500 && reply.statusCode < 600) { | ||
return (0, exports.handle500)(reply, error, request); | ||
} | ||
// Handle generic js errors | ||
// Fallback and handling of generic js errors | ||
return (0, exports.handle500)(reply, error, request); | ||
@@ -92,2 +92,11 @@ }; | ||
exports.handle404 = handle404; | ||
const handle415 = (reply, error) => reply | ||
.code(415) | ||
.header('Content-Type', 'application/json; charset=utf-8') | ||
.send({ | ||
error: 'Unsupported Media Type', | ||
message: error.message, | ||
status_code: 415, | ||
}); | ||
exports.handle415 = handle415; | ||
const handle500 = (reply, error, request) => { | ||
@@ -94,0 +103,0 @@ if (process.env.NODE_ENV !== 'test') { |
{ | ||
"name": "@blockfrost/blockfrost-utils", | ||
"version": "1.0.0-alfa.3", | ||
"version": "1.0.0-alfa.4", | ||
"repository": "git@github.com:blockfrost/blockfrost-utils.git", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43869
749