Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const helloWorldEndpoint = defaultEndpointsFactory.build({
Connect your endpoint to the `/v1/hello` route:

```ts
import { Routing } from "express-zod-api";
import type { Routing } from "express-zod-api";

const routing: Routing = {
v1: {
Expand Down
2 changes: 1 addition & 1 deletion example/middlewares.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 { Method, Middleware } from "express-zod-api";
import { type Method, Middleware } from "express-zod-api";

export const authMiddleware = new Middleware({
security: {
Expand Down
2 changes: 1 addition & 1 deletion example/routing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DependsOnMethod, Routing, ServeStatic } from "express-zod-api";
import { DependsOnMethod, type Routing, ServeStatic } from "express-zod-api";
import { rawAcceptingEndpoint } from "./endpoints/accept-raw.ts";
import { createUserEndpoint } from "./endpoints/create-user.ts";
import { deleteUserEndpoint } from "./endpoints/delete-user.ts";
Expand Down
6 changes: 3 additions & 3 deletions express-zod-api/src/builtin-logger.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import ansis from "ansis";
import { inspect } from "node:util";
import { performance } from "node:perf_hooks";
import { FlatObject, isProduction } from "./common-helpers.ts";
import { type FlatObject, isProduction } from "./common-helpers.ts";
import {
AbstractLogger,
type AbstractLogger,
formatDuration,
isHidden,
Severity,
type Severity,
styles,
} from "./logger-helpers.ts";

Expand Down
14 changes: 7 additions & 7 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 type { Request } from "express";
import * as R from "ramda";
import { z } from "zod";
import { CommonConfig, InputSource, InputSources } from "./config-type.ts";
import type { CommonConfig, InputSource, InputSources } from "./config-type.ts";
import { contentTypes } from "./content-type.ts";
import {
ClientMethod,
SomeMethod,
type ClientMethod,
type SomeMethod,
isMethod,
Method,
CORSMethod,
type Method,
type CORSMethod,
} from "./method.ts";
import { NormalizedResponse } from "./api-response.ts";
import type { NormalizedResponse } from "./api-response.ts";

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

export type InputSource = keyof Pick<
Request,
Expand Down
4 changes: 2 additions & 2 deletions express-zod-api/src/deep-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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 type { IOSchema } from "./io-schema.ts";
import { getBrand } from "@express-zod-api/zod-plugin";
import { FirstPartyKind } from "./schema-walker.ts";
import type { FirstPartyKind } from "./schema-walker.ts";
import { ezUploadBrand } from "./upload-schema.ts";
import { ezRawBrand } from "./raw-schema.ts";

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

export class DependsOnMethod extends Routable {
Expand Down
4 changes: 2 additions & 2 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.ts";
import { FlatObject, getRoutePathParams } from "./common-helpers.ts";
import { type 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";
import type { ActualLogger } from "./logger-helpers.ts";

export class Diagnostics {
#verifiedEndpoints = new WeakSet<AbstractEndpoint>();
Expand Down
44 changes: 22 additions & 22 deletions express-zod-api/src/documentation-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import {
ExamplesObject,
type ExamplesObject,
isReferenceObject,
isSchemaObject,
MediaTypeObject,
OAuthFlowObject,
ParameterObject,
ReferenceObject,
RequestBodyObject,
ResponseObject,
SchemaObject,
SchemaObjectType,
SecurityRequirementObject,
SecuritySchemeObject,
TagObject,
type MediaTypeObject,
type OAuthFlowObject,
type ParameterObject,
type ReferenceObject,
type RequestBodyObject,
type ResponseObject,
type SchemaObject,
type SchemaObjectType,
type SecurityRequirementObject,
type SecuritySchemeObject,
type TagObject,
} from "openapi3-ts/oas31";
import * as R from "ramda";
import { z } from "zod";
import { NormalizedResponse, ResponseVariant } from "./api-response.ts";
import type { NormalizedResponse, ResponseVariant } from "./api-response.ts";
import { ezBufferBrand } from "./buffer-schema.ts";
import {
shouldHaveContent,
FlatObject,
type FlatObject,
getRoutePathParams,
getTransformedType,
isObject,
isSchema,
makeCleanId,
routePathParamsRegex,
Tag,
type Tag,
ucFirst,
} from "./common-helpers.ts";
import { InputSource } from "./config-type.ts";
import type { 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 type { IOSchema } from "./io-schema.ts";
import { flattenIO } from "./json-schema-helpers.ts";
import { Alternatives } from "./logical-container.ts";
import type { Alternatives } from "./logical-container.ts";
import { getBrand } from "@express-zod-api/zod-plugin";
import { ClientMethod } from "./method.ts";
import { ProprietaryBrand } from "./proprietary-schemas.ts";
import type { ClientMethod } from "./method.ts";
import type { ProprietaryBrand } from "./proprietary-schemas.ts";
import { ezRawBrand } from "./raw-schema.ts";
import { FirstPartyKind } from "./schema-walker.ts";
import { Security } from "./security.ts";
import type { FirstPartyKind } from "./schema-walker.ts";
import type { Security } from "./security.ts";
import { ezUploadBrand } from "./upload-schema.ts";
import wellKnownHeaders from "./well-known-headers.ts";

Expand Down
24 changes: 12 additions & 12 deletions express-zod-api/src/documentation.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
OpenApiBuilder,
OperationObject,
ReferenceObject,
ResponsesObject,
SchemaObject,
SecuritySchemeObject,
SecuritySchemeType,
type OperationObject,
type ReferenceObject,
type ResponsesObject,
type SchemaObject,
type SecuritySchemeObject,
type SecuritySchemeType,
} from "openapi3-ts/oas31";
import * as R from "ramda";
import { responseVariants } from "./api-response.ts";
import { contentTypes } from "./content-type.ts";
import { DocumentationError } from "./errors.ts";
import { getInputSources, makeCleanId } from "./common-helpers.ts";
import { CommonConfig } from "./config-type.ts";
import type { CommonConfig } from "./config-type.ts";
import { processContainers } from "./logical-container.ts";
import { ClientMethod } from "./method.ts";
import type { ClientMethod } from "./method.ts";
import {
depictBody,
depictRequestParams,
Expand All @@ -24,13 +24,13 @@ import {
depictTags,
ensureShortDescription,
reformatParamsInPath,
IsHeader,
type IsHeader,
nonEmpty,
BrandHandling,
type BrandHandling,
depictRequest,
} from "./documentation-helpers.ts";
import { Routing } from "./routing.ts";
import { OnEndpoint, walkRouting, withHead } from "./routing-walker.ts";
import type { Routing } from "./routing.ts";
import { type OnEndpoint, walkRouting, withHead } from "./routing-walker.ts";

type Component =
| "positiveResponse"
Expand Down
29 changes: 16 additions & 13 deletions express-zod-api/src/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import * as R from "ramda";
import { z, globalRegistry } from "zod";
import { NormalizedResponse, ResponseVariant } from "./api-response.ts";
import type { NormalizedResponse, ResponseVariant } from "./api-response.ts";
import { findRequestTypeDefiningSchema } from "./deep-checks.ts";
import {
FlatObject,
type FlatObject,
getActualMethod,
getInput,
ensureError,
isSchema,
} from "./common-helpers.ts";
import { CommonConfig } from "./config-type.ts";
import type { CommonConfig } from "./config-type.ts";
import {
InputValidationError,
OutputValidationError,
ResultHandlerError,
} from "./errors.ts";
import { ezFormBrand } from "./form-schema.ts";
import { IOSchema } from "./io-schema.ts";
import type { IOSchema } from "./io-schema.ts";
import { lastResortHandler } from "./last-resort.ts";
import { ActualLogger } from "./logger-helpers.ts";
import { LogicalContainer } from "./logical-container.ts";
import type { ActualLogger } from "./logger-helpers.ts";
import type { LogicalContainer } from "./logical-container.ts";
import { getBrand } from "@express-zod-api/zod-plugin";
import { ClientMethod, CORSMethod, Method, SomeMethod } from "./method.ts";
import { AbstractMiddleware, ExpressMiddleware } from "./middleware.ts";
import { ContentType } from "./content-type.ts";
import type { ClientMethod, CORSMethod, Method, SomeMethod } from "./method.ts";
import { type AbstractMiddleware, ExpressMiddleware } from "./middleware.ts";
import type { ContentType } from "./content-type.ts";
import { ezRawBrand } from "./raw-schema.ts";
import { DiscriminatedResult, pullResponseExamples } from "./result-helpers.ts";
import {
type DiscriminatedResult,
pullResponseExamples,
} from "./result-helpers.ts";
import { Routable } from "./routable.ts";
import { AbstractResultHandler } from "./result-handler.ts";
import { Security } from "./security.ts";
import type { AbstractResultHandler } from "./result-handler.ts";
import type { Security } from "./security.ts";
import { ezUploadBrand } from "./upload-schema.ts";

export type Handler<IN, OUT, OPT> = (params: {
Expand Down
20 changes: 10 additions & 10 deletions express-zod-api/src/endpoints-factory.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Request, Response } from "express";
import type { Request, Response } from "express";
import { z } from "zod";
import {
EmptyObject,
type EmptyObject,
emptySchema,
EmptySchema,
FlatObject,
Tag,
type EmptySchema,
type FlatObject,
type Tag,
} from "./common-helpers.ts";
import { Endpoint, Handler } from "./endpoint.ts";
import { Endpoint, type Handler } from "./endpoint.ts";
import {
IOSchema,
FinalInputSchema,
Extension,
type IOSchema,
type FinalInputSchema,
type Extension,
ensureExtension,
makeFinalInputSchema,
} from "./io-schema.ts";
import { ClientMethod, Method } from "./method.ts";
import type { ClientMethod, Method } from "./method.ts";
import {
AbstractMiddleware,
ExpressMiddleware,
Expand Down
2 changes: 1 addition & 1 deletion express-zod-api/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import { getMessageFromError } from "./common-helpers.ts";
import { OpenAPIContext } from "./documentation-helpers.ts";
import type { OpenAPIContext } from "./documentation-helpers.ts";
import type { Method } from "./method.ts";

/** @desc An error related to the wrong Routing declaration */
Expand Down
6 changes: 3 additions & 3 deletions express-zod-api/src/integration-base.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as R from "ramda";
import ts from "typescript";
import { ResponseVariant } from "./api-response.ts";
import type { ResponseVariant } from "./api-response.ts";
import { contentTypes } from "./content-type.ts";
import { ClientMethod, clientMethods } from "./method.ts";
import { type ClientMethod, clientMethods } from "./method.ts";
import type { makeEventSchema } from "./sse.ts";
import {
accessModifiers,
Expand Down Expand Up @@ -35,7 +35,7 @@ import {
makePublicProperty,
makeIndexed,
makeMaybeAsync,
Typeable,
type Typeable,
makeFnType,
makeLiteralType,
literally,
Expand Down
12 changes: 6 additions & 6 deletions express-zod-api/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as R from "ramda";
import ts from "typescript";
import { z } from "zod";
import { ResponseVariant, responseVariants } from "./api-response.ts";
import { type ResponseVariant, responseVariants } from "./api-response.ts";
import { IntegrationBase } from "./integration-base.ts";
import {
f,
Expand All @@ -16,13 +16,13 @@ import {
} from "./typescript-api.ts";
import { shouldHaveContent, makeCleanId } from "./common-helpers.ts";
import { loadPeer } from "./peer-helpers.ts";
import { Routing } from "./routing.ts";
import { OnEndpoint, walkRouting, withHead } from "./routing-walker.ts";
import { HandlingRules } from "./schema-walker.ts";
import type { Routing } from "./routing.ts";
import { type OnEndpoint, walkRouting, withHead } from "./routing-walker.ts";
import type { HandlingRules } from "./schema-walker.ts";
import { zodToTs } from "./zts.ts";
import { ZTSContext } from "./zts-helpers.ts";
import type { ZTSContext } from "./zts-helpers.ts";
import type Prettier from "prettier";
import { ClientMethod } from "./method.ts";
import type { ClientMethod } from "./method.ts";

interface IntegrationParams {
routing: Routing;
Expand Down
2 changes: 1 addition & 1 deletion express-zod-api/src/json-schema-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as R from "ramda";
import { combinations, FlatObject, isObject } from "./common-helpers.ts";
import { combinations, type FlatObject, isObject } from "./common-helpers.ts";
import type { z } from "zod";

const isJsonObjectSchema = (
Expand Down
6 changes: 3 additions & 3 deletions express-zod-api/src/last-resort.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Response } from "express";
import type { Response } from "express";
import createHttpError, { isHttpError } from "http-errors";
import { ResultHandlerError } from "./errors.ts";
import { ActualLogger } from "./logger-helpers.ts";
import type { ResultHandlerError } from "./errors.ts";
import type { ActualLogger } from "./logger-helpers.ts";
import { getPublicErrorMessage } from "./result-helpers.ts";

interface LastResortHandlerParams {
Expand Down
Loading