content-type-parser.test-d.ts — fastify Source File
Architecture documentation for content-type-parser.test-d.ts, a typescript file in the fastify codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9ad71af2_215e_f629_f041_271cf6d2b63a["content-type-parser.test-d.ts"] 2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"] 9ad71af2_215e_f629_f041_271cf6d2b63a --> 2bf9986b_b7fb_0c78_f075_72fbe6f4672b 4285dbb5_245d_95e1_f339_579e1aa1d358["./request"] 9ad71af2_215e_f629_f041_271cf6d2b63a --> 4285dbb5_245d_95e1_f339_579e1aa1d358 1741b237_9033_f1d9_f91f_94ad04e621d4["tsd"] 9ad71af2_215e_f629_f041_271cf6d2b63a --> 1741b237_9033_f1d9_f91f_94ad04e621d4 bd94e3ff_2705_51a0_bac0_884f2c38b615["node:http"] 9ad71af2_215e_f629_f041_271cf6d2b63a --> bd94e3ff_2705_51a0_bac0_884f2c38b615 style 9ad71af2_215e_f629_f041_271cf6d2b63a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fastify, { FastifyBodyParser } from '../../fastify'
import { expectError, expectType } from 'tsd'
import { IncomingMessage } from 'node:http'
import { FastifyRequest } from '../../types/request'
expectType<void>(fastify().addContentTypeParser('contentType', function (request, payload, done) {
expectType<FastifyRequest>(request)
expectType<IncomingMessage>(payload)
done(null)
}))
// Body limit options
expectType<void>(fastify().addContentTypeParser('contentType', { bodyLimit: 99 }, function (request, payload, done) {
expectType<FastifyRequest>(request)
expectType<IncomingMessage>(payload)
done(null)
}))
// Array for contentType
expectType<void>(fastify().addContentTypeParser(['contentType'], function (request, payload, done) {
expectType<FastifyRequest>(request)
expectType<IncomingMessage>(payload)
done(null)
}))
// Body Parser - the generic after addContentTypeParser enforces the type of the `body` parameter as well as the value of the `parseAs` property
expectType<void>(fastify().addContentTypeParser<string>('bodyContentType', { parseAs: 'string' }, function (request, body, done) {
expectType<FastifyRequest>(request)
expectType<string>(body)
done(null)
}))
expectType<void>(fastify().addContentTypeParser<Buffer>('bodyContentType', { parseAs: 'buffer' }, function (request, body, done) {
expectType<FastifyRequest>(request)
expectType<Buffer>(body)
done(null)
}))
expectType<void>(fastify().addContentTypeParser('contentType', async function (request: FastifyRequest, payload: IncomingMessage) {
expectType<FastifyRequest>(request)
expectType<IncomingMessage>(payload)
return null
}))
expectType<void>(fastify().addContentTypeParser<string>('bodyContentType', { parseAs: 'string' }, async function (request: FastifyRequest, body: string) {
expectType<FastifyRequest>(request)
expectType<string>(body)
return null
}))
expectType<void>(fastify().addContentTypeParser<Buffer>('bodyContentType', { parseAs: 'buffer' }, async function (request: FastifyRequest, body: Buffer) {
expectType<FastifyRequest>(request)
expectType<Buffer>(body)
return null
}))
expectType<FastifyBodyParser<string>>(fastify().getDefaultJsonParser('error', 'ignore'))
expectError(fastify().getDefaultJsonParser('error', 'skip'))
expectError(fastify().getDefaultJsonParser('nothing', 'ignore'))
expectType<void>(fastify().removeAllContentTypeParsers())
expectError(fastify().removeAllContentTypeParsers('contentType'))
expectType<void>(fastify().removeContentTypeParser('contentType'))
expectType<void>(fastify().removeContentTypeParser(/contentType+.*/))
expectType<void>(fastify().removeContentTypeParser(['contentType', /contentType+.*/]))
expectError(fastify().removeContentTypeParser({}))
Domain
Dependencies
- ./request
- fastify.js
- node:http
- tsd
Source
Frequently Asked Questions
What does content-type-parser.test-d.ts do?
content-type-parser.test-d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain.
What does content-type-parser.test-d.ts depend on?
content-type-parser.test-d.ts imports 4 module(s): ./request, fastify.js, node:http, tsd.
Where is content-type-parser.test-d.ts in the architecture?
content-type-parser.test-d.ts is located at test/types/content-type-parser.test-d.ts (domain: CoreKernel, directory: test/types).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free