Skip to content

Commit

Permalink
#180 Fixing typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
stazz committed Feb 13, 2024
1 parent 323994d commit b9c02d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
34 changes: 34 additions & 0 deletions code/backend-express-io-ts-openapi/src/endpoint-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,40 @@ export type ApplicationBuilder<
TAdditionalDataSpecHKT
>;

/**
* This is helper type to have both {@link server.ServerContext} and `never` as context types of {@link ApplicationBuilder}.
*/
export type ApplicationBuilderAny<
TAuthenticatedState extends TStateSpecBase = typeof DEFAULT_AUTHENTICATED_STATE,
TOtherState extends TStateSpecBase = typeof DEFAULT_NOT_AUTHENTICATED_STATE,
TAllRequestBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TAllResponseBodyContentTypes extends string = typeof dataIO.CONTENT_TYPE,
TDefaultRequestBodyContentType extends TAllRequestBodyContentTypes = TAllRequestBodyContentTypes,
TDefaultResponseBodyContentType extends TAllResponseBodyContentTypes = TAllResponseBodyContentTypes,
// TMetadataProviders extends epSpec.TMetadataProvidersBase = MetadataProviders,
TAdditionalDataSpecHKT extends epSpec.EndpointSpecAdditionalDataHKTBase = epSpec.NoAdditionalSpecDataHKT,
> =
| ApplicationBuilder<
server.ServerContext,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>
| ApplicationBuilder<
never,
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
TAllResponseBodyContentTypes,
TDefaultRequestBodyContentType,
TDefaultResponseBodyContentType,
TAdditionalDataSpecHKT
>;

/**
* This is the {@link dataBE.MaterializeStateInfo} type for {@link DefaultStateHKT}.
*/
Expand Down
10 changes: 4 additions & 6 deletions code/backend-express-io-ts-openapi/src/md-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as epSpec from "./endpoint-spec";
* @returns All of the endpoints of `creationResult` along with endpoints to serve the OpenAPI document.
*/
export function endpointsWithOpenAPI(
builder: epSpec.ApplicationBuilder<server.ServerContext | never>,
builder: epSpec.ApplicationBuilderAny,
creationResult: epSpecBase.EndpointsCreationResult<
epSpec.MetadataProviders,
server.ServerContext,
Expand Down Expand Up @@ -58,8 +58,7 @@ export function endpointsWithOpenAPI<
...Array<keyof TAuthenticatedState>,
],
>(
builder: epSpec.ApplicationBuilder<
server.ServerContext | never,
builder: epSpec.ApplicationBuilderAny<
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand Down Expand Up @@ -112,8 +111,7 @@ export function endpointsWithOpenAPI<
...Array<keyof TAuthenticatedState>,
],
>(
builder: epSpec.ApplicationBuilder<
server.ServerContext | never,
builder: epSpec.ApplicationBuilderAny<
TAuthenticatedState,
TOtherState,
TAllRequestBodyContentTypes,
Expand All @@ -140,7 +138,7 @@ export function endpointsWithOpenAPI<
>,
openAPIPath?: string,
): MutableServerEndpoints<TAuthenticatedState, TOtherState> {
const noMD = builder.resetMetadataProviders();
const noMD = builder.showContextToEndpoints().resetMetadataProviders();
const noURLParameters = noMD.url``({});
const params: ParametersValidation<
TAuthenticatedState,
Expand Down

0 comments on commit b9c02d2

Please sign in to comment.