Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/homebridge-config-ui-x/node_modules/middie/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
const { test } = require('tap')
const Fastify = require('fastify')
const sget = require('simple-get').concat
const cors = require('cors')
const middiePlugin = require('../index')
test('Should enhance the Node.js core request/response objects', t => {
t.plan(9)
const fastify = Fastify()
t.teardown(fastify.close)
fastify.register(middiePlugin)
.after(() => { fastify.use(cors()) })
fastify.get('/', async (req, reply) => {
t.equal(req.raw.originalUrl, req.raw.url)
t.equal(req.raw.id, req.id)
t.equal(req.raw.hostname, req.hostname)
t.equal(req.raw.ip, req.ip)
t.same(req.raw.ips, req.ips)
t.ok(req.raw.log)
t.ok(reply.raw.log)
return { hello: 'world' }
})
fastify.listen(0, (err, address) => {
t.error(err)
sget({
method: 'GET',
url: address
}, (err, res, data) => {
t.error(err)
})
})
})
test('Should not enhance the Node.js core request/response objects when there are no middlewares', t => {
t.plan(9)
const fastify = Fastify()
t.teardown(fastify.close)
fastify.register(middiePlugin)
fastify.get('/', async (req, reply) => {
t.equal(req.raw.originalUrl, undefined)
t.equal(req.raw.id, undefined)
t.equal(req.raw.hostname, undefined)
t.equal(req.raw.ip, undefined)
t.equal(req.raw.ips, undefined)
t.notOk(req.raw.log)
t.notOk(reply.raw.log)
return { hello: 'world' }
})
fastify.listen(0, (err, address) => {
t.error(err)
sget({
method: 'GET',
url: address
}, (err, res, data) => {
t.error(err)
})
})
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |