Buckets:
| const { createHook } = require('node:async_hooks') | |
| const { test } = require('node:test') | |
| const Fastify = require('..') | |
| const remainingIds = new Set() | |
| createHook({ | |
| init (asyncId, type, triggerAsyncId, resource) { | |
| if (type === 'content-type-parser:run') { | |
| remainingIds.add(asyncId) | |
| } | |
| }, | |
| destroy (asyncId) { | |
| remainingIds.delete(asyncId) | |
| } | |
| }) | |
| const app = Fastify({ logger: false }) | |
| test('test async hooks', async (t) => { | |
| app.get('/', function (request, reply) { | |
| reply.send({ id: 42 }) | |
| }) | |
| app.post('/', function (request, reply) { | |
| reply.send({ id: 42 }) | |
| }) | |
| t.after(() => app.close()) | |
| const fastifyServer = await app.listen({ port: 0 }) | |
| const result1 = await fetch(fastifyServer, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ hello: 'world' }) | |
| }) | |
| t.assert.strictEqual(result1.status, 200) | |
| const result2 = await fetch(fastifyServer, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ hello: 'world' }) | |
| }) | |
| t.assert.strictEqual(result2.status, 200) | |
| const result3 = await fetch(fastifyServer) | |
| t.assert.strictEqual(result3.status, 200) | |
| t.assert.strictEqual(remainingIds.size, 0) | |
| }) | |
Xet Storage Details
- Size:
- 1.27 kB
- Xet hash:
- 8bf367165e87d1ebdd0c21ea587569a71c5d675dae4d3471e07d4f2807e21d0a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.