promises.test.js — fastify Source File
Architecture documentation for promises.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const assert = require('node:assert')
const fastify = require('..')()
test.after(() => fastify.close())
const opts = {
schema: {
response: {
'2xx': {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
}
}
fastify.get('/return', opts, function (req, reply) {
const promise = new Promise((resolve, reject) => {
resolve({ hello: 'world' })
})
return promise
})
fastify.get('/return-error', opts, function (req, reply) {
const promise = new Promise((resolve, reject) => {
reject(new Error('some error'))
})
return promise
})
fastify.get('/double', function (req, reply) {
setTimeout(function () {
// this should not throw
reply.send({ hello: 'world' })
}, 20)
return Promise.resolve({ hello: '42' })
})
fastify.get('/thenable', opts, function (req, reply) {
setImmediate(function () {
reply.send({ hello: 'world' })
})
return reply
})
fastify.get('/thenable-error', opts, function (req, reply) {
setImmediate(function () {
reply.send(new Error('kaboom'))
})
return reply
})
fastify.get('/return-reply', opts, function (req, reply) {
// ... (66 more lines)
Source
Frequently Asked Questions
What does promises.test.js do?
promises.test.js is a source file in the fastify codebase, written in javascript.
Where is promises.test.js in the architecture?
promises.test.js is located at test/promises.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free