Skip to main content Link Search Menu Expand Document (external link)

HttpApiMiddleware overview

Added in v1.0.0


Table of contents


guards

isSecurity

Signature

export declare const isSecurity: (u: TagClassAny) => u is TagClassSecurityAny

Added in v1.0.0

models

HttpApiMiddleware (interface)

Signature

export interface HttpApiMiddleware<Provides, E> extends Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided> {}

Added in v1.0.0

HttpApiMiddleware (namespace)

Added in v1.0.0

Any (interface)

Signature

export interface Any {
  readonly [TypeId]: TypeId
}

Added in v1.0.0

AnyId (interface)

Signature

export interface AnyId {
  readonly [TypeId]: {
    readonly provides: any
  }
}

Added in v1.0.0

Error (type alias)

Signature

export type Error<A> = A extends { readonly [TypeId]: { readonly failure: infer E } } ? E : never

Added in v1.0.0

ErrorContext (type alias)

Signature

export type ErrorContext<A> = A extends { readonly [TypeId]: { readonly failureContext: infer R } } ? R : never

Added in v1.0.0

ExtractProvides (type alias)

Signature

export type ExtractProvides<A> = Provides<Only<A>>

Added in v1.0.0

Only (type alias)

Signature

export type Only<R> = Extract<R, AnyId>

Added in v1.0.0

Provides (type alias)

Signature

export type Provides<A> = A extends { readonly [TypeId]: { readonly provides: infer P } } ? P : never

Added in v1.0.0

Without (type alias)

Signature

export type Without<R> = Exclude<R, AnyId>

Added in v1.0.0

HttpApiMiddlewareSecurity (type alias)

Signature

export type HttpApiMiddlewareSecurity<Security extends Record<string, HttpApiSecurity.HttpApiSecurity>, Provides, E> = {
  readonly [K in keyof Security]: (
    _: HttpApiSecurity.HttpApiSecurity.Type<Security[K]>
  ) => Effect.Effect<Provides, E, HttpRouter.HttpRouter.Provided>
}

Added in v1.0.0

TagClass (type alias)

Signature

export type TagClass<Self, Name extends string, Options> = Options extends {
  readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>
}
  ? TagClass.BaseSecurity<
      Self,
      Name,
      Options,
      Simplify<
        HttpApiMiddlewareSecurity<Options["security"], TagClass.Service<Options>, TagClass.FailureService<Options>>
      >,
      Options["security"]
    >
  : TagClass.Base<Self, Name, Options, HttpApiMiddleware<TagClass.Service<Options>, TagClass.FailureService<Options>>>

Added in v1.0.0

TagClass (namespace)

Added in v1.0.0

Base (interface)

Signature

export interface Base<Self, Name extends string, Options, Service> extends Context.Tag<Self, Service> {
  new (_: never): Context.TagClassShape<Name, Service> & {
    readonly [TypeId]: {
      readonly provides: Provides<Options>
      readonly failure: Failure<Options>
      readonly failureContext: FailureContext<Options>
    }
  }
  readonly [TypeId]: TypeId
  readonly optional: Optional<Options>
  readonly failure: FailureSchema<Options>
  readonly provides: Options extends { readonly provides: Context.Tag<any, any> } ? Options["provides"] : undefined
}

Added in v1.0.0

BaseSecurity (interface)

Signature

export interface BaseSecurity<
  Self,
  Name extends string,
  Options,
  Service,
  Security extends Record<string, HttpApiSecurity.HttpApiSecurity>
> extends Base<Self, Name, Options, Service> {
  readonly [SecurityTypeId]: SecurityTypeId
  readonly security: Security
}

Added in v1.0.0

Failure (type alias)

Signature

export type Failure<Options> = Options extends {
  readonly failure: Schema.Schema<infer _A, infer _I, infer _R>
  readonly optional?: false
}
  ? _A
  : never

Added in v1.0.0

FailureContext (type alias)

Signature

export type FailureContext<Options> = Schema.Schema.Context<FailureSchema<Options>>

Added in v1.0.0

FailureSchema (type alias)

Signature

export type FailureSchema<Options> = Options extends { readonly failure: Schema.Schema.All; readonly optional?: false }
  ? Options["failure"]
  : typeof Schema.Never

Added in v1.0.0

FailureService (type alias)

Signature

export type FailureService<Options> = Optional<Options> extends true ? unknown : Failure<Options>

Added in v1.0.0

Optional (type alias)

Signature

export type Optional<Options> = Options extends { readonly optional: true } ? true : false

Added in v1.0.0

Provides (type alias)

Signature

export type Provides<Options> = Options extends {
  readonly provides: Context.Tag<any, any>
  readonly optional?: false
}
  ? Context.Tag.Identifier<Options["provides"]>
  : never

Added in v1.0.0

Service (type alias)

Signature

export type Service<Options> = Options extends { readonly provides: Context.Tag<any, any> }
  ? Context.Tag.Service<Options["provides"]>
  : void

Added in v1.0.0

TagClassAny (interface)

Signature

export interface TagClassAny extends Context.Tag<any, HttpApiMiddleware.Any> {
  readonly [TypeId]: TypeId
  readonly optional: boolean
  readonly provides?: Context.Tag<any, any>
  readonly failure: Schema.Schema.All
}

Added in v1.0.0

TagClassSecurityAny (interface)

Signature

export interface TagClassSecurityAny extends TagClassAny {
  readonly [SecurityTypeId]: SecurityTypeId
  readonly security: Record<string, HttpApiSecurity.HttpApiSecurity>
}

Added in v1.0.0

tags

Tag

Signature

export declare const Tag: <Self>() => <
  const Name extends string,
  const Options extends {
    readonly optional?: boolean
    readonly failure?: Schema.Schema.All
    readonly provides?: Context.Tag<any, any>
    readonly security?: Record<string, HttpApiSecurity.HttpApiSecurity>
  }
>(
  id: Name,
  options?: Options | undefined
) => TagClass<Self, Name, Options>

Added in v1.0.0

type ids

SecurityTypeId

Signature

export declare const SecurityTypeId: typeof SecurityTypeId

Added in v1.0.0

SecurityTypeId (type alias)

Signature

export type SecurityTypeId = typeof SecurityTypeId

Added in v1.0.0

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0