equipped 5.0.0-beta-5 → 5.0.0-beta-6

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [5.0.0-beta-6](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-5...v5.0.0-beta-6) (2024-05-30)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * res body defaults to any ([534b3a4](https://github.com/kevinand11/equipped/commit/534b3a4d20e832733a18b5f4735f9132d09669ad))
11
+
5
12
  ## [5.0.0-beta-5](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-4...v5.0.0-beta-5) (2024-05-30)
6
13
 
7
14
 
@@ -11,7 +11,7 @@ export declare class FastifyServer extends Server<FastifyRequest, FastifyReply>
11
11
  protected onLoad(): Promise<void>;
12
12
  protected registerRoute(route: FullRoute): void;
13
13
  protected startServer(port: number): Promise<boolean>;
14
- protected parse(req: FastifyRequest, res: FastifyReply): Promise<Request<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>>;
14
+ protected parse(req: FastifyRequest, res: FastifyReply): Promise<Request<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>>;
15
15
  makeController(cb: Defined<Route['handler']>): RouteHandlerMethod;
16
16
  makeMiddleware(cb: Defined<Route['middlewares']>[number]['cb']): preHandlerHookHandler<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
17
17
  makeErrorMiddleware(cb: Defined<Route['onError']>['cb']): (error: import("fastify").FastifyError, request: FastifyRequest<import("fastify").RouteGenericInterface, import("fastify").RawServerDefault, import("http").IncomingMessage, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown, import("fastify").FastifyBaseLogger, import("fastify/types/type-provider").ResolveFastifyRequestType<import("fastify").FastifyTypeProviderDefault, import("fastify").FastifySchema, import("fastify").RouteGenericInterface>>, reply: FastifyReply<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").RouteGenericInterface, unknown, import("fastify").FastifySchema, import("fastify").FastifyTypeProviderDefault, unknown>) => void;
@@ -1,4 +1,4 @@
1
1
  export declare const errorHandler: {
2
- cb: import("../types").ErrorHandler<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
2
+ cb: import("../types").ErrorHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
3
3
  onSetup?: import("../types").HandlerSetup | undefined;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  export declare const notFoundHandler: {
2
- cb: import("../types").RouteMiddlewareHandler<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
2
+ cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
3
3
  onSetup?: import("../types").HandlerSetup | undefined;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  export declare const parseAuthUser: {
2
- cb: import("../types").RouteMiddlewareHandler<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
2
+ cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
3
3
  onSetup?: import("../types").HandlerSetup | undefined;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  export declare const requireAuthUser: {
2
- cb: import("../types").RouteMiddlewareHandler<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
2
+ cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
3
3
  onSetup?: import("../types").HandlerSetup | undefined;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  export declare const requireRefreshUser: {
2
- cb: import("../types").RouteMiddlewareHandler<import("../types").Api<unknown, string, import("../types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
2
+ cb: import("../types").RouteMiddlewareHandler<import("../types").Api<any, string, import("../types").MethodTypes, any, Record<string, string>, Record<string, any>, import("../types").SupportedStatusCodes>>;
3
3
  onSetup?: import("../types").HandlerSetup | undefined;
4
4
  };
@@ -5,5 +5,5 @@ export declare class Router extends ClassPropertiesWrapper<AddMethodImpls> {
5
5
  #private;
6
6
  constructor(config?: GeneralConfig);
7
7
  include(router: Router): void;
8
- get routes(): Route<import("./types").ApiDef<import("./types").Api<unknown, string, import("./types").MethodTypes, unknown, Record<string, string>, Record<string, any>, import("./types").SupportedStatusCodes>>>[];
8
+ get routes(): Route<import("./types").ApiDef<import("./types").Api<any, string, import("./types").MethodTypes, any, Record<string, string>, Record<string, any>, import("./types").SupportedStatusCodes>>>[];
9
9
  }
@@ -1,7 +1,7 @@
1
1
  import { Enum } from '../enums/types';
2
2
  import { CustomError } from '../errors';
3
3
  import { FastifySchema } from 'fastify';
4
- import { JSONPrimitives, JSONValue } from '../types';
4
+ import { JSONValue } from '../types';
5
5
  import type { Request, Response } from './requests';
6
6
  export declare const Methods: {
7
7
  readonly get: "get";
@@ -25,10 +25,7 @@ export type SupportedStatusCodes = Enum<typeof StatusCodes>;
25
25
  type GoodStatusCodes = 200;
26
26
  type ApiErrors = Record<Exclude<SupportedStatusCodes, GoodStatusCodes>, JSONValue<CustomError['serializedErrors']>>;
27
27
  type ApiResponse<T, StatusCode extends SupportedStatusCodes> = Record<StatusCode, JSONValue<T>> | Omit<ApiErrors, StatusCode>;
28
- type Any = unknown;
29
- type Arrayable<T> = T | T[];
30
- type AllowedResponses = Arrayable<JSONPrimitives | Any>;
31
- export interface Api<Res = AllowedResponses, Key extends string = string, Method extends MethodTypes = MethodTypes, Body extends Any = Any, Params extends Record<string, string> = Record<string, string>, Query extends Record<string, any> = Record<string, any>, DefaultStatus extends SupportedStatusCodes = SupportedStatusCodes> {
28
+ export interface Api<Res = any, Key extends string = string, Method extends MethodTypes = MethodTypes, Body = any, Params extends Record<string, string> = Record<string, string>, Query extends Record<string, any> = Record<string, any>, DefaultStatus extends SupportedStatusCodes = SupportedStatusCodes> {
32
29
  key: Key;
33
30
  method: Method;
34
31
  response: Res;
@@ -73,7 +70,7 @@ export interface Route<Def extends ApiDef = ApiDef> {
73
70
  export type RouteConfig<T extends ApiDef = ApiDef> = Omit<Route<T>, 'method' | 'handler'>;
74
71
  export type GeneralConfig = Omit<RouteConfig, 'schema' | 'key'>;
75
72
  export type AddMethodImpls = {
76
- [Method in MethodTypes]: <T extends ApiDef<Api<AllowedResponses, string, Method>>>(route: RouteConfig<T>) => (handler: RouteHandler<InferApiFromApiDef<T>>) => Route<T>;
73
+ [Method in MethodTypes]: <T extends ApiDef<Api<any, string, Method>>>(route: RouteConfig<T>) => (handler: RouteHandler<InferApiFromApiDef<T>>) => Route<T>;
77
74
  };
78
75
  declare class MiddlewareHandler<Cb extends Function> {
79
76
  cb: Cb;
@@ -81,6 +78,6 @@ declare class MiddlewareHandler<Cb extends Function> {
81
78
  private constructor();
82
79
  static make<Cb extends Function>(cb: Cb, onSetup?: HandlerSetup): MiddlewareHandler<Cb>;
83
80
  }
84
- export declare const makeMiddleware: <Def extends Api<unknown, string, MethodTypes, unknown, Record<string, string>, Record<string, any>, SupportedStatusCodes> = Api<unknown, string, MethodTypes, unknown, Record<string, string>, Record<string, any>, SupportedStatusCodes>>(cb: RouteMiddlewareHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<RouteMiddlewareHandler<Def>>;
85
- export declare const makeErrorMiddleware: <Def extends Api<unknown, string, MethodTypes, unknown, Record<string, string>, Record<string, any>, SupportedStatusCodes> = Api<unknown, string, MethodTypes, unknown, Record<string, string>, Record<string, any>, SupportedStatusCodes>>(cb: ErrorHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<ErrorHandler<Def>>;
81
+ export declare const makeMiddleware: <Def extends Api<any, string, MethodTypes, any, Record<string, string>, Record<string, any>, SupportedStatusCodes> = Api<any, string, MethodTypes, any, Record<string, string>, Record<string, any>, SupportedStatusCodes>>(cb: RouteMiddlewareHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<RouteMiddlewareHandler<Def>>;
82
+ export declare const makeErrorMiddleware: <Def extends Api<any, string, MethodTypes, any, Record<string, string>, Record<string, any>, SupportedStatusCodes> = Api<any, string, MethodTypes, any, Record<string, string>, Record<string, any>, SupportedStatusCodes>>(cb: ErrorHandler<Def>, onSetup?: HandlerSetup | undefined) => MiddlewareHandler<ErrorHandler<Def>>;
86
83
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "equipped",
3
- "version": "5.0.0-beta-5",
3
+ "version": "5.0.0-beta-6",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",