Skip to content

Commit

Permalink
major: update to Fastify v4 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored May 10, 2022
1 parent 1829a0d commit fdd0587
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function now () {
}

module.exports = fp(underPressure, {
fastify: '3.x',
fastify: '4.x',
name: 'under-pressure'
})

Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -40,8 +40,5 @@
"tap": "^16.2.0",
"tsd": "^0.20.0",
"typescript": "^4.0.3"
},
"engines": {
"node": ">=10"
}
}
10 changes: 5 additions & 5 deletions test/pressurehandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
10 changes: 5 additions & 5 deletions test/statusRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
32 changes: 16 additions & 16 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit fdd0587

Please sign in to comment.