Buckets:
| const { test } = require('node:test') | |
| const { kRouteContext } = require('../lib/symbols') | |
| const fastify = require('..') | |
| test('handlers receive correct `this` context', async (t) => { | |
| t.plan(4) | |
| // simulate plugin that uses fastify-plugin | |
| const plugin = function (instance, opts, done) { | |
| instance.decorate('foo', 'foo') | |
| done() | |
| } | |
| plugin[Symbol.for('skip-override')] = true | |
| const instance = fastify() | |
| instance.register(plugin) | |
| instance.get('/', function (req, reply) { | |
| t.assert.ok(this.foo) | |
| t.assert.strictEqual(this.foo, 'foo') | |
| reply.send() | |
| }) | |
| await instance.inject('/') | |
| t.assert.ok(instance.foo) | |
| t.assert.strictEqual(instance.foo, 'foo') | |
| }) | |
| test('handlers have access to the internal context', async (t) => { | |
| t.plan(5) | |
| const instance = fastify() | |
| instance.get('/', { config: { foo: 'bar' } }, function (req, reply) { | |
| t.assert.ok(reply[kRouteContext]) | |
| t.assert.ok(reply[kRouteContext].config) | |
| t.assert.ok(typeof reply[kRouteContext].config, Object) | |
| t.assert.ok(reply[kRouteContext].config.foo) | |
| t.assert.strictEqual(reply[kRouteContext].config.foo, 'bar') | |
| reply.send() | |
| }) | |
| await instance.inject('/') | |
| }) | |
Xet Storage Details
- Size:
- 1.2 kB
- Xet hash:
- f5125f1ee2015c523f97dfd4ae4c98a4f525525edfe424ff0748469b38235de1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.