@kiwiproject/kiwi-js 0.12.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ### KiwiJS
2
- [![Build](https://github.com/kiwiproject/kiwi-js/workflows/build/badge.svg)](https://github.com/kiwiproject/kiwi-js/actions?query=workflow%3Abuild)
2
+ [![Build](https://github.com/kiwiproject/kiwi-js/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/kiwiproject/kiwi-js/actions/workflows/build.yml?query=branch%3Amain)
3
3
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=kiwiproject_kiwi-js&metric=alert_status)](https://sonarcloud.io/dashboard?id=kiwiproject_kiwi-js)
4
4
  [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=kiwiproject_kiwi-js&metric=coverage)](https://sonarcloud.io/dashboard?id=kiwiproject_kiwi-js)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@@ -0,0 +1,4 @@
1
+ import KiwiStandardResponseError from "./kiwi-standard-response-error";
2
+ export default class KiwiNotLoggedInError extends KiwiStandardResponseError {
3
+ constructor(message?: string, nestedError?: Error);
4
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const kiwi_standard_response_error_1 = require("./kiwi-standard-response-error");
4
+ class KiwiNotLoggedInError extends kiwi_standard_response_error_1.default {
5
+ constructor(message = "User is not logged in", nestedError) {
6
+ super(message, 401, nestedError);
7
+ this.name = "KiwiNotLoggedInError";
8
+ }
9
+ }
10
+ exports.default = KiwiNotLoggedInError;
@@ -0,0 +1,5 @@
1
+ export default class KiwiStandardResponseError extends Error {
2
+ statusCode: number;
3
+ nestedError?: Error;
4
+ constructor(message: string, statusCode: number, nestedError?: Error);
5
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class KiwiStandardResponseError extends Error {
4
+ constructor(message, statusCode, nestedError) {
5
+ super(message);
6
+ this.name = "KiwiStandardResponseError";
7
+ this.statusCode = statusCode;
8
+ this.nestedError = nestedError;
9
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
10
+ if (Error.captureStackTrace) {
11
+ Error.captureStackTrace(this, KiwiStandardResponseError);
12
+ }
13
+ // If a nested error is provided, append its stack
14
+ if (nestedError && nestedError.stack) {
15
+ this.stack += `\nCaused by: ${nestedError.stack}`;
16
+ }
17
+ }
18
+ }
19
+ exports.default = KiwiStandardResponseError;
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Request, Response } from "express";
2
+ export declare function setupFallback(logger?: (msg: string, stack?: string) => void | undefined): (err: Error, req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupFallback = setupFallback;
4
+ const kiwi_standard_responses_express_1 = require("./kiwi-standard-responses-express");
5
+ function setupFallback(logger = undefined) {
6
+ return (err, req, res, next) => {
7
+ var _a;
8
+ if (err.name === "KiwiNotLoggedInError") {
9
+ return kiwi_standard_responses_express_1.KiwiStandardResponsesExpress.standardUnauthorizedResponse(res, err.message);
10
+ }
11
+ if (logger) {
12
+ logger(`Error while processing path ${req.method} ${req.originalUrl}: ${err.message}`, (_a = err.stack) === null || _a === void 0 ? void 0 : _a.toString());
13
+ }
14
+ if (res.headersSent) {
15
+ next(err);
16
+ }
17
+ else {
18
+ if (err.name === "KiwiStandardResponseError") {
19
+ kiwi_standard_responses_express_1.KiwiStandardResponsesExpress.standardErrorResponse(res, err.statusCode, err.message);
20
+ }
21
+ else {
22
+ kiwi_standard_responses_express_1.KiwiStandardResponsesExpress.standardErrorResponse(res, 500, err.message);
23
+ }
24
+ }
25
+ };
26
+ }
package/package.json CHANGED
@@ -1,16 +1,25 @@
1
1
  {
2
2
  "name": "@kiwiproject/kiwi-js",
3
- "version": "0.12.0",
3
+ "version": "1.0.0",
4
4
  "description": "KiwiJS is a utility library. It contains a variety of utilities that we have built over time and find useful. Most of these utilities are ports from the Java Kiwi library.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/kiwiproject/kiwi-js.git"
8
+ },
5
9
  "main": "dist/index.js",
6
10
  "types": "dist/index.d.ts",
7
11
  "files": [
8
12
  "/dist"
9
13
  ],
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "provenance": true
17
+ },
10
18
  "scripts": {
11
- "format": "node node_modules/.bin/prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
12
- "lint": "node node_modules/.bin/eslint --ext .js,.ts .",
13
- "test": "node --experimental-vm-modules node_modules/.bin/jest --coverage --collectCoverageFrom=src/**/*.ts"
19
+ "build": "tsc",
20
+ "format": "npx prettier --ignore-path .gitignore --write \"**/*.+(ts|js|json)\"",
21
+ "lint": "npx eslint --fix src",
22
+ "test": "npx jest --coverage --collectCoverageFrom=src/**/*.ts"
14
23
  },
15
24
  "jest": {
16
25
  "testPathIgnorePatterns": [
@@ -22,21 +31,26 @@
22
31
  ]
23
32
  },
24
33
  "dependencies": {
25
- "express": "4.21.0"
34
+ "express": "5.2.1"
26
35
  },
27
36
  "devDependencies": {
28
- "@babel/core": "7.25.2",
29
- "@babel/preset-env": "7.25.4",
30
- "@babel/preset-typescript": "7.24.7",
31
- "@jest/globals": "29.7.0",
32
- "@types/express": "4.17.21",
33
- "@types/node": "22.5.5",
34
- "@typescript-eslint/eslint-plugin": "8.6.0",
35
- "@typescript-eslint/parser": "8.7.0",
36
- "babel-jest": "29.7.0",
37
- "eslint": "9.11.0",
38
- "jest": "29.7.0",
39
- "prettier": "3.3.3",
40
- "typescript": "5.6.2"
37
+ "semantic-release": "^25.0.2",
38
+ "@babel/core": "7.28.6",
39
+ "@babel/preset-env": "7.28.6",
40
+ "@babel/preset-typescript": "7.28.5",
41
+ "@eslint/eslintrc": "3.3.3",
42
+ "@eslint/js": "9.39.2",
43
+ "@jest/globals": "30.2.0",
44
+ "@types/express": "5.0.6",
45
+ "@types/node": "25.0.9",
46
+ "babel-jest": "30.2.0",
47
+ "eslint": "9.39.2",
48
+ "eslint-config-prettier": "10.1.8",
49
+ "eslint-plugin-prettier": "5.5.5",
50
+ "globals": "17.0.0",
51
+ "jest": "30.2.0",
52
+ "prettier": "3.8.0",
53
+ "typescript": "5.9.3",
54
+ "typescript-eslint": "8.53.0"
41
55
  }
42
56
  }