@rest-vir/implement-service 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,8 @@ import { type ContextInitParams } from './service-context-init.js';
12
12
  export type PostHookParams<Context = any, ServiceName extends string = any, EndpointsInit extends BaseServiceEndpointsInit | NoParam = NoParam, WebSocketsInit extends BaseServiceWebSocketsInit | NoParam = NoParam> = ContextInitParams<ServiceName, EndpointsInit, WebSocketsInit> & {
13
13
  originalResponseData: EndpointsInit extends NoParam ? unknown : WithFinalEndpointProps<Values<EndpointsInit>, Extract<keyof EndpointsInit, EndpointPathBase>>['ResponseType'];
14
14
  originalStatus: HttpStatus;
15
- context: Context;
15
+ /** This will be `undefined` if your `createContext` method rejects the request. */
16
+ context: Context | undefined;
16
17
  };
17
18
  /**
18
19
  * Type for `ServiceImplementationsParams.postHook`.
@@ -1,5 +1,5 @@
1
1
  import { type HttpMethod, type MaybePromise, type Values } from '@augment-vir/common';
2
- import { type BaseSearchParams, type BaseServiceEndpointsInit, type BaseServiceWebSocketsInit, type EndpointDefinition, type EndpointPathBase, type MinimalService, type NoParam, type WebSocketDefinition, type WithFinalEndpointProps, type WithFinalWebSocketProps } from '@rest-vir/define-service';
2
+ import { type BaseSearchParams, type BaseServiceEndpointsInit, type BaseServiceWebSocketsInit, type EndpointDefinition, type EndpointPathBase, type MinimalService, type NoParam, type PathParams, type WebSocketDefinition, type WithFinalEndpointProps, type WithFinalWebSocketProps } from '@rest-vir/define-service';
3
3
  import { type IncomingHttpHeaders } from 'node:http';
4
4
  import { type RequireExactlyOne } from 'type-fest';
5
5
  import { type ServerRequest, type ServerResponse } from '../util/data.js';
@@ -37,6 +37,7 @@ export type ContextInit<Context, ServiceName extends string, EndpointsInit exten
37
37
  * @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
38
38
  */
39
39
  export type ContextInitParams<ServiceName extends string = any, EndpointsInit extends BaseServiceEndpointsInit | NoParam = NoParam, WebSocketsInit extends BaseServiceWebSocketsInit | NoParam = NoParam> = {
40
+ pathParams: EndpointsInit extends NoParam ? Readonly<Record<string, string>> : PathParams<WithFinalWebSocketProps<Values<WebSocketsInit>, any>['path']> extends string ? Readonly<Record<PathParams<WithFinalWebSocketProps<Values<WebSocketsInit>, any>['path']>, string>> : Readonly<Record<string, string>>;
40
41
  searchParams: ReplaceUndefinedWithEmptyObject<(WebSocketsInit extends NoParam ? BaseSearchParams | undefined : WithFinalWebSocketProps<Values<WebSocketsInit>, any>['SearchParamsType']) | (EndpointsInit extends NoParam ? BaseSearchParams | undefined : WithFinalEndpointProps<Values<EndpointsInit>, any>['SearchParamsType'])>;
41
42
  service: MinimalService<ServiceName>;
42
43
  requestHeaders: IncomingHttpHeaders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rest-vir/implement-service",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Implement a service defined by @rest-vir/define-service.",
5
5
  "keywords": [
6
6
  "rest",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@augment-vir/assert": "^31.19.1",
43
43
  "@augment-vir/common": "^31.19.1",
44
- "@rest-vir/define-service": "^0.19.0",
44
+ "@rest-vir/define-service": "^0.19.1",
45
45
  "@types/ws": "^8.18.1",
46
46
  "fastify": "^5.3.3",
47
47
  "path-to-regexp": "^8.2.0",