Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coobaha/typed-fastify

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coobaha/typed-fastify - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

6

bin/gen.bin.js

@@ -10,5 +10,3 @@ #!/usr/bin/env node

const gen_1 = __importDefault(require("./gen"));
const glob_1 = __importDefault(require("glob"));
const util_1 = require("util");
const resolveGlobFiles = (0, util_1.promisify)(glob_1.default);
const glob_1 = require("glob");
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))

@@ -24,3 +22,3 @@ .command('gen [files]', 'Generates json schemas next to corresponding ts files', (yargs) => {

}, async (argv) => {
const files = await resolveGlobFiles(argv.files);
const files = await (0, glob_1.glob)(argv.files);
await (0, gen_1.default)({ files });

@@ -27,0 +25,0 @@ })

@@ -7,3 +7,3 @@ /// <reference types="node" />

import type { Stream } from 'stream';
export declare type StatusCode = 100 | '100' | 101 | '101' | 200 | '200' | 201 | '201' | 202 | '202' | 203 | '203' | 204 | '204' | 205 | '205' | 206 | '206' | 300 | '300' | 301 | '301' | 302 | '302' | 303 | '303' | 304 | '304' | 305 | '305' | 307 | '307' | 400 | '400' | 401 | '401' | 402 | '402' | 403 | '403' | 404 | '404' | 405 | '405' | 406 | '406' | 407 | '407' | 408 | '408' | 409 | '409' | 410 | '410' | 411 | '411' | 412 | '412' | 413 | '413' | 414 | '414' | 415 | '415' | 416 | '416' | 417 | '417' | 426 | '426' | 500 | '500' | 501 | '501' | 502 | '502' | 503 | '503' | 504 | '504' | 505 | '505';
export type StatusCode = 100 | '100' | 101 | '101' | 200 | '200' | 201 | '201' | 202 | '202' | 203 | '203' | 204 | '204' | 205 | '205' | 206 | '206' | 300 | '300' | 301 | '301' | 302 | '302' | 303 | '303' | 304 | '304' | 305 | '305' | 307 | '307' | 400 | '400' | 401 | '401' | 402 | '402' | 403 | '403' | 404 | '404' | 405 | '405' | 406 | '406' | 407 | '407' | 408 | '408' | 409 | '409' | 410 | '410' | 411 | '411' | 412 | '412' | 413 | '413' | 414 | '414' | 415 | '415' | 416 | '416' | 417 | '417' | 426 | '426' | 500 | '500' | 501 | '501' | 502 | '502' | 503 | '503' | 504 | '504' | 505 | '505';
export interface FastifyError extends Error {

@@ -14,3 +14,3 @@ code: string;

}
export declare type validResponses = object | string | Stream | Buffer | FastifyError;
export type validResponses = object | string | Stream | Buffer | FastifyError;
export interface Operation {

@@ -17,0 +17,0 @@ security?: unknown;

import type * as F from 'fastify';
import { RouteGenericInterface } from 'fastify/types/route';
import { FastifyRequestType, FastifyTypeProvider, FastifyTypeProviderDefault, ResolveFastifyRequestType } from 'fastify/types/type-provider';
import { Operation, Schema } from './schema';
declare const addSchema: <ServiceSchema extends Schema<string>, RawServer extends F.RawServerBase = import("http").Server, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, ContextConfig = unknown, S = Service<ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, Logger>>(fastify: F.FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, opts: {
declare const addSchema: <ServiceSchema extends Schema<string>, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, ContextConfig = unknown, S = Service<ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, Logger>>(fastify: F.FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, opts: {
jsonSchema: {

@@ -13,6 +14,6 @@ schema: Record<string, any>;

export default addSchema;
declare type Missing<Candidate extends any, MaybeRequired extends any> = [Candidate, MaybeRequired] extends [never, never] ? false : [Candidate] extends [never] ? true : [Candidate] extends [MaybeRequired] ? false : true;
declare type ExtractMethodPath<T extends string | number | symbol, M extends F.HTTPMethods> = T extends `${M} ${infer P}` ? [M, P] : never;
declare type MP<T extends string | number | symbol> = ExtractMethodPath<T, 'DELETE'> | ExtractMethodPath<T, 'GET'> | ExtractMethodPath<T, 'HEAD'> | ExtractMethodPath<T, 'PATCH'> | ExtractMethodPath<T, 'POST'> | ExtractMethodPath<T, 'PUT'> | ExtractMethodPath<T, 'OPTIONS'>;
declare type ExtractParams<T extends string | number | symbol, Acc = {}> = T extends `${infer _}:${infer P}/${infer R}` ? ExtractParams<R, Acc & {
type Missing<Candidate extends any, MaybeRequired extends any> = [Candidate, MaybeRequired] extends [never, never] ? false : [Candidate] extends [never] ? true : [Candidate] extends [MaybeRequired] ? false : true;
type ExtractMethodPath<T extends string | number | symbol, M extends F.HTTPMethods> = T extends `${M} ${infer P}` ? [M, P] : never;
type MP<T extends string | number | symbol> = ExtractMethodPath<T, 'DELETE'> | ExtractMethodPath<T, 'GET'> | ExtractMethodPath<T, 'HEAD'> | ExtractMethodPath<T, 'PATCH'> | ExtractMethodPath<T, 'POST'> | ExtractMethodPath<T, 'PUT'> | ExtractMethodPath<T, 'OPTIONS'>;
type ExtractParams<T extends string | number | symbol, Acc = {}> = T extends `${infer _}:${infer P}/${infer R}` ? ExtractParams<R, Acc & {
[_ in P]: string;

@@ -22,5 +23,6 @@ }> : T extends `${infer _}:${infer P}` ? Id<Acc & {

}> : Acc;
type ArrayTOrT<T> = T | T[];
interface Reply<Op extends Operation, Status, Content, Headers, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault> extends Omit<F.FastifyReply<RawServer, RawRequest, RawReply, Router<Op>, ContextConfig>, 'send' | 'status' | 'statusCode' | 'code' | 'redirect' | 'headers' | 'header' | 'request' | 'getHeader' | 'getHeaders' | 'then'> {
asReply(this: any): AsReply;
matches<P extends keyof ServiceSchema['paths'], IsKnown = P extends Path ? true : false, NewOp extends ServiceSchema['paths'][P] = ServiceSchema['paths'][P], S = keyof Get<NewOp, 'response'>, Content = Get<Get2<NewOp, 'response', S>, 'content'>, Headers = Get<Get2<NewOp, 'response', S>, 'headers'>>(this: any, path: IsKnown extends true ? P : Path): this is IsKnown extends true ? Reply<NewOp, S, Content, Headers, P, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig> : never;
matches<P extends keyof ServiceSchema['paths'], IsKnown = P extends Path ? true : false, NewOp extends ServiceSchema['paths'][P] = ServiceSchema['paths'][P], S = keyof Get<NewOp, 'response'>, Content = Get<Get2<NewOp, 'response', S>, 'content'>, Headers = Get<Get2<NewOp, 'response', S>, 'headers'>>(this: any, path: IsKnown extends true ? P : Path): this is IsKnown extends true ? Reply<Extract<NewOp, Operation>, S, Content, Headers, P, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig> : never;
send<AllHeaders = Get2<Op['response'], Status, 'headers'>, O = [Headers, AllHeaders], MissingHeaders = Missing<Headers, AllHeaders>, MissingStatus = [Status] extends [never] ? true : false>(...payload: [MissingStatus] extends [true] ? [Invalid<`Missing status`>] : [MissingHeaders] extends [true] ? [

@@ -46,3 +48,3 @@ Invalid<`Missing headers: [ ${Extract<keyof Omit<AllHeaders, keyof ([Headers] extends [never] ? {} : Headers)>, string>} ]. Please provide required headers before sending reply.`>

}
declare type OpaqueReply<Op extends Operation, Status, Content, Headers, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, Opaque = Reply<Op, Status, Content, Headers, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig>> = Status extends unknown ? Opaque : Content extends unknown ? Opaque : Headers extends unknown ? Opaque : never;
type OpaqueReply<Op extends Operation, Status, Content, Headers, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, Opaque = Reply<Op, Status, Content, Headers, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig>> = Status extends unknown ? Opaque : Content extends unknown ? Opaque : Headers extends unknown ? Opaque : never;
interface Invalid<msg = any> {

@@ -56,4 +58,4 @@ readonly __INVALID__: unique symbol;

export declare const asReply: (any: any) => AsReply;
declare type Get<T, P> = P extends keyof T ? T[P] : never;
declare type Get2<T, P, P2> = Get<Get<T, P>, P2>;
type Get<T, P> = P extends keyof T ? T[P] : never;
type Get2<T, P, P2> = Get<Get<T, P>, P2>;
interface Router<Op extends Operation> {

@@ -66,6 +68,6 @@ Querystring: Get<Op['request'], 'querystring'>;

}
declare type Id<T> = T extends infer U ? {
type Id<T> = T extends infer U ? {
[K in keyof U]: U[K];
} : never;
interface Request<ServiceSchema extends Schema, Op extends Operation, Path extends keyof ServiceSchema['paths'], RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, ContextConfig = F.ContextConfigDefault, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance, OpRequest extends Router<Op> = Router<Op>, PathParams = OpRequest['Params'] extends never ? ExtractParams<Path> : Id<Omit<ExtractParams<Path>, keyof OpRequest['Params']>>, RouteGeneric = OpRequest['Params'] extends [never] ? Omit<Router<Op>, 'Params'> & {
interface Request<ServiceSchema extends Schema, Op extends Operation, Path extends keyof ServiceSchema['paths'], RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, ContextConfig = F.ContextConfigDefault, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger, OpRequest extends Router<Op> = Router<Op>, PathParams = OpRequest['Params'] extends never ? ExtractParams<Path> : Id<Omit<ExtractParams<Path>, keyof OpRequest['Params']>>, RouteGeneric extends RouteGenericInterface = OpRequest['Params'] extends [never] ? Omit<Router<Op>, 'Params'> & {
Params: PathParams;

@@ -82,21 +84,22 @@ } : Omit<Router<Op>, 'Params'> & {

}
declare type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
declare type GetInvalidParamsValidation<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, DifferentKeys = Id<Omit<Router<Op>['Params'], keyof ExtractParams<Path>>>> = Router<Op>['Params'] extends never ? false : IsEqual<DifferentKeys, {}> extends false ? Invalid<`request.params keys doesn't match params from router path, probably due to typo in [ ${Extract<keyof DifferentKeys, string>} ] in path: [ ${Extract<MP<Path>[1], string>} ]`> : false;
declare type Handler<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, SchemaCompiler = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Op>>, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance, InvalidParams = GetInvalidParamsValidation<Op, Path, ServiceSchema>, ValidSchema = [Op['response'][keyof Op['response']]] extends [never] ? Invalid<`${Extract<Path, string>} - has no response, every path should have at least one response defined`> : InvalidParams extends Invalid ? InvalidParams : true, Status extends keyof Op['response'] = keyof Op['response']> = ValidSchema extends true ? (this: F.FastifyInstance<RawServer, RawRequest, RawReply, Logger>, request: Request<ServiceSchema, Op, Path, RawServer, RawRequest, ContextConfig, TypeProvider, RequestType, Logger>, reply: Reply<Op, never, never, never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig> & {
type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
type GetInvalidParamsValidation<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, DifferentKeys = Id<Omit<Router<Op>['Params'], keyof ExtractParams<Path>>>> = Router<Op>['Params'] extends never ? false : IsEqual<DifferentKeys, {}> extends false ? Invalid<`request.params keys doesn't match params from router path, probably due to typo in [ ${Extract<keyof DifferentKeys, string>} ] in path: [ ${Extract<MP<Path>[1], string>} ]`> : false;
type Handler<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig extends F.ContextConfigDefault = F.ContextConfigDefault, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Op>>, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger, InvalidParams = GetInvalidParamsValidation<Op, Path, ServiceSchema>, ValidSchema = [Op['response'][keyof Op['response']]] extends [never] ? Invalid<`${Extract<Path, string>} - has no response, every path should have at least one response defined`> : InvalidParams extends Invalid ? InvalidParams : true, Status extends keyof Op['response'] = keyof Op['response']> = ValidSchema extends true ? (this: F.FastifyInstance<RawServer, RawRequest, RawReply, Logger>, request: Request<ServiceSchema, Op, Path, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>, reply: Reply<Op, never, never, never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig> & {
readonly __unknownReply: unique symbol;
M: MP<Path>[0];
}) => AsReply | Promise<AsReply> : ValidSchema;
declare type HandlerObj<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, SchemaCompiler = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Op>>, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance> = F.RouteShorthandOptions<RawServer, RawRequest, RawReply, Router<Op>, ContextConfig, SchemaCompiler, TypeProvider, Logger> & {
handler: Handler<Op, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, Logger>;
type HandlerObj<Op extends Operation, Path extends keyof ServiceSchema['paths'], ServiceSchema extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig extends F.ContextConfigDefault = F.ContextConfigDefault, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends F.FastifyTypeProvider = F.FastifyTypeProviderDefault, RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Op>>, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger, _Handler = Handler<Op, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, RequestType, Logger>, _Request extends Request<any, any, any> = Parameters<Extract<_Handler, (...args: any) => any>>[0], _Reply extends Reply<any, any, any, any, any, any> = Parameters<Extract<_Handler, (...args: any) => any>>[1]> = Omit<F.RouteShorthandOptions<RawServer, RawRequest, RawReply, Router<Op>, ContextConfig, SchemaCompiler, TypeProvider, Logger>, 'preHandler'> & {
handler: _Handler;
preHandler?: ArrayTOrT<(this: F.FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, request: _Request, reply: _Reply, done: F.HookHandlerDoneFunction) => void>;
};
export declare type Service<S extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, SchemaCompiler = F.FastifySchema, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance> = {
[P in keyof S['paths']]: Handler<S['paths'][P], P, S, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<S['paths'][P]>>, Logger> | HandlerObj<S['paths'][P], P, S, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<S['paths'][P]>>, Logger>;
export type Service<S extends Schema, RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig extends F.ContextConfigDefault = F.ContextConfigDefault, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger> = {
[P in keyof S['paths']]: Handler<Extract<S['paths'][P], Operation>, P, S, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Extract<S['paths'][P], Operation>>>, Logger> | HandlerObj<Extract<S['paths'][P], Operation>, P, S, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Extract<S['paths'][P], Operation>>>, Logger>;
};
export declare type RequestHandler<ServiceSchema extends Schema, HandlerPaths extends keyof ServiceSchema['paths'], RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig = F.ContextConfigDefault, SchemaCompiler = F.FastifySchema, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, Logger extends F.FastifyLoggerInstance = F.FastifyLoggerInstance, S = Service<ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, Logger>, Paths = ServiceSchema['paths'], OpHandler = {
[Path in HandlerPaths]: Handler<Path extends keyof Paths ? Paths[Path] : never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Path extends keyof Paths ? Paths[Path] : never>>, Logger>;
export type RequestHandler<ServiceSchema extends Schema, HandlerPaths extends keyof ServiceSchema['paths'], RawServer extends F.RawServerBase = F.RawServerDefault, RawRequest extends F.RawRequestDefaultExpression<RawServer> = F.RawRequestDefaultExpression<RawServer>, RawReply extends F.RawReplyDefaultExpression<RawServer> = F.RawReplyDefaultExpression<RawServer>, ContextConfig extends F.ContextConfigDefault = F.ContextConfigDefault, SchemaCompiler extends F.FastifySchema = F.FastifySchema, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, Logger extends F.FastifyBaseLogger = F.FastifyBaseLogger, S = Service<ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, Logger>, Paths = ServiceSchema['paths'], OpHandler = {
[Path in HandlerPaths]: Handler<Path extends keyof Paths ? Extract<Paths[Path], Operation> : never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Path extends keyof Paths ? Extract<Paths[Path], Operation> : never>>, Logger>;
}[HandlerPaths], OpHandlerObj = {
[Path in HandlerPaths]: HandlerObj<Path extends keyof Paths ? Paths[Path] : never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Path extends keyof Paths ? Paths[Path] : never>>, Logger>;
[Path in HandlerPaths]: HandlerObj<Path extends keyof Paths ? Extract<Paths[Path], Operation> : never, Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig, SchemaCompiler, TypeProvider, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Path extends keyof Paths ? Extract<Paths[Path], Operation> : never>>, Logger>;
}[HandlerPaths]> = OpHandler extends (...args: any) => any ? {
Request: Parameters<OpHandler>[0];
AsFastifyRequest: Parameters<OpHandler>[0] extends F.FastifyRequest<any, any, any> ? F.FastifyRequest<Router<Paths[keyof Paths]>, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Paths[keyof Paths]>>> : never;
AsFastifyRequest: Parameters<OpHandler>[0] extends F.FastifyRequest<any, any, any> ? F.FastifyRequest<Router<Extract<Paths[keyof Paths], Operation>>, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger, ResolveFastifyRequestType<TypeProvider, SchemaCompiler, Router<Extract<Paths[keyof Paths], Operation>>>> : never;
Reply: Parameters<OpHandler>[1];

@@ -103,0 +106,0 @@ Return: AsReply | Promise<AsReply>;

{
"name": "@coobaha/typed-fastify",
"description": "opinionated types for fastify",
"version": "1.1.1",
"version": "1.1.2",
"bin": {

@@ -10,32 +10,34 @@ "tfs": "bin/gen.bin.js",

"dependencies": {
"@types/json-schema": "^7.0.11",
"crypto-js": "^4.1.1",
"glob": "^8.0.3",
"glob": "^10.2.5",
"json-schema-merge-allof": "^0.8.1",
"json-schema-traverse": "^1.0.0",
"typescript-json-schema": "^0.54.0",
"yargs": "^17.5.1"
"typescript-json-schema": "^0.56.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@fastify/swagger": "^7.5.1",
"@fastify/swagger": "^8.4.0",
"@fastify/swagger-ui": "^1.8.1",
"@types/crypto-js": "^4.1.1",
"@types/glob": "^8.0.0",
"@types/glob": "^8.1.0",
"@types/json-schema-merge-allof": "^0.6.1",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@types/split2": "^3.2.1",
"@types/tap": "^15.0.7",
"@types/yargs": "^17.0.12",
"fastify": "^4.6.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"pino-pretty": "^9.1.0",
"@types/node": "^20.2.1",
"@types/prettier": "^2.7.2",
"@types/split2": "^4.2.0",
"@types/tap": "^15.0.8",
"@types/yargs": "^17.0.24",
"fastify": "^4.17.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"pino-pretty": "^10.0.0",
"pinst": "^3.0.0",
"prettier": "^2.7.1",
"split2": "^4.1.0",
"syncpack": "^8.2.4",
"tap": "^16.3.0",
"prettier": "^2.8.8",
"split2": "^4.2.0",
"syncpack": "^9.8.6",
"tap": "^16.3.4",
"ts-node-dev": "^2.0.0",
"tsd": "^0.24.1",
"type-fest": "^2.19.0",
"typescript": "^4.8.3"
"tsd": "^0.28.1",
"type-fest": "^3.10.0",
"typescript": "^5.0.4"
},

@@ -66,3 +68,3 @@ "directories": {

"main": "lib/index.js",
"packageManager": "yarn@3.2.3",
"packageManager": "pnpm@8.5.0",
"peerDependencies": {

@@ -74,9 +76,7 @@ "fastify": "^4"

"build": "tsc -p src && tsc -p generator",
"postinstall": "husky install",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable",
"_postinstall": "husky install",
"preserver": "tsnd generator/gen.bin.ts gen 'test/test_schema.ts'",
"pretest": "tsnd generator/gen.bin.ts gen 'test/test_schema.ts'",
"server": "tsnd test/server.ts",
"test": "yarn test:types && yarn test:integration",
"server": "pnpm preserver && tsnd test/server.ts",
"test": "pnpm pretest && pnpm test:types && pnpm test:integration",
"test:integration": "TAP_TS=1 tap test/*.test.ts -R terse --no-check-coverage",

@@ -83,0 +83,0 @@ "test:types": "tsc -p test/tsconfig.test.json"

@@ -28,3 +28,6 @@ # Typed Fastify

pnpm i @coobaha/typed-fastify
yarn add @coobaha/typed-fastify
```

@@ -31,0 +34,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc