Skip to content

Commit

Permalink
major: update to Fastify v4 (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed May 10, 2022
1 parent de2e09b commit 10371e1
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 350 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ jobs:
strategy:
matrix:
node-version:
- 10
- 12
- 14
- 16
- 18
os:
- macos-latest
- ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ function fastifyView (fastify, opts, next) {
this.send(e)
}
} else {
getPartials(type, { partials: options.partials || {}, requestedPath: requestedPath }, (err, partialsObject) => {
getPartials(type, { partials: options.partials || {}, requestedPath }, (err, partialsObject) => {
if (err) {
this.send(err)
return
Expand Down Expand Up @@ -505,7 +505,7 @@ function fastifyView (fastify, opts, next) {
this.send(err)
return
}
getPartials(page, { partials: options.partials || {}, requestedPath: requestedPath }, (err, partialsObject) => {
getPartials(page, { partials: options.partials || {}, requestedPath }, (err, partialsObject) => {
if (err) {
this.send(err)
return
Expand Down Expand Up @@ -707,6 +707,6 @@ function fastifyView (fastify, opts, next) {
}

module.exports = fp(fastifyView, {
fastify: '3.x',
fastify: '4.x',
name: 'point-of-view'
})
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"ejs": "^3.1.2",
"eta": "^1.11.0",
"express": "^4.17.1",
"fastify": "^3.0.0",
"fastify": "^4.0.0-rc.2",
"handlebars": "^4.7.6",
"html-minifier": "^4.0.0",
"html-minify-stream": "^2.0.0",
"liquidjs": "^9.15.1",
"mustache": "^4.0.1",
"nunjucks": "^3.2.1",
"pino": "^6.7.0",
"pino": "^7.0.0",
"pre-commit": "^1.2.2",
"proxyquire": "^2.1.3",
"pug": "^3.0.0",
Expand Down
42 changes: 21 additions & 21 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO

fastify.register(POV, {
engine: {
dot: dot
dot
},
root: 'templates',
options: {
Expand All @@ -47,7 +47,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO
reply.view('testdot', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand All @@ -70,7 +70,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO

fastify.register(POV, {
engine: {
dot: dot
dot
},
root: 'templates',
options: {
Expand All @@ -84,7 +84,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO
reply.view('testdot', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -112,7 +112,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
eta: eta
eta
},
options: {
useHtmlMinifier: minifier,
Expand All @@ -124,7 +124,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('templates/index.eta', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand All @@ -146,7 +146,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
eta: eta
eta
},
options: {
useHtmlMinifier: minifier,
Expand All @@ -159,7 +159,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('templates/index.eta', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports.handleBarsHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
handlebars: handlebars
handlebars
},
options: {
useHtmlMinifier: minifier,
Expand Down Expand Up @@ -230,7 +230,7 @@ module.exports.liquidHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.liquid', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -270,7 +270,7 @@ module.exports.liquidHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.liquid', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -302,7 +302,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
nunjucks: nunjucks
nunjucks
},
templates: 'templates',
options: {
Expand All @@ -315,7 +315,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./index.njk', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand All @@ -338,7 +338,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
nunjucks: nunjucks
nunjucks
},
templates: 'templates',
options: {
Expand All @@ -352,7 +352,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./index.njk', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -381,7 +381,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
pug: pug
pug
},
options: {
useHtmlMinifier: minifier,
Expand All @@ -393,7 +393,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.pug', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand All @@ -415,7 +415,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {

fastify.register(POV, {
engine: {
pug: pug
pug
},
options: {
useHtmlMinifier: minifier,
Expand All @@ -428,7 +428,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.pug', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -468,7 +468,7 @@ module.exports.twigHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.twig', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -506,7 +506,7 @@ module.exports.twigHtmlMinifierTests = function (t, withMinifierOptions) {
reply.view('./templates/index.twig', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down
24 changes: 12 additions & 12 deletions test/test-art-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('reply.view with art-template engine and custom templates folder', t => {
reply.view('./index.art', data)
})

fastify.listen(10086, err => {
fastify.listen({ port: 10086 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -59,7 +59,7 @@ test('reply.view for art-template without data-parameter and defaultContext', t
reply.view('./index.art')
})

fastify.listen(10086, err => {
fastify.listen({ port: 10086 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -97,7 +97,7 @@ test('reply.view for art-template without data-parameter but with defaultContext
reply.view('./index.art')
})

fastify.listen(10086, err => {
fastify.listen({ port: 10086 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -135,7 +135,7 @@ test('reply.view with art-template engine and defaultContext', t => {
reply.view('./index.art', {})
})

fastify.listen(10086, err => {
fastify.listen({ port: 10086 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -176,7 +176,7 @@ test('reply.view for art-template engine without data-parameter and defaultConte
reply.view('./templates/index.art')
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -218,7 +218,7 @@ test('reply.view for art-template engine without defaultContext but with reply.l
reply.view('./templates/index.art', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -261,7 +261,7 @@ test('reply.view for art-template engine without data-parameter but with reply.l
reply.view('./templates/index.art')
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -305,7 +305,7 @@ test('reply.view for art-template engine with data-parameter and reply.locals an
reply.view('./templates/index.art', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -343,7 +343,7 @@ test('reply.view with art-template engine and full path templates folder', t =>
reply.view('./index.art', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -381,7 +381,7 @@ test('reply.view with art-template engine and includeViewExtension is true', t =
reply.view('./templates/index', data)
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -422,7 +422,7 @@ test('fastify.view with art-template engine and full path templates folder', t =
})
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down Expand Up @@ -480,7 +480,7 @@ test('reply.view with art-template should return 500 if render fails', t => {
reply.view('./templates/index')
})

fastify.listen(0, err => {
fastify.listen({ port: 0 }, err => {
t.error(err)

sget({
Expand Down

0 comments on commit 10371e1

Please sign in to comment.