constrained-routes.test.js — fastify Source File
Architecture documentation for constrained-routes.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('../fastify')
test('Should register a host constrained route', async t => {
t.plan(4)
const fastify = Fastify()
fastify.route({
method: 'GET',
url: '/',
constraints: { host: 'fastify.dev' },
handler: (req, reply) => {
reply.send({ hello: 'world' })
}
})
{
const res = await fastify.inject({
method: 'GET',
url: '/',
headers: {
host: 'fastify.dev'
}
})
t.assert.deepStrictEqual(JSON.parse(res.payload), { hello: 'world' })
t.assert.strictEqual(res.statusCode, 200)
}
{
const res = await fastify.inject({
method: 'GET',
url: '/',
headers: {
host: 'example.com'
}
})
t.assert.strictEqual(res.statusCode, 404)
}
{
const res = await fastify.inject({
method: 'GET',
url: '/'
})
t.assert.strictEqual(res.statusCode, 404)
}
})
test('Should register the same route with host constraints', async t => {
t.plan(5)
const fastify = Fastify()
fastify.route({
method: 'GET',
url: '/',
constraints: { host: 'fastify.dev' },
handler: (req, reply) => {
// ... (1079 more lines)
Source
Frequently Asked Questions
What does constrained-routes.test.js do?
constrained-routes.test.js is a source file in the fastify codebase, written in javascript.
Where is constrained-routes.test.js in the architecture?
constrained-routes.test.js is located at test/constrained-routes.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free