Skip to content

Commit

Permalink
adding type for fastify.routing (#3270)
Browse files Browse the repository at this point in the history
  • Loading branch information
axe-me committed Aug 21, 2021
1 parent 9cdc897 commit fb29ece
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/types/instance.test-d.ts
Expand Up @@ -2,8 +2,8 @@ import fastify, {
FastifyBodyParser,
FastifyError,
FastifyInstance,
FastifyLoggerInstance,
ValidationResult
RawReplyDefaultExpression,
RawRequestDefaultExpression
} from '../../fastify'
import { expectAssignable, expectError, expectNotAssignable, expectType } from 'tsd'
import { FastifyRequest } from '../../types/request'
Expand Down Expand Up @@ -100,6 +100,8 @@ expectAssignable<void>(server.listen({ port: 3000 }, () => {}))
expectAssignable<void>(server.listen({ port: 3000, host: '0.0.0.0' }, () => {}))
expectAssignable<void>(server.listen({ port: 3000, host: '0.0.0.0', backlog: 42 }, () => {}))

expectAssignable<void>(server.routing({} as RawRequestDefaultExpression, {} as RawReplyDefaultExpression))

expectType<FastifyInstance>(fastify().get('/', {
handler: () => {},
errorHandler: (error, request, reply) => {
Expand Down
1 change: 1 addition & 0 deletions types/instance.d.ts
Expand Up @@ -82,6 +82,7 @@ export interface FastifyInstance<

register: FastifyRegister<FastifyInstance<RawServer, RawRequest, RawReply, Logger> & PromiseLike<undefined>>;

routing(req: RawRequest, res: RawReply): void;
getDefaultRoute: DefaultRoute<RawRequest, RawReply>;
setDefaultRoute(defaultRoute: DefaultRoute<RawRequest, RawReply>): void;

Expand Down

0 comments on commit fb29ece

Please sign in to comment.