@darksheep/express 2.1.2 → 2.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.4](https://github.com/DarkSheepSoftware/node-packages/compare/express-v2.1.3...express-v2.1.4) (2026-09-20)
4
+
5
+
6
+ ### 🩹 Fixes
7
+
8
+ * **express:** correct JSDoc types that broke the prepack typecheck ([#1005](https://github.com/DarkSheepSoftware/node-packages/issues/1005)) ([d21cd6f](https://github.com/DarkSheepSoftware/node-packages/commit/d21cd6fffe02ad1ed13a0d67c6c19e32eeff5a85))
9
+
10
+ ## [2.1.3](https://github.com/DarkSheepSoftware/node-packages/compare/express-v2.1.2...express-v2.1.3) (2026-09-20)
11
+
12
+
13
+ ### Dependencies
14
+
15
+ * The following workspace dependencies were updated
16
+ * devDependencies
17
+ * @darksheep/logger bumped from 1.3.1 to 1.4.0
18
+ * peerDependencies
19
+ * @darksheep/logger bumped from >=1.0.10 to >=1.4.0
20
+
3
21
  ## [2.1.2](https://github.com/DarkSheepSoftware/node-packages/compare/express-v2.1.1...express-v2.1.2) (2026-04-17)
4
22
 
5
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/express",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "express utilites and other bits",
5
5
  "license": "UNLICENCED",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@darksheep/json-schema": "",
31
- "@darksheep/logger": "1.3.1",
31
+ "@darksheep/logger": "1.4.0",
32
32
  "@types/express": "~5.0.0",
33
33
  "@types/on-finished": "^2",
34
34
  "express": "~5.2.0"
@@ -48,5 +48,8 @@
48
48
  },
49
49
  "engines": {
50
50
  "node": "^20.13.1 || >=22.2.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
51
54
  }
52
55
  }
@@ -17,7 +17,7 @@ export function createContentTypeMiddleware(targetContentTypes, shouldThrow = tr
17
17
  );
18
18
 
19
19
  return (request, response, next) => {
20
- const provided = request.headers['content-type']?.split(';').at(0);
20
+ const provided = request.headers['content-type']?.split(';', 1).at(0);
21
21
  if (
22
22
  provided != null &&
23
23
  contentTypes.has(provided)
@@ -35,9 +35,9 @@ export function createContentTypeMiddleware(targetContentTypes, shouldThrow = tr
35
35
  }
36
36
 
37
37
  /** @type {Handler} */
38
- export function unsupportedMediaType(request) {
38
+ export function unsupportedMediaType(request, _response, _next) {
39
39
  const { method } = request;
40
- const url = request.originalUrl.split('?').at(0) ?? '/';
40
+ const url = request.originalUrl.split('?', 1).at(0) ?? '/';
41
41
  const contentType = request.headers['content-type'];
42
42
 
43
43
  throw new UnsupportedMediaType(
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /**
8
- * @type {JsonSchema}
8
+ * @type {typeof JsonSchema | undefined}
9
9
  */
10
10
  let schema;
11
11
  try {
@@ -21,7 +21,8 @@ export function errorHandlerMiddleware(error, request, response, _next) {
21
21
  : 500,
22
22
  );
23
23
 
24
- for (const { format, test } of request.app.errorHandlers ?? []) {
24
+ const errorHandlers = request.app.errorHandlers ?? [];
25
+ for (const { format, test } of errorHandlers) {
25
26
  if (test(error)) {
26
27
  response.json({
27
28
  errors: format(error),
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @import { Socket } from 'node:net'
3
- * @import { Logger } from '@darksheep/logger'
3
+ * @import { Logger as LoggerType } from '@darksheep/logger'
4
4
  * @import { Handler } from '../../express.js'
5
5
  * @import { Filter } from './filter.js'
6
6
  */
@@ -28,7 +28,7 @@ const sockets = new WeakMap();
28
28
  const wrap = Logger?.wrap ?? ((_ctx, fn) => fn());
29
29
 
30
30
  /**
31
- * @param {Logger} logger - A callback that can be bound to the request.
31
+ * @param {LoggerType} logger - A callback that can be bound to the request.
32
32
  * @param {Filter[]} [filters] - A list of requests to not log.
33
33
  * @returns {Handler}
34
34
  */
@@ -1,8 +1,10 @@
1
+ /**
2
+ * @import { Handler } from '../../express.js'
3
+ */
4
+ import type { Handler } from '../../express.js';
1
5
  /**
2
6
  * @param {string | string[]} targetContentTypes - The permitted content types.
3
7
  * @param {boolean} [shouldThrow] - Should the middleware throw an error.
4
8
  * @returns {Handler}
5
9
  */
6
- export function createContentTypeMiddleware(targetContentTypes: string | string[], shouldThrow?: boolean): Handler;
7
- export function unsupportedMediaType(req: import("express-serve-static-core").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express-serve-static-core").Response<any, Record<string, any>, number>, next: import("express-serve-static-core").NextFunction): unknown;
8
- import type { Handler } from '../../express.js';
10
+ export declare function createContentTypeMiddleware(targetContentTypes: string | string[], shouldThrow?: boolean): Handler;
@@ -1,7 +1,10 @@
1
1
  /**
2
- * @param {Record<string, Handler | Handler[]>} contentTypeRoutes - An object containing the contentType and routes.
3
- * @returns {Router}
2
+ * @import { Handler } from '../../express.js'
4
3
  */
5
- export function createContentTypeRouter(contentTypeRoutes: Record<string, Handler | Handler[]>): Router;
6
4
  import type { Handler } from '../../express.js';
7
5
  import { Router } from 'express';
6
+ /**
7
+ * @param {Record<string, Handler | Handler[]>} contentTypeRoutes - An object containing the contentType and routes.
8
+ * @returns {Router}
9
+ */
10
+ export declare function createContentTypeRouter(contentTypeRoutes: Record<string, Handler | Handler[]>): Router;
@@ -1,17 +1,7 @@
1
1
  /**
2
2
  * @import { ErrorHandler } from '../../express.js';
3
3
  */
4
- /**
5
- * @typedef HttpErrorExtra
6
- * @property {boolean} expose - Should the error message be sent to the client.
7
- * @property {Record<string, string> | undefined} headers - Additional headers to send.
8
- * @property {number} statusCode - The response status code.
9
- */
10
- /**
11
- * @typedef {Error & HttpErrorExtra} HttpError
12
- */
13
- /** @type {ErrorHandler<HttpError>} */
14
- export const HttpErrorHandler: ErrorHandler<HttpError>;
4
+ import type { ErrorHandler } from '../../express.js';
15
5
  export type HttpErrorExtra = {
16
6
  /**
17
7
  * - Should the error message be sent to the client.
@@ -27,4 +17,14 @@ export type HttpErrorExtra = {
27
17
  statusCode: number;
28
18
  };
29
19
  export type HttpError = Error & HttpErrorExtra;
30
- import type { ErrorHandler } from '../../express.js';
20
+ /**
21
+ * @typedef HttpErrorExtra
22
+ * @property {boolean} expose - Should the error message be sent to the client.
23
+ * @property {Record<string, string> | undefined} headers - Additional headers to send.
24
+ * @property {number} statusCode - The response status code.
25
+ */
26
+ /**
27
+ * @typedef {Error & HttpErrorExtra} HttpError
28
+ */
29
+ /** @type {ErrorHandler<HttpError>} */
30
+ export declare const HttpErrorHandler: ErrorHandler<HttpError>;
@@ -1,4 +1,9 @@
1
- /** @type {ErrorHandler<RequestSchemaError | ResponseSchemaError>} */
2
- export const SchemaErrorHandler: ErrorHandler<JsonSchema.RequestSchemaError | JsonSchema.ResponseSchemaError>;
3
- import type * as JsonSchema from '@darksheep/json-schema';
1
+ /**
2
+ * @import * as JsonSchema from '@darksheep/json-schema';
3
+ * @import { ErrorHandler } from '../../express.js';
4
+ * @import { RequestSchemaError, ResponseSchemaError } from '@darksheep/json-schema';
5
+ */
4
6
  import type { ErrorHandler } from '../../express.js';
7
+ import type { RequestSchemaError, ResponseSchemaError } from '@darksheep/json-schema';
8
+ /** @type {ErrorHandler<RequestSchemaError | ResponseSchemaError>} */
9
+ export declare const SchemaErrorHandler: ErrorHandler<RequestSchemaError | ResponseSchemaError>;
@@ -1 +1,6 @@
1
- export function errorHandlerMiddleware(err: any, req: import("express-serve-static-core").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: import("express-serve-static-core").Response<any, Record<string, any>, number>, next: import("express-serve-static-core").NextFunction): unknown;
1
+ /**
2
+ * @import {
3
+ * ErrorRequestHandler,
4
+ * } from '../../express.js'
5
+ */
6
+ export {};
@@ -1,17 +1,7 @@
1
1
  /**
2
2
  * @import { ErrorHandler } from '../../express.js';
3
3
  */
4
- /**
5
- * @typedef ZodIssue
6
- * @property {string} message - The error message for the path.
7
- * @property {string} code - The zod error code text.
8
- * @property {string} path - The path to the error in zod.
9
- */
10
- /**
11
- * @typedef {Error & { errors: ZodIssue[] }} ZodError
12
- */
13
- /** @type {ErrorHandler<ZodError>} */
14
- export const ZodErrorHandler: ErrorHandler<ZodError>;
4
+ import type { ErrorHandler } from '../../express.js';
15
5
  export type ZodIssue = {
16
6
  /**
17
7
  * - The error message for the path.
@@ -29,4 +19,14 @@ export type ZodIssue = {
29
19
  export type ZodError = Error & {
30
20
  errors: ZodIssue[];
31
21
  };
32
- import type { ErrorHandler } from '../../express.js';
22
+ /**
23
+ * @typedef ZodIssue
24
+ * @property {string} message - The error message for the path.
25
+ * @property {string} code - The zod error code text.
26
+ * @property {string} path - The path to the error in zod.
27
+ */
28
+ /**
29
+ * @typedef {Error & { errors: ZodIssue[] }} ZodError
30
+ */
31
+ /** @type {ErrorHandler<ZodError>} */
32
+ export declare const ZodErrorHandler: ErrorHandler<ZodError>;
package/types/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { createContentTypeMiddleware } from "./content-type/middleware.js";
2
- export { createContentTypeRouter } from "./content-type/router.js";
3
- export { createRequestLoggerMiddleware } from "./logger/middleware.js";
4
- export { createRequestIdMiddleware } from "./request-id/middleware.js";
5
- export { errorHandlerMiddleware } from "./error-handler/middleware.js";
6
- export { notFoundMiddleware } from "./not-found/middleware.js";
7
- export { HttpErrorHandler } from "./error-handler/http.handler.js";
8
- export { SchemaErrorHandler } from "./error-handler/json-schema.handler.js";
9
- export { ZodErrorHandler } from "./error-handler/zod.handler.js";
1
+ export { createContentTypeMiddleware } from './content-type/middleware.js';
2
+ export { createContentTypeRouter } from './content-type/router.js';
3
+ export { createRequestLoggerMiddleware } from './logger/middleware.js';
4
+ export { createRequestIdMiddleware } from './request-id/middleware.js';
5
+ export { errorHandlerMiddleware } from './error-handler/middleware.js';
6
+ export { notFoundMiddleware } from './not-found/middleware.js';
7
+ export { HttpErrorHandler } from './error-handler/http.handler.js';
8
+ export { SchemaErrorHandler } from './error-handler/json-schema.handler.js';
9
+ export { ZodErrorHandler } from './error-handler/zod.handler.js';
@@ -1,3 +1,4 @@
1
+ export type Filter = string | RegExp;
1
2
  /**
2
3
  * @typedef {string|RegExp} Filter
3
4
  */
@@ -6,5 +7,4 @@
6
7
  * @param {Filter[]} [filters] - A list of paths to filter out.
7
8
  * @returns {boolean}
8
9
  */
9
- export function shouldFilterOutRequest(requestPath?: string | undefined | null, filters?: Filter[]): boolean;
10
- export type Filter = string | RegExp;
10
+ export declare function shouldFilterOutRequest(requestPath?: string | undefined | null, filters?: Filter[]): boolean;
@@ -1,11 +1,15 @@
1
1
  /**
2
- * @param {Logger} logger - A callback that can be bound to the request.
2
+ * @import { Socket } from 'node:net'
3
+ * @import { Logger as LoggerType } from '@darksheep/logger'
4
+ * @import { Handler } from '../../express.js'
5
+ * @import { Filter } from './filter.js'
6
+ */
7
+ import type { Logger as LoggerType } from '@darksheep/logger';
8
+ import type { Handler } from '../../express.js';
9
+ import type { Filter } from './filter.js';
10
+ /**
11
+ * @param {LoggerType} logger - A callback that can be bound to the request.
3
12
  * @param {Filter[]} [filters] - A list of requests to not log.
4
13
  * @returns {Handler}
5
14
  */
6
- export function createRequestLoggerMiddleware(logger: Logger, filters?: Filter[]): Handler;
7
- declare const Logger: typeof Logger | undefined;
8
- import type { Logger } from '@darksheep/logger';
9
- import type { Filter } from './filter.js';
10
- import type { Handler } from '../../express.js';
11
- export {};
15
+ export declare function createRequestLoggerMiddleware(logger: LoggerType, filters?: Filter[]): Handler;
@@ -1,10 +1,9 @@
1
+ import type { NextFunction } from 'express';
2
+ import type { Request, Response } from '../../express.js';
1
3
  /**
2
4
  * @param {Request} request - The express request.
3
5
  * @param {Response} _response - The express response.
4
6
  * @param {NextFunction} next - The next handler.
5
7
  * @returns {void}
6
8
  */
7
- export function notFoundMiddleware(request: Request, _response: Response, next: NextFunction): void;
8
- import type { Request } from '../../express.js';
9
- import type { Response } from '../../express.js';
10
- import type { NextFunction } from 'express';
9
+ export declare function notFoundMiddleware(request: Request, _response: Response, next: NextFunction): void;
@@ -1,13 +1,12 @@
1
+ import type { Handler, Request } from '../../express.js';
1
2
  /**
2
3
  * @param {Request} request - The express request.
3
4
  * @param {string} [headerName] - The name of the header used in correlation.
4
5
  * @returns {string}
5
6
  */
6
- export function getTrail(request: Request, headerName?: string): string;
7
+ export declare function getTrail(request: Request, headerName?: string): string;
7
8
  /**
8
9
  * @param {string} [headerName] - The name of a header to include in the response with the trail.
9
10
  * @returns {Handler}
10
11
  */
11
- export function createRequestIdMiddleware(headerName?: string): Handler;
12
- import type { Request } from '../../express.js';
13
- import type { Handler } from '../../express.js';
12
+ export declare function createRequestIdMiddleware(headerName?: string): Handler;