Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@xylabs/express

Package Overview
Dependencies
Maintainers
5
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/express

SDK for base code for Api repos that use express and deploy on AWS ECS

Source
npmnpm
Version
5.0.95
Version published
Weekly downloads
517
-68.57%
Maintainers
5
Weekly downloads
 
Created
Source

@xylabs/express

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

SDK for base code for Api repos that use express and deploy on AWS ECS

Reference

@xylabs/express

Classes

ClassDescription
WrappedWinstonLoggerWrap Winston logger methods to adapt to familiar console logging methods
CountersStatic counter registry for tracking named numeric metrics.
ProfilerMeasures and records the execution duration of async operations by name.

Interfaces

InterfaceDescription
RouteDefinitionDefines an Express route with its HTTP method, path, and handler(s).
EmptyEmpty object type used as a default for request/response body generics.
LoggerOptionsConfiguration options for creating a logger instance.
ExpressErrorAn Error with an optional HTTP status code for Express error handling.
SourceAn object containing references to the source of the error
ApiError-
HrefWithMetaA link with an href and associated metadata.
IRelationshipSelfLinkA relationship link pointing to the relationship itself.
IRelationshipRelatedLinkA relationship link pointing to a related resource.
IRelationshipLinksContains the links for a JSON:API relationship.
IRelationshipDataContains the resource linkage data for a JSON:API relationship.
ApiResourceIdentifierObjectWithin a given API, each resource object's type and id pair MUST identify a single, unique resource. (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.)
ApiResourceObjectA JSON:API resource object with optional attributes, links, meta, and relationships.
JsonApiJSON:API version and metadata descriptor.
ApiResponseBaseBase interface for all JSON:API responses, including optional links and metadata.
ApiDataResponseA successful JSON:API response containing primary data and optional included resources.
ApiErrorResponseA JSON:API error response containing one or more error objects.

Type Aliases

Type AliasDescription
HttpMethodSupported HTTP methods for route definitions.
NoReqParamsDefault type for request route parameters.
NoResBodyDefault type for response body when none is specified.
NoReqBodyDefault type for request body when none is specified.
NoReqQueryDefault type for request query parameters.
NoLocalsDefault type for response locals.
LoggerMetaMetadata key-value pairs attached to log entries.
LoggerVerbosityApplication-level log verbosity levels.
LogFunction-
Logger-
ParseFuncA function that parses a string value into the target type.
ApiLinkA JSON:API link, either a simple URL string or an object with href and metadata.
ApiLinksA collection of named JSON:API links.
ResourceLinkageResource linkage in a compound document allows a client to link together all of the included resource objects without having to GET any URLs via links. Resource linkage MUST be represented as one of the following: • null for empty to-one relationships. • an empty array ([]) for empty to-many relationships. • a single resource identifier object for non-empty to-one relationships. • an array of resource identifier objects for non-empty to-many relationships.
RelationshipMetaNon-standard metadata associated with a JSON:API relationship.
RelationshipThe value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships") represent references from the resource object in which it’s defined to other resource objects. Relationships may be to-one or to-many.
ApiResponseA JSON:API response, either a data response or an error response.

Variables

VariableDescription
notImplementedExpress request handler that responds with a 501 Not Implemented error.
EmptyParamsZodEmpty Zod schema for requests with no parameters.
EmptyQueryParamsZodEmpty Zod schema for requests with no query parameters.
ValidateRequestDefaultsDefault validation schemas for request handler validator.
DefaultJsonBodyParserOptionsLimitThe default maximum request body size for the JSON Body Parser
DefaultJsonBodyParserOptionsTypesThe default MIME types for the JSON Body Parser
DefaultJsonBodyParserOptionsThe default options for the JSON Body Parser
jsonBodyParserA JSON Body Parser middleware handler initialized with the default options
standardResponsesConnect middleware to enable the transform of all responses to match the standard response format (compatible with JSON API)

Functions

FunctionDescription
addRouteDefinitionsRegisters an array of route definitions on an Express application.
asyncHandlerWraps an async Express request handler to forward rejected promises to the error handler.
errorToJsonHandlerExpress error handler that logs the error and sends a JSON response with the error message and status code.
getHttpHeaderSince there can be multiple of certain HTTP headers or to prevent ugliness if someone did send us multiple instances of a header we only expect one of, this method grabs the 1st/only one of the desired header
getDefaultLoggerReturns the singleton default logger instance, creating one if it does not exist.
getLoggerReturns a cached Winston-backed logger at the specified verbosity level.
compactObjectReturns a shallow copy of the object with all null and undefined values removed.
tryParse-
requestHandlerValidatorFactory for Express middleware that validates request and response objects using Zod schemas.
enableCaseSensitiveRoutingEnable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same.
disableCaseSensitiveRoutingDisable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same.
enableExpressDefaultPoweredByHeaderBy default Express appends the X-Powered-By: Express header to all responses. Calling this method enables that behavior.
disableExpressDefaultPoweredByHeaderBy default Express appends the X-Powered-By: Express header to all responses. Calling this method disables that behavior.
customPoweredByHeaderExpress middleware that sets the X-Powered-By header to 'XYO'.
getJsonBodyParserOptionsGets the default JSON Body Parser options merged with the supplied options with the supplied options taking precedence
getJsonBodyParserGet a JSON Body Parser connect middleware handler
useRequestCountersRegisters middleware that increments per-path request counters and exposes a /stats endpoint.
responseProfilerConnect middleware to enable profiling of response lifecycle timing. To effectively profile the response timing, this middleware needs to be called first when initializing your Express App
getResponseMetadataExtracts response metadata from res.locals, computing profile duration if profiling was started.
standardErrorsExpress error handler that logs the error and sends a JSON:API-compliant error response.
setRawResponseFormatFlags the response to forgo the standard response envelope and return the raw response body to the client
clearRawResponseFormatClears any flags on the response, allowing the response to use the default standard response envelope
isRawResponseFormatSetChecks if there are any flags on the response that would cause it to forgo the standard response envelope and return the raw response body to the client

classes

Counters

@xylabs/express

Static counter registry for tracking named numeric metrics.

Constructors

Constructor

new Counters(): Counters;

Returns

Counters

Properties

PropertyModifierTypeDefault value
countersstaticRecord<string, number>{}

Methods

inc()

static inc(name: string, count?: number): void;

Parameters

ParameterTypeDefault value
namestringundefined
countnumber1

Returns

void

max()

static max(name: string, count: number): void;

Parameters

ParameterType
namestring
countnumber

Returns

void

min()

static min(name: string, count: number): void;

Parameters

ParameterType
namestring
countnumber

Returns

void

Profiler

@xylabs/express

Measures and records the execution duration of async operations by name.

Constructors

Constructor

new Profiler(): Profiler;

Returns

Profiler

Properties

PropertyTypeDefault value
statsRecord<string, number>{}

Methods

profile()

profile<T>(name: string, promise: Promise<T>): Promise<T>;

Type Parameters

Type Parameter
T

Parameters

ParameterType
namestring
promisePromise<T>

Returns

Promise<T>

WrappedWinstonLogger

@xylabs/express

Wrap Winston logger methods to adapt to familiar console logging methods

Implements

  • Logger

Constructors

Constructor

new WrappedWinstonLogger(winston: Logger): WrappedWinstonLogger;

Parameters

ParameterType
winstonLogger

Returns

WrappedWinstonLogger

Properties

PropertyModifierType
winstonreadonlyLogger
debugpublicLogFunction
errorpublicLogFunction
infopublicLogFunction
logpublicLogFunction
tracepublicLogFunction
warnpublicLogFunction

functions

addRouteDefinitions

@xylabs/express

function addRouteDefinitions(app: Express, routeDefinitions: RouteDefinition<RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>[]): void;

Registers an array of route definitions on an Express application.

Parameters

ParameterTypeDescription
appExpressThe Express application to register routes on.
routeDefinitionsRouteDefinition<RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>[]The route definitions to register.

Returns

void

asyncHandler

@xylabs/express

function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>): (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => Promise<unknown>;

Wraps an async Express request handler to forward rejected promises to the error handler.

Type Parameters

Type ParameterDefault type
PParamsDictionary
ResBodyEmpty
ReqBodyEmpty
ReqQueryParsedQs
Locals extends NoLocalsNoLocals

Parameters

ParameterTypeDescription
fnRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>The async request handler to wrap.

Returns

A request handler that catches async errors and passes them to next().

(
   req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, 
   res: Response<ResBody, Locals>, 
next: NextFunction): Promise<unknown>;

Parameters

ParameterType
reqRequest<P, ResBody, ReqBody, ReqQuery, Locals>
resResponse<ResBody, Locals>
nextNextFunction

Returns

Promise<unknown>

clearRawResponseFormat

@xylabs/express

function clearRawResponseFormat(res: Response): void;

Clears any flags on the response, allowing the response to use the default standard response envelope

Parameters

ParameterTypeDescription
resResponseThe response to set to the standard response format

Returns

void

compactObject

@xylabs/express

function compactObject<T>(obj: T): T;

Returns a shallow copy of the object with all null and undefined values removed.

Type Parameters

Type Parameter
T extends Record<string, unknown>

Parameters

ParameterTypeDescription
objTThe object to compact.

Returns

T

A new object with only defined, non-null properties.

customPoweredByHeader

@xylabs/express

function customPoweredByHeader(
   req: Request, 
   res: Response, 
   next: NextFunction): void;

Express middleware that sets the X-Powered-By header to 'XYO'.

Parameters

ParameterType
reqRequest
resResponse
nextNextFunction

Returns

void

disableCaseSensitiveRouting

@xylabs/express

function disableCaseSensitiveRouting(app: Express): void;

Disable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same.

Parameters

ParameterTypeDescription
appExpressThe Express app to disable the header on.

Returns

void

disableExpressDefaultPoweredByHeader

@xylabs/express

function disableExpressDefaultPoweredByHeader(app: Express): void;

By default Express appends the X-Powered-By: Express header to all responses. Calling this method disables that behavior.

Parameters

ParameterTypeDescription
appExpressThe Express app to disable the header on.

Returns

void

enableCaseSensitiveRouting

@xylabs/express

function enableCaseSensitiveRouting(app: Express): void;

Enable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same.

Parameters

ParameterTypeDescription
appExpressThe Express app to disable the header on.

Returns

void

enableExpressDefaultPoweredByHeader

@xylabs/express

function enableExpressDefaultPoweredByHeader(app: Express): void;

By default Express appends the X-Powered-By: Express header to all responses. Calling this method enables that behavior.

Parameters

ParameterTypeDescription
appExpressThe Express app to disable the header on.

Returns

void

errorToJsonHandler

@xylabs/express

function errorToJsonHandler(
   error: ExpressError, 
   req: Request, 
   res: Response, 
   next: NextFunction): void;

Express error handler that logs the error and sends a JSON response with the error message and status code.

Parameters

ParameterTypeDescription
errorExpressErrorThe Express error to handle.
reqRequestThe incoming request.
resResponseThe outgoing response.
nextNextFunctionThe next middleware function.

Returns

void

getDefaultLogger

@xylabs/express

function getDefaultLogger(): Logger;

Returns the singleton default logger instance, creating one if it does not exist.

Returns

Logger

The default logger.

getHttpHeader

@xylabs/express

function getHttpHeader(header: string, req: Request): string | undefined;

Since there can be multiple of certain HTTP headers or to prevent ugliness if someone did send us multiple instances of a header we only expect one of, this method grabs the 1st/only one of the desired header

Parameters

ParameterTypeDescription
headerstringThe header to find
reqRequestThe received HTTP request (with headers)

Returns

string | undefined

The first or only occurrence of the specified HTTP header

getJsonBodyParser

@xylabs/express

function getJsonBodyParser(options?: OptionsJson): NextHandleFunction;

Get a JSON Body Parser connect middleware handler

Parameters

ParameterTypeDefault valueDescription
optionsOptionsJsonDefaultJsonBodyParserOptionsThe options for the JSON Body Parser

Returns

NextHandleFunction

A middleware function that parses JSON bodies

getJsonBodyParserOptions

@xylabs/express

function getJsonBodyParserOptions(options?: Partial<OptionsJson>): OptionsJson;

Gets the default JSON Body Parser options merged with the supplied options with the supplied options taking precedence

Parameters

ParameterTypeDescription
options?Partial<OptionsJson>The options to override the default JSON Body Parser options with

Returns

OptionsJson

The combined JSON Body Parser options with the supplied values taking precedence over the default

getLogger

@xylabs/express

function getLogger(minVerbosity?: LoggerVerbosity): Logger;

Returns a cached Winston-backed logger at the specified verbosity level.

Parameters

ParameterTypeDefault valueDescription
minVerbosityLoggerVerbosity'info'The minimum log level to output. Defaults to 'info'.

Returns

Logger

A logger instance configured for the given verbosity.

getResponseMetadata

@xylabs/express

function getResponseMetadata(res: Response): Record<string, unknown>;

Extracts response metadata from res.locals, computing profile duration if profiling was started.

Parameters

ParameterTypeDescription
resResponseThe Express response to extract metadata from.

Returns

Record<string, unknown>

The metadata record including any profiling information.

isRawResponseFormatSet

@xylabs/express

function isRawResponseFormatSet(res: Response): boolean;

Checks if there are any flags on the response that would cause it to forgo the standard response envelope and return the raw response body to the client

Parameters

ParameterTypeDescription
resResponse-

Returns

boolean

True if there are any flags on the response, false otherwise

requestHandlerValidator

@xylabs/express

function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas?: Partial<{
  body: TBody;
  params: TParams;
  query: TQuery;
  response: TResponse;
}>): (handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown) => RequestHandler;

Factory for Express middleware that validates request and response objects using Zod schemas.

Type Parameters

Type ParameterDefault type
TParams extends | ZodObject<{ }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>> | ZodType<Record<string, string>, unknown, $ZodTypeInternals<Record<string, string>, unknown>>ZodObject<{ }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>
TQuery extends | ZodObject<{ }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>> | ZodType<Record<string, string | string[]>, unknown, $ZodTypeInternals<Record<string, string | string[]>, unknown>>ZodObject<{ }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>
TBody extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
TResponse extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Parameters

ParameterTypeDescription
schemas?Partial<{ body: TBody; params: TParams; query: TQuery; response: TResponse; }>The Zod schemas to use for validation.

Returns

A middleware function for validating requests and responses.

(handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown): RequestHandler;

Parameters

ParameterType
handler(req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown

Returns

RequestHandler

responseProfiler

@xylabs/express

function responseProfiler(
   _req: Request, 
   res: Response, 
   next: NextFunction): void;

Connect middleware to enable profiling of response lifecycle timing. To effectively profile the response timing, this middleware needs to be called first when initializing your Express App

Parameters

ParameterTypeDescription
_reqRequestThe request
resResponseThe response
nextNextFunctionThe next function

Returns

void

Example

const app = express()
app.use(responseProfiler)
// other initialization ...

setRawResponseFormat

@xylabs/express

function setRawResponseFormat(res: Response): void;

Flags the response to forgo the standard response envelope and return the raw response body to the client

Parameters

ParameterTypeDescription
resResponseThe response to disable the standard response format on

Returns

void

standardErrors

@xylabs/express

function standardErrors(
   err: ExpressError | undefined, 
   req: Request, 
   res: Response, 
   next: NextFunction): void;

Express error handler that logs the error and sends a JSON:API-compliant error response.

Parameters

ParameterTypeDescription
errExpressError | undefinedThe error to handle, or undefined if no error.
reqRequestThe incoming request.
resResponseThe outgoing response.
nextNextFunctionThe next middleware function.

Returns

void

tryParse

@xylabs/express

function tryParse<T>(func: ParseFunc<T>, value?: string): 
  | T & {
}
  | undefined;

Type Parameters

Type ParameterDefault type
Tnumber

Parameters

ParameterType
funcParseFunc<T>
value?string

Returns

| T & { } | undefined

Deprecated

use zod instead

useRequestCounters

@xylabs/express

function useRequestCounters(app: Application): void;

Registers middleware that increments per-path request counters and exposes a /stats endpoint.

Parameters

ParameterTypeDescription
appApplicationThe Express application to attach counters to.

Returns

void

interfaces

ApiDataResponse

@xylabs/express

A successful JSON:API response containing primary data and optional included resources.

Extends

Type Parameters

Type Parameter
T extends ApiResourceIdentifierObject

Properties

PropertyTypeInherited from
jsonapi?JsonApiApiResponseBase.jsonapi
links?ApiLinksApiResponseBase.links
meta?Record<string, unknown>ApiResponseBase.meta
dataT-
included?ApiResourceObject[]-

ApiError

@xylabs/express

Properties

PropertyTypeDescription
code?stringAn application-specific error code, expressed as a string value.
detail?stringA human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.
id?stringA unique identifier for this particular occurrence of the problem.
links?ApiLinksA links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem
meta?Record<string, unknown>A meta object containing non-standard meta-information about the error.
source?SourceAn object containing references to the source of the error, optionally including any of the following members:
status?stringThe HTTP status code applicable to this problem, expressed as a string value.
title?stringA short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.

ApiErrorResponse

@xylabs/express

A JSON:API error response containing one or more error objects.

Extends

Properties

PropertyTypeInherited from
jsonapi?JsonApiApiResponseBase.jsonapi
links?ApiLinksApiResponseBase.links
meta?Record<string, unknown>ApiResponseBase.meta
errorsApiError[]-

ApiResourceIdentifierObject

@xylabs/express

Within a given API, each resource object's type and id pair MUST identify a single, unique resource. (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.)

Extended by

Properties

PropertyTypeDescription
idstringThe id member is not required when the resource object originates at the client and represents a new resource to be created on the server.
typestringThe type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names.

ApiResourceObject

@xylabs/express

A JSON:API resource object with optional attributes, links, meta, and relationships.

Extends

Properties

PropertyTypeDescriptionInherited from
idstringThe id member is not required when the resource object originates at the client and represents a new resource to be created on the server.ApiResourceIdentifierObject.id
typestringThe type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names.ApiResourceIdentifierObject.type
attributes?Record<string, unknown>An attributes object representing some of the resource's data.-
links?ApiLinksA links object containing links related to the resource.-
meta?Record<string, unknown>A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.-
relationships?Record<string, Relationship>A relationships object describing relationships between the resource and other JSON:API resources.-

ApiResponseBase

@xylabs/express

Base interface for all JSON:API responses, including optional links and metadata.

Extended by

Properties

PropertyType
jsonapi?JsonApi
links?ApiLinks
meta?Record<string, unknown>

Empty

@xylabs/express

Empty object type used as a default for request/response body generics.

ExpressError

@xylabs/express

An Error with an optional HTTP status code for Express error handling.

Extends

  • Error

Properties

PropertyType
statusCode?number

HrefWithMeta

@xylabs/express

A link with an href and associated metadata.

Properties

PropertyType
hrefstring
metaRecord<string, unknown>

IRelationshipData

@xylabs/express

Contains the resource linkage data for a JSON:API relationship.

Properties

PropertyType
dataResourceLinkage

@xylabs/express

Contains the links for a JSON:API relationship.

Properties

PropertyType
links| IRelationshipSelfLink | IRelationshipRelatedLink

@xylabs/express

A relationship link pointing to a related resource.

Properties

PropertyTypeDescription
relatedstringA related resource link

@xylabs/express

A relationship link pointing to the relationship itself.

Properties

PropertyTypeDescription
selfstringA link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data.

JsonApi

@xylabs/express

JSON:API version and metadata descriptor.

Properties

PropertyType
meta?Record<string, unknown>
version?"1.0" | "1.1"

LoggerOptions

@xylabs/express

Configuration options for creating a logger instance.

Properties

PropertyType
defaultMeta?LoggerMeta
level?LoggerVerbosity

RouteDefinition

@xylabs/express

Defines an Express route with its HTTP method, path, and handler(s).

Type Parameters

Type ParameterDefault type
H extends RequestHandlerRequestHandler

Properties

PropertyType
handlersH | H[]
methodHttpMethod
pathstring | RegExp

Source

@xylabs/express

An object containing references to the source of the error

Properties

PropertyTypeDescription
parameter?stringA string indicating which URI query parameter caused the error.
pointer?stringA JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].

type-aliases

@xylabs/express

type ApiLink = string | HrefWithMeta;

A JSON:API link, either a simple URL string or an object with href and metadata.

@xylabs/express

type ApiLinks = Record<string, ApiLink>;

A collection of named JSON:API links.

ApiResponse

@xylabs/express

type ApiResponse<T> = 
  | ApiDataResponse<T>
  | ApiErrorResponse;

A JSON:API response, either a data response or an error response.

Type Parameters

Type Parameter
T extends ApiResourceIdentifierObject

HttpMethod

@xylabs/express

type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "options" | "head";

Supported HTTP methods for route definitions.

LogFunction

@xylabs/express

type LogFunction = XyLabsLogFunction;

Deprecated

use from @xylabs/logger instead

Logger

@xylabs/express

type Logger = XyLabsLogger;

Deprecated

use from @xylabs/logger instead

LoggerMeta

@xylabs/express

type LoggerMeta = Record<string, string | number>;

Metadata key-value pairs attached to log entries.

LoggerVerbosity

@xylabs/express

type LoggerVerbosity = "error" | "warn" | "info" | "debug" | "all";

Application-level log verbosity levels.

NoLocals

@xylabs/express

type NoLocals = Record<string, any>;

Default type for response locals.

NoReqBody

@xylabs/express

type NoReqBody = Empty;

Default type for request body when none is specified.

NoReqParams

@xylabs/express

type NoReqParams = ParamsDictionary;

Default type for request route parameters.

NoReqQuery

@xylabs/express

type NoReqQuery = Query;

Default type for request query parameters.

NoResBody

@xylabs/express

type NoResBody = Empty;

Default type for response body when none is specified.

ParseFunc

@xylabs/express

type ParseFunc<T> = (value: string) => T;

A function that parses a string value into the target type.

Type Parameters

Type ParameterDefault type
Tnumber

Parameters

ParameterType
valuestring

Returns

T

Relationship

@xylabs/express

type Relationship = 
  | IRelationshipLinks
  | IRelationshipData
  | RelationshipMeta;

The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships") represent references from the resource object in which it’s defined to other resource objects. Relationships may be to-one or to-many.

RelationshipMeta

@xylabs/express

type RelationshipMeta = Record<string, unknown>;

Non-standard metadata associated with a JSON:API relationship.

ResourceLinkage

@xylabs/express

type ResourceLinkage = 
  | null
  | []
  | ApiResourceIdentifierObject
  | ApiResourceIdentifierObject[];

Resource linkage in a compound document allows a client to link together all of the included resource objects without having to GET any URLs via links. Resource linkage MUST be represented as one of the following: • null for empty to-one relationships. • an empty array ([]) for empty to-many relationships. • a single resource identifier object for non-empty to-one relationships. • an array of resource identifier objects for non-empty to-many relationships.

variables

DefaultJsonBodyParserOptions

@xylabs/express

const DefaultJsonBodyParserOptions: OptionsJson;

The default options for the JSON Body Parser

DefaultJsonBodyParserOptionsLimit

@xylabs/express

const DefaultJsonBodyParserOptionsLimit: "100kb" = '100kb';

The default maximum request body size for the JSON Body Parser

DefaultJsonBodyParserOptionsTypes

@xylabs/express

const DefaultJsonBodyParserOptionsTypes: string[];

The default MIME types for the JSON Body Parser

EmptyParamsZod

@xylabs/express

const EmptyParamsZod: ZodObject<{
}, $catchall<ZodString>>;

Empty Zod schema for requests with no parameters.

EmptyQueryParamsZod

@xylabs/express

const EmptyQueryParamsZod: ZodObject<{
}, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>;

Empty Zod schema for requests with no query parameters.

ValidateRequestDefaults

@xylabs/express

const ValidateRequestDefaults: {
  params: ZodObject<{
  }, $catchall<ZodString>>;
  query: ZodObject<{
  }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>;
  body: ZodOptional<ZodJSONSchema>;
  response: ZodOptional<ZodJSONSchema>;
};

Default validation schemas for request handler validator.

Type Declaration

NameTypeDefault value
paramsZodObject<{ }, $catchall<ZodString>>EmptyParamsZod
queryZodObject<{ }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>EmptyQueryParamsZod
bodyZodOptional<ZodJSONSchema>-
responseZodOptional<ZodJSONSchema>-

jsonBodyParser

@xylabs/express

const jsonBodyParser: NextHandleFunction;

A JSON Body Parser middleware handler initialized with the default options

notImplemented

@xylabs/express

const notImplemented: RequestHandler;

Express request handler that responds with a 501 Not Implemented error.

standardResponses

@xylabs/express

const standardResponses: RequestHandler;

Connect middleware to enable the transform of all responses to match the standard response format (compatible with JSON API)

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs

Keywords

xylabs

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts