Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"lint": "eslint",
"lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:typescript": "tstyche",
"test:unit": "c8 --100 node --test"
},
"keywords": [
Expand Down Expand Up @@ -68,7 +68,7 @@
"fastify": "^5.0.0",
"neostandard": "^0.13.0",
"rimraf": "^6.0.1",
"tsd": "^0.33.0"
"tstyche": "^7.0.0"
},
"dependencies": {
"fastify-plugin": "^5.0.0",
Expand All @@ -77,4 +77,4 @@
"publishConfig": {
"access": "public"
}
}
}
30 changes: 15 additions & 15 deletions types/index.test-d.ts → types/index.tst.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fastify, { FastifyInstance, FastifyReply, FastifyRequest, preHandlerHookHandler } from 'fastify'
import fastifyAuth from '..'
import { expectType } from 'tsd'
import { expect } from 'tstyche'
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts'

Expand All @@ -11,33 +11,33 @@ type Done = (error?: Error) => void
app.register(fastifyAuth).after((_err) => {
app.auth([
(request, reply, done) => {
expectType<FastifyRequest>(request)
expectType<FastifyReply>(reply)
expectType<Done>(done)
expect(request).type.toBe<FastifyRequest>()
expect(reply).type.toBe<FastifyReply>()
expect(done).type.toBe<Done>()
},
], { relation: 'or' })
app.auth([
(request, reply, done) => {
expectType<FastifyRequest>(request)
expectType<FastifyReply>(reply)
expectType<Done>(done)
expect(request).type.toBe<FastifyRequest>()
expect(reply).type.toBe<FastifyReply>()
expect(done).type.toBe<Done>()
},
], { run: 'all' })
app.auth([
(request, reply, done) => {
expectType<FastifyRequest>(request)
expectType<FastifyReply>(reply)
expectType<Done>(done)
expect(request).type.toBe<FastifyRequest>()
expect(reply).type.toBe<FastifyReply>()
expect(done).type.toBe<Done>()
},
])
app.auth([
function () {
expectType<FastifyInstance>(this)
expect(this).type.toBe<FastifyInstance>()
},
])
const auth = app.auth([() => {}])
expectType<preHandlerHookHandler>(auth)
app.get('/secret', { preHandler: auth }, () => {})
expect(auth).type.toBe<preHandlerHookHandler>()
app.get('/secret', { preHandler: auth }, () => { })
app.get('/private', { preHandler: [auth] }, () => {})
})

Expand Down Expand Up @@ -102,7 +102,7 @@ async function usersController (fastify: FastifyInstance): Promise<void> {
async () => ({ success: true })
)
}
await usersController(app)
usersController(app)

async function usersControllerV2 (fastify: FastifyInstance): Promise<void> {
fastify.patch<{
Expand All @@ -116,4 +116,4 @@ async function usersControllerV2 (fastify: FastifyInstance): Promise<void> {
async () => ({ success: true })
)
}
await usersControllerV2(app)
usersControllerV2(app)
Loading