diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baa6d2b..d891a1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [10, 12, 14, 16] + node-version: [14, 16, 18] os: [macos-latest, ubuntu-latest, windows-latest] steps: diff --git a/index.js b/index.js index acb1ad5..7921d9d 100644 --- a/index.js +++ b/index.js @@ -252,7 +252,7 @@ function now () { } module.exports = fp(underPressure, { - fastify: '3.x', + fastify: '4.x', name: 'under-pressure' }) diff --git a/package.json b/package.json index 507ec3a..4e83085 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@types/node": "^17.0.7", - "fastify": "^3.0.0", + "fastify": "^4.0.0-rc.2", "pre-commit": "^1.2.2", "semver": "^7.3.2", "simple-get": "^4.0.0", @@ -40,8 +40,5 @@ "tap": "^16.2.0", "tsd": "^0.20.0", "typescript": "^4.0.3" - }, - "engines": { - "node": ">=10" } } diff --git a/test/pressurehandler.test.js b/test/pressurehandler.test.js index 34bdf9f..92de5a9 100644 --- a/test/pressurehandler.test.js +++ b/test/pressurehandler.test.js @@ -121,7 +121,7 @@ test('event loop delay', { skip: !monitorEventLoopDelay }, t => { fastify.get('/', (req, rep) => rep.send('A')) - fastify.listen(0, async (err, address) => { + fastify.listen({ port: 0 }, async (err, address) => { t.error(err) fastify.server.unref() @@ -154,7 +154,7 @@ test('heap bytes', t => { fastify.get('/', (req, rep) => rep.send('A')) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -186,7 +186,7 @@ test('rss bytes', t => { fastify.get('/', (req, rep) => rep.send('A')) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -218,7 +218,7 @@ test('event loop utilization', { skip: !isSupportedVersion }, t => { fastify.get('/', async (req, rep) => rep.send('A')) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -263,7 +263,7 @@ test('event loop delay (NaN)', { skip: !isSupportedVersion }, t => { fastify.get('/', async (req, rep) => rep.send('A')) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() diff --git a/test/statusRoute.test.js b/test/statusRoute.test.js index 0a5b9a0..a997ee1 100644 --- a/test/statusRoute.test.js +++ b/test/statusRoute.test.js @@ -20,7 +20,7 @@ test('Expose status route', t => { exposeStatusRoute: true }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -70,7 +70,7 @@ test('Expose status route with additional route options', t => { const customConfig = { customVal: 'someVal' } - const fastify = Fastify() + const fastify = Fastify({ exposeHeadRoutes: false }) fastify.addHook('onRoute', (routeOptions) => { fastify.server.unref() @@ -97,7 +97,7 @@ test('Expose status route with additional route options', t => { test('Expose status route with additional route options and default url', t => { t.plan(2) - const fastify = Fastify() + const fastify = Fastify({ exposeHeadRoutes: false }) fastify.addHook('onRoute', (routeOptions) => { fastify.server.unref() @@ -121,7 +121,7 @@ test('Expose status route with additional route options and default url', t => { test('Expose status route with additional route options, route schema options', t => { const routeSchemaOpts = { hide: true } - const fastify = Fastify() + const fastify = Fastify({ exposeHeadRoutes: false }) fastify.addHook('onRoute', (routeOptions) => { fastify.server.unref() @@ -158,7 +158,7 @@ test('Expose status route with additional route options, route schema options', test('Expose status route with additional route options, route schema options and default url', t => { const routeSchemaOpts = { hide: true } - const fastify = Fastify() + const fastify = Fastify({ exposeHeadRoutes: false }) fastify.addHook('onRoute', (routeOptions) => { fastify.server.unref() diff --git a/test/test.js b/test/test.js index 6763fac..f8087d8 100644 --- a/test/test.js +++ b/test/test.js @@ -22,7 +22,7 @@ test('Should return 503 on maxEventLoopDelay', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, async (err, address) => { + fastify.listen({ port: 0 }, async (err, address) => { t.error(err) fastify.server.unref() @@ -65,7 +65,7 @@ test('Should return 503 on maxEventloopUtilization', { skip: !isSupportedVersion reply.send({ hello: 'world' }) }) - fastify.listen(0, async (err, address) => { + fastify.listen({ port: 0 }, async (err, address) => { t.error(err) fastify.server.unref() @@ -102,7 +102,7 @@ test('Should return 503 on maxHeapUsedBytes', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -138,7 +138,7 @@ test('Should return 503 on maxRssBytes', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -176,7 +176,7 @@ test('Custom message and retry after header', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -227,7 +227,7 @@ test('Custom error instance', t => { return reply.code(err.statusCode).send(err) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -269,7 +269,7 @@ test('memoryUsage name space', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, async (err, address) => { + fastify.listen({ port: 0 }, async (err, address) => { t.error(err) t.equal(typeof fastify.memoryUsage, 'function') fastify.server.unref() @@ -308,7 +308,7 @@ test('memoryUsage name space (without check)', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, async (err, address) => { + fastify.listen({ port: 0 }, async (err, address) => { t.error(err) t.equal(typeof fastify.memoryUsage, 'function') fastify.server.unref() @@ -351,7 +351,7 @@ test('Custom health check', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -386,7 +386,7 @@ test('Custom health check', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -419,7 +419,7 @@ test('Custom health check', t => { reply.send({ hello: 'world' }) }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() sget({ @@ -468,7 +468,7 @@ test('Custom health check', t => { healthCheckInterval: 1000 }) - fastify.listen(0, (err) => { + fastify.listen({ port: 0 }, (err) => { t.error(err) t.ok(called) fastify.close() @@ -488,7 +488,7 @@ test('Custom health check', t => { exposeStatusRoute: true }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() check = false @@ -527,7 +527,7 @@ test('Custom health check', t => { exposeStatusRoute: true }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() check = false @@ -571,7 +571,7 @@ test('Custom health check', t => { } }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref() @@ -610,7 +610,7 @@ test('Custom health check', t => { } }) - fastify.listen(0, (err, address) => { + fastify.listen({ port: 0 }, (err, address) => { t.error(err) fastify.server.unref()