Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
290e99f
Overriding tsconfig/node20 with recommended module and target from ht…
RobinTail Sep 28, 2025
81e7fca
Enabling importing with ts extension.
RobinTail Sep 28, 2025
7bbe6d3
Resetting tsconfig and adjusting imports for zod plugin.
RobinTail Sep 28, 2025
f0cb45a
Resetting tsconfig and adjusting imports in migration.
RobinTail Sep 28, 2025
58a6e90
Resetting tsconfig and adjusting imports in tools.
RobinTail Sep 28, 2025
03bb51f
Resetting and adjusting example.
RobinTail Sep 28, 2025
deb5af2
Resetting and adjusting the framework workspace.
RobinTail Sep 28, 2025
01476e7
rm empty compiler options from example tsconfig.
RobinTail Sep 28, 2025
45e4ddd
Adjusting the rest of workspaces.
RobinTail Sep 28, 2025
e8e9ade
rm tsconfig in ESM test.
RobinTail Sep 28, 2025
1dd79b8
Moving resolveJsonModule to the root.
RobinTail Sep 28, 2025
c21d5e2
Ref: static import in tsdown.config for the framework workspace.
RobinTail Sep 28, 2025
10d4dfe
rm tsconfig from tools.
RobinTail Sep 28, 2025
d893552
Lint: ensure .ts extensions.
RobinTail Sep 29, 2025
480a773
Merge branch 'master' into strict-module-node20
RobinTail Sep 29, 2025
ed9990b
Ref: simpler selector for the linting rule.
RobinTail Sep 30, 2025
4dcd797
fix: avoid package json module import in runtime code of the framework.
RobinTail Oct 1, 2025
a08c1dd
fix: avoid package json module import in runtime code of the plugin.
RobinTail Oct 1, 2025
4d1debb
Add eslint rule for sources concerning importing package.json files.
RobinTail Oct 1, 2025
5fd70d4
Merge branch 'master' into strict-module-node20
RobinTail Oct 1, 2025
e4588d4
Merge branch 'master' into strict-module-node20
RobinTail Oct 2, 2025
453fba2
fix: stabilizing test for migration.
RobinTail Oct 2, 2025
41d61d5
Merge branch 'master' into strict-module-node20
RobinTail Oct 2, 2025
791bca5
Merge branch 'master' into strict-module-node20
RobinTail Oct 4, 2025
5434de3
mv type coercion in migration test.
RobinTail Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compat-test/quick-start.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
expect,
test,
} from "vitest";
import { givePort } from "../tools/ports";
import { givePort } from "../tools/ports.ts";

describe("ESM Test", async () => {
let out = "";
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const importConcerns = [
selector: "ImportDeclaration[source.value=/^zod/] > ImportDefaultSpecifier",
message: "do import { z } instead",
},
{
selector: "ImportDeclaration[source.value=/\\.js$/]",
message: "use .ts extension for relative imports",
},
...builtinModules.map((mod) => ({
selector: `ImportDeclaration[source.value='${mod}']`,
message: `use node:${mod} for the built-in module`,
Expand Down Expand Up @@ -64,6 +68,10 @@ const performanceConcerns = [
selector: "MemberExpression[object.name='R'] > Identifier[name='union']", // #2599
message: "R.union() is 1.5x slower than [...Set().add()]",
},
{
selector: "ImportDeclaration[source.value=/package.json$/]", // #2974
message: "it can not be tree shaken, use tsdown and process.env instead",
},
];

const tsFactoryConcerns = [
Expand Down
2 changes: 1 addition & 1 deletion esm-test/quick-start.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from "node:child_process";
import { givePort } from "../tools/ports";
import { givePort } from "../tools/ports.ts";

describe("ESM Test", async () => {
let out = "";
Expand Down
7 changes: 0 additions & 7 deletions esm-test/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion example/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BuiltinLogger, createConfig } from "express-zod-api";
import ui from "swagger-ui-express";
import createHttpError from "http-errors";
import { givePort } from "../tools/ports";
import { givePort } from "../tools/ports.ts";
import qs from "qs";

export const config = createConfig({
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/create-user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createHttpError from "http-errors";
import assert from "node:assert/strict";
import { z } from "zod";
import { statusDependingFactory } from "../factories";
import { statusDependingFactory } from "../factories.ts";

const namePart = z.string().regex(/^\w+$/);

Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/delete-user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createHttpError from "http-errors";
import assert from "node:assert/strict";
import { z } from "zod";
import { noContentFactory } from "../factories";
import { noContentFactory } from "../factories.ts";

/** @desc The endpoint demonstrates no content response established by its factory */
export const deleteUserEndpoint = noContentFactory.buildVoid({
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/list-users.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { arrayRespondingFactory } from "../factories";
import { arrayRespondingFactory } from "../factories.ts";

const roleSchema = z.enum(["manager", "operator", "admin"]);

Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/retrieve-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import createHttpError from "http-errors";
import assert from "node:assert/strict";
import { z } from "zod";
import { defaultEndpointsFactory } from "express-zod-api";
import { methodProviderMiddleware } from "../middlewares";
import { methodProviderMiddleware } from "../middlewares.ts";

// Demonstrating circular schemas using z.object()
const feature = z.object({
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/send-avatar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { fileSendingEndpointsFactory } from "../factories";
import { fileSendingEndpointsFactory } from "../factories.ts";
import { readFile } from "node:fs/promises";

export const sendAvatarEndpoint = fileSendingEndpointsFactory.build({
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/stream-avatar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { fileStreamingEndpointsFactory } from "../factories";
import { fileStreamingEndpointsFactory } from "../factories.ts";

export const streamAvatarEndpoint = fileStreamingEndpointsFactory.build({
shortDescription: "Streams a file content.",
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/time-subscription.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import { setTimeout } from "node:timers/promises";
import { eventsFactory } from "../factories";
import { eventsFactory } from "../factories.ts";

/** @desc The endpoint demonstrates emitting server-sent events (SSE) */
export const subscriptionEndpoint = eventsFactory.buildVoid({
Expand Down
2 changes: 1 addition & 1 deletion example/endpoints/update-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import createHttpError from "http-errors";
import assert from "node:assert/strict";
import { z } from "zod";
import { ez } from "express-zod-api";
import { keyAndTokenAuthenticatedEndpointsFactory } from "../factories";
import { keyAndTokenAuthenticatedEndpointsFactory } from "../factories.ts";

export const updateUserEndpoint =
keyAndTokenAuthenticatedEndpointsFactory.build({
Expand Down
2 changes: 1 addition & 1 deletion example/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
EventStreamFactory,
defaultEndpointsFactory,
} from "express-zod-api";
import { authMiddleware } from "./middlewares";
import { authMiddleware } from "./middlewares.ts";
import { createReadStream } from "node:fs";
import { z } from "zod";
import { stat } from "node:fs/promises";
Expand Down
4 changes: 2 additions & 2 deletions example/generate-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { writeFile } from "node:fs/promises";
import { Integration } from "express-zod-api";
import { routing } from "./routing";
import { config } from "./config";
import { routing } from "./routing.ts";
import { config } from "./config.ts";

await writeFile(
"example.client.ts",
Expand Down
6 changes: 3 additions & 3 deletions example/generate-documentation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { writeFile } from "node:fs/promises";
import { Documentation } from "express-zod-api";
import { config } from "./config";
import { routing } from "./routing";
import manifest from "./package.json";
import { config } from "./config.ts";
import { routing } from "./routing.ts";
import manifest from "./package.json" with { type: "json" };

await writeFile(
"example.documentation.yaml",
Expand Down
4 changes: 2 additions & 2 deletions example/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from "node:assert/strict";
import { spawn } from "node:child_process";
import { createReadStream, readFileSync } from "node:fs";
import { Client, Subscription } from "./example.client";
import { givePort } from "../tools/ports";
import { Client, Subscription } from "./example.client.ts";
import { givePort } from "../tools/ports.ts";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import { fail } from "node:assert";
Expand Down
4 changes: 2 additions & 2 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer } from "express-zod-api";
import { config } from "./config";
import { routing } from "./routing";
import { config } from "./config.ts";
import { routing } from "./routing.ts";

/**
* "await" is only needed for using entities returned from this method.
Expand Down
22 changes: 11 additions & 11 deletions example/routing.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { DependsOnMethod, Routing, ServeStatic } from "express-zod-api";
import { rawAcceptingEndpoint } from "./endpoints/accept-raw";
import { createUserEndpoint } from "./endpoints/create-user";
import { deleteUserEndpoint } from "./endpoints/delete-user";
import { listUsersEndpoint } from "./endpoints/list-users";
import { submitFeedbackEndpoint } from "./endpoints/submit-feedback";
import { subscriptionEndpoint } from "./endpoints/time-subscription";
import { uploadAvatarEndpoint } from "./endpoints/upload-avatar";
import { retrieveUserEndpoint } from "./endpoints/retrieve-user";
import { sendAvatarEndpoint } from "./endpoints/send-avatar";
import { updateUserEndpoint } from "./endpoints/update-user";
import { streamAvatarEndpoint } from "./endpoints/stream-avatar";
import { rawAcceptingEndpoint } from "./endpoints/accept-raw.ts";
import { createUserEndpoint } from "./endpoints/create-user.ts";
import { deleteUserEndpoint } from "./endpoints/delete-user.ts";
import { listUsersEndpoint } from "./endpoints/list-users.ts";
import { submitFeedbackEndpoint } from "./endpoints/submit-feedback.ts";
import { subscriptionEndpoint } from "./endpoints/time-subscription.ts";
import { uploadAvatarEndpoint } from "./endpoints/upload-avatar.ts";
import { retrieveUserEndpoint } from "./endpoints/retrieve-user.ts";
import { sendAvatarEndpoint } from "./endpoints/send-avatar.ts";
import { updateUserEndpoint } from "./endpoints/update-user.ts";
import { streamAvatarEndpoint } from "./endpoints/stream-avatar.ts";

export const routing: Routing = {
v1: {
Expand Down
6 changes: 1 addition & 5 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "ES2022",
"moduleResolution": "Bundler"
}
"extends": "../tsconfig.json"
}
4 changes: 2 additions & 2 deletions express-zod-api/src/builtin-logger.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import ansis from "ansis";
import { inspect } from "node:util";
import { performance } from "node:perf_hooks";
import { FlatObject, isProduction } from "./common-helpers";
import { FlatObject, isProduction } from "./common-helpers.ts";
import {
AbstractLogger,
formatDuration,
isHidden,
Severity,
styles,
} from "./logger-helpers";
} from "./logger-helpers.ts";

interface Context extends FlatObject {
requestId?: string;
Expand Down
8 changes: 4 additions & 4 deletions express-zod-api/src/common-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Request } from "express";
import * as R from "ramda";
import { z } from "zod";
import { CommonConfig, InputSource, InputSources } from "./config-type";
import { contentTypes } from "./content-type";
import { CommonConfig, InputSource, InputSources } from "./config-type.ts";
import { contentTypes } from "./content-type.ts";
import {
ClientMethod,
SomeMethod,
isMethod,
Method,
CORSMethod,
} from "./method";
import { NormalizedResponse } from "./api-response";
} from "./method.ts";
import { NormalizedResponse } from "./api-response.ts";

/** @since zod 3.25.61 output type fixed */
export const emptySchema = z.object({});
Expand Down
12 changes: 6 additions & 6 deletions express-zod-api/src/config-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type compression from "compression";
import { IRouter, Request, RequestHandler } from "express";
import type fileUpload from "express-fileupload";
import { ServerOptions } from "node:https";
import { BuiltinLoggerConfig } from "./builtin-logger";
import { AbstractEndpoint } from "./endpoint";
import { AbstractLogger, ActualLogger } from "./logger-helpers";
import { Method } from "./method";
import { AbstractResultHandler } from "./result-handler";
import { BuiltinLoggerConfig } from "./builtin-logger.ts";
import { AbstractEndpoint } from "./endpoint.ts";
import { AbstractLogger, ActualLogger } from "./logger-helpers.ts";
import { Method } from "./method.ts";
import { AbstractResultHandler } from "./result-handler.ts";
import { ListenOptions } from "node:net";
import { GetLogger } from "./server-helpers";
import { GetLogger } from "./server-helpers.ts";

export type InputSource = keyof Pick<
Request,
Expand Down
18 changes: 9 additions & 9 deletions express-zod-api/src/deep-checks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as R from "ramda";
import { z } from "zod";
import { ezBufferBrand } from "./buffer-schema";
import { ezDateInBrand } from "./date-in-schema";
import { ezDateOutBrand } from "./date-out-schema";
import { DeepCheckError } from "./errors";
import { ezFormBrand } from "./form-schema";
import { IOSchema } from "./io-schema";
import { ezBufferBrand } from "./buffer-schema.ts";
import { ezDateInBrand } from "./date-in-schema.ts";
import { ezDateOutBrand } from "./date-out-schema.ts";
import { DeepCheckError } from "./errors.ts";
import { ezFormBrand } from "./form-schema.ts";
import { IOSchema } from "./io-schema.ts";
import { getBrand } from "@express-zod-api/zod-plugin";
import { FirstPartyKind } from "./schema-walker";
import { ezUploadBrand } from "./upload-schema";
import { ezRawBrand } from "./raw-schema";
import { FirstPartyKind } from "./schema-walker.ts";
import { ezUploadBrand } from "./upload-schema.ts";
import { ezRawBrand } from "./raw-schema.ts";

interface NestedSchemaLookupProps {
io: "input" | "output";
Expand Down
6 changes: 3 additions & 3 deletions express-zod-api/src/depends-on-method.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as R from "ramda";
import { AbstractEndpoint } from "./endpoint";
import { Method } from "./method";
import { Routable } from "./routable";
import { AbstractEndpoint } from "./endpoint.ts";
import { Method } from "./method.ts";
import { Routable } from "./routable.ts";

export class DependsOnMethod extends Routable {
readonly #endpoints: ConstructorParameters<typeof DependsOnMethod>[0];
Expand Down
14 changes: 7 additions & 7 deletions express-zod-api/src/diagnostics.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { z } from "zod";
import { responseVariants } from "./api-response";
import { FlatObject, getRoutePathParams } from "./common-helpers";
import { contentTypes } from "./content-type";
import { findJsonIncompatible } from "./deep-checks";
import { AbstractEndpoint } from "./endpoint";
import { flattenIO } from "./json-schema-helpers";
import { ActualLogger } from "./logger-helpers";
import { responseVariants } from "./api-response.ts";
import { FlatObject, getRoutePathParams } from "./common-helpers.ts";
import { contentTypes } from "./content-type.ts";
import { findJsonIncompatible } from "./deep-checks.ts";
import { AbstractEndpoint } from "./endpoint.ts";
import { flattenIO } from "./json-schema-helpers.ts";
import { ActualLogger } from "./logger-helpers.ts";

export class Diagnostics {
#verifiedEndpoints = new WeakSet<AbstractEndpoint>();
Expand Down
36 changes: 18 additions & 18 deletions express-zod-api/src/documentation-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
} from "openapi3-ts/oas31";
import * as R from "ramda";
import { z } from "zod";
import { NormalizedResponse, ResponseVariant } from "./api-response";
import { ezBufferBrand } from "./buffer-schema";
import { NormalizedResponse, ResponseVariant } from "./api-response.ts";
import { ezBufferBrand } from "./buffer-schema.ts";
import {
shouldHaveContent,
FlatObject,
Expand All @@ -29,23 +29,23 @@ import {
routePathParamsRegex,
Tag,
ucFirst,
} from "./common-helpers";
import { InputSource } from "./config-type";
import { contentTypes } from "./content-type";
import { ezDateInBrand } from "./date-in-schema";
import { ezDateOutBrand } from "./date-out-schema";
import { DocumentationError } from "./errors";
import { IOSchema } from "./io-schema";
import { flattenIO } from "./json-schema-helpers";
import { Alternatives } from "./logical-container";
} from "./common-helpers.ts";
import { InputSource } from "./config-type.ts";
import { contentTypes } from "./content-type.ts";
import { ezDateInBrand } from "./date-in-schema.ts";
import { ezDateOutBrand } from "./date-out-schema.ts";
import { DocumentationError } from "./errors.ts";
import { IOSchema } from "./io-schema.ts";
import { flattenIO } from "./json-schema-helpers.ts";
import { Alternatives } from "./logical-container.ts";
import { getBrand } from "@express-zod-api/zod-plugin";
import { ClientMethod } from "./method";
import { ProprietaryBrand } from "./proprietary-schemas";
import { ezRawBrand } from "./raw-schema";
import { FirstPartyKind } from "./schema-walker";
import { Security } from "./security";
import { ezUploadBrand } from "./upload-schema";
import wellKnownHeaders from "./well-known-headers.json";
import { ClientMethod } from "./method.ts";
import { ProprietaryBrand } from "./proprietary-schemas.ts";
import { ezRawBrand } from "./raw-schema.ts";
import { FirstPartyKind } from "./schema-walker.ts";
import { Security } from "./security.ts";
import { ezUploadBrand } from "./upload-schema.ts";
import wellKnownHeaders from "./well-known-headers.json" with { type: "json" };

interface ReqResCommons {
makeRef: (
Expand Down
Loading