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

@axah/koa

Package Overview
Dependencies
Maintainers
10
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axah/koa - npm Package Compare versions

Comparing version 0.0.0-20240607113947 to 0.0.0-20240607120304

4

lib/create-api-method/index.d.ts

@@ -18,4 +18,4 @@ import type { Context, Middleware, Next } from 'koa';

}) => {
status: StatusCodes;
body: object;
errorStatus: StatusCodes;
errorBody: object;
};

@@ -22,0 +22,0 @@ };

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

function defaultErrorFormatter({ statusCode, errorMessage, }) {
return { status: statusCode, body: { error: errorMessage } };
return { errorStatus: statusCode, errorBody: { error: errorMessage } };
}

@@ -36,3 +36,3 @@ function createApiMethod({ allowedRoles, body: bodyValidator, query: queryValidator, params: paramsValidator, files: allowFiles = false, exposeErrorCause = false, hashAlgorithm, errorFormatter = defaultErrorFormatter, }, executor) {

catch (e) {
const { status, body } = errorFormatter({
const { errorStatus, errorBody } = errorFormatter({
statusCode: http_status_codes_1.StatusCodes.FORBIDDEN,

@@ -42,4 +42,4 @@ errorMessage: http_status_codes_1.ReasonPhrases.FORBIDDEN,

});
ctx.status = status;
ctx.body = body;
ctx.status = errorStatus;
ctx.body = errorBody;
if (exposeErrorCause) {

@@ -55,8 +55,8 @@ enrichResponseWithErrorCause(ctx, e);

ctx.log.error('User %s (%j) tried to access %s %s but does not have one of the required roles %j', auth.userId, auth.userRoles, ctx.method, ctx.path, allowedRoles);
const { status, body } = errorFormatter({
const { errorStatus, errorBody } = errorFormatter({
statusCode: http_status_codes_1.StatusCodes.FORBIDDEN,
errorMessage: http_status_codes_1.ReasonPhrases.FORBIDDEN,
});
ctx.status = status;
ctx.body = body;
ctx.status = errorStatus;
ctx.body = errorBody;
return;

@@ -77,3 +77,3 @@ }

const errorMessage = 'body is invalid';
const { status, body } = errorFormatter({
const { errorStatus, errorBody } = errorFormatter({
statusCode: http_status_codes_1.StatusCodes.BAD_REQUEST,

@@ -83,4 +83,4 @@ errorMessage,

});
ctx.status = status;
ctx.body = body;
ctx.status = errorStatus;
ctx.body = errorBody;
if (exposeErrorCause) {

@@ -101,3 +101,3 @@ enrichResponseWithErrorCause(ctx, e);

const errorMessage = 'params is invalid';
const { status, body } = errorFormatter({
const { errorStatus, errorBody } = errorFormatter({
statusCode: http_status_codes_1.StatusCodes.BAD_REQUEST,

@@ -107,4 +107,4 @@ errorMessage,

});
ctx.status = status;
ctx.body = body;
ctx.status = errorStatus;
ctx.body = errorBody;
if (exposeErrorCause) {

@@ -125,3 +125,3 @@ enrichResponseWithErrorCause(ctx, e);

const errorMessage = 'query is invalid';
const { status, body } = errorFormatter({
const { errorStatus, errorBody } = errorFormatter({
statusCode: http_status_codes_1.StatusCodes.BAD_REQUEST,

@@ -131,4 +131,4 @@ errorMessage,

});
ctx.status = status;
ctx.body = body;
ctx.status = errorStatus;
ctx.body = errorBody;
if (exposeErrorCause) {

@@ -135,0 +135,0 @@ enrichResponseWithErrorCause(ctx, e);

{
"name": "@axah/koa",
"version": "0.0.0-20240607113947",
"version": "0.0.0-20240607120304",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "UNLICENSED",

Sorry, the diff of this file is not supported yet

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