profile
viewpoint
Maksim Sinik fox1t @hospitalrun Italy https://maksim.dev Cloud Software Architect. DevOps lover. Container enthusiast. Conference Speaker. @HospitalRun lead maintainer; @fastify core team

fox1t/fastify-multer 31

Fastify plugin for handling multipart/form-data

fastify/tsconfig 4

Shared TypeScript configuration for fastify projects

fox1t/Backbone-relational 0

Get and set relations (one-to-one, one-to-many, many-to-one) for Backbone models

fox1t/building-products-with-js 0

Materials and code for free course on building products with javascript

fox1t/cgm-remote-monitor 0

nightscout web monitor

fox1t/couchbackup 0

CouchDB backup and restore command-line utility.

issue commentfastify/help

Type "number" in schema allows null values by fastify, but not Ajv.

Thanks friends. So for clarity, can we say this: Fastify first serializes the data and then validates it? (I'm assuming this because if the data would have gone through ajv first, it would have thrown, which is not the case here.)

https://www.fastify.io/docs/latest/Validation-and-Serialization/ While reading it at least I got intuition that first fastify first validates and then serializes. Because, throughout the docs serialization comes second to validation.

vajahath

comment created time in 3 hours

issue openedfastify/help

Custom error messages with ajv-errors

What are you trying to achieve or the steps to reproduce?

I have a single POST endpoint

  fastify.post('/register', {
    schema: {
      summary: 'Register a new user',
      description: "Use this route to register a new user",
      tags: ['user'],
      body: {
        type: 'object',
        required: ['name'],
        properties: {
          name: {
            type: 'string'
          },
        },
        errorMessage: {
          required: {
            name: 'Your name is required',
          }
        }
      },
    }

I call the endpoint without providing a name

What was the result you received?

I got this response body should have required property 'name'

What did you expect?

the expected result to get my custom error message Your name is required

Context

based on the docs

add custom error messages for each property of a schema by supplying custom AJV options.

const fastify = Fastify({
  ajv: {
    customOptions: { jsonPointers: true },
    plugins: [
      require('ajv-errors')
    ]
  }
})

because , I use a ready generated template from Fastify-cli looks I have to pass these options within the command (Reference) but , there's no a clear way to pass these ajv options within Fastify-cli

  • node version: 10.15.1
  • fastify version: >=3.0.0
  • os: Mac
  • fastify-cli version:2.7.0

created time in 4 hours

issue commentfastify/help

Type "number" in schema allows null values by fastify, but not Ajv.

I think issue here with default AJV settings in fastify: it enabled coercion hence ajv coerce null on input to 0, you need to disable it

vajahath

comment created time in 8 hours

startedpreactjs/preact-cli

started time in 8 hours

issue commentHospitalRun/components

Upgrade to React 17.0.x

@jackcmeyer @blestab any clue?

jackcmeyer

comment created time in 11 hours

issue commentfastify/help

Type "number" in schema allows null values by fastify, but not Ajv.

The Fastify serializer is fast-json-stringify: it is not a validator in any form or fashion: it assumes you are generating is correct. It does all it can to make the data you are passing conform to the schema, e.g. coercing null to 0. If it's not possible to shape the data, it will throw: however it is very lenient and not spec-compliant.

This is useful to remove unwanted fields and make sure the output conforms to a given output. It's also faster than JSON.stringify.

vajahath

comment created time in 11 hours

issue closedHospitalRun/hospitalrun-frontend

Tests pass even if they fail

🐛 Bug Report

  • [ ] Tests pass even if they fail
  • [ ] The tests fail. Understand why

Reference: https://github.com/HospitalRun/hospitalrun-frontend/runs/974788560?check_suite_focus=true#step:8:138

Cc @fox1t

closed time in 12 hours

tehKapa

starteddonavon/use-persisted-state

started time in 12 hours

startedwebsockets/ws

started time in 13 hours

issue commentfastify/fastify

Rename `master` branch to `main`

Once we do this, we'll ping the authors of every open pr (again, like we did when we switched from next to master) to let them know that they need to rebase on a new branch (with zero breaking changes in this case).

Renaming a branch will: Re-target any open pull requests

Not even sure it is necessary

delvedor

comment created time in 14 hours

issue commentfastify/fastify

Rename `master` branch to `main`

Those references need to be changed: https://github.com/fastify/fastify/blob/master/.github/workflows/website.yml#L6 https://github.com/fastify/fastify/blob/master/.github/workflows/package-manager-ci.yml#L6

delvedor

comment created time in 14 hours

issue commentfastify/fastify

Rename `master` branch to `main`

The tooling provided by github is going to do all the rebasing automatically, it would also allow the old references to continue working. We can also wait for Node.js core to switch for example and validate the approach.

delvedor

comment created time in 15 hours

issue commentfastify/fastify

Rename `master` branch to `main`

@jsumners I don't agree, if you are maintaining a fork for a pr changing the base branch is the same as changing it when targeting the wrong branch or when we switch from next to master. Once we do this, we'll ping the authors of every open pr (again, like we did when we switched from next to master) to let them know that they need to rebase on a new branch (with zero breaking changes in this case).

delvedor

comment created time in 16 hours

issue commentfastify/fastify

Rename `master` branch to `main`

This is just a solution in search of a problem. And implementing it is going to cause problems for everyone who has the code forked.

delvedor

comment created time in 17 hours

issue closedfastify/help

Hi can you help fastify.route execute the function twice

Hi can you help fastify.route execute the function twice

I can't understand why the function is executed 2 times. I posted the entire function in which this error occurs. I would be very grateful for your help!

  • node version: v14.15.1
  • fastify version: >=3.9.1
  • os: Windows
  • any other relevant information:

**code debug link to video -> https://drive.google.com/file/d/1dYCk3QgAx36nAF2UGKByDgH7dip-xDnP/view?usp=sharing

Photo link controller https://drive.google.com/file/d/1EJ4imtJYGrPfDWoDBMpVJtwMj1yxjrhf/view?usp=sharing https://drive.google.com/file/d/1raJCmlqESeiGzAYcTc0tuqMMuxcWaRPJ/view?usp=sharing https://drive.google.com/file/d/1rn5e0AdfJIlliCOKzwOth94Hd0HEG_G9/view?usp=sharing

closed time in 18 hours

frontenddima

issue commentfastify/help

Hi can you help fastify.route execute the function twice

Please share the code and context in the issue.

Hi thanks for the answer solved the problem :_) in preHandler it was necessary to pass done

frontenddima

comment created time in 18 hours

startedothneildrew/Best-README-Template

started time in 19 hours

pull request commentfastify/fastify-websocket

Fix / route with prefix in fastify@v3.10.1

@Skn0tt double onRoute was called when prefixTrailingSlash was set to both. However, this behavior was neither expected (or at least I think so, coz single route definition triggering two onRoute) nor documented. Hence, we removed this double trigger.

mcollina

comment created time in 19 hours

issue commentfastify/fastify

Rename `master` branch to `main`

Go for it!

delvedor

comment created time in 20 hours

issue openedfastify/fastify

Rename `master` branch to `main`

As titled. It should not be a problem here, but the documentation build should be updated.

Related: https://github.com/github/renaming

/cc @lmammino

created time in 20 hours

created tagfastify/fastify-websocket

tagv2.1.0

basic websocket support for fastify

created time in 20 hours

release fastify/fastify-websocket

v2.1.0

released time in 20 hours

push eventfastify/fastify-websocket

Matteo Collina

commit sha c276f6dbc8da0da3e4a87bd7b81ff8b237c5156f

Bumped v2.1.0

view details

push time in 20 hours

push eventfastify/fastify-websocket

Matteo Collina

commit sha 11d4b12b72780ec8d086e9e0006d9a0ccf358893

Fix / route with prefix in fastify@v3.10.1 (#98)

view details

push time in 20 hours

PR merged fastify/fastify-websocket

Reviewers
Fix / route with prefix in fastify@v3.10.1

<!-- Thank you for your pull request. Please provide a description above and review the requirements below.

Bug fixes and new features should include tests and possibly benchmarks.

Contributors guide: https://github.com/fastify/fastify/blob/master/CONTRIBUTING.md

By making a contribution to this project, I certify that:

  • (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or

  • (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or

  • (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

  • (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. -->

Fix #97

Checklist

+45 -8

1 comment

3 changed files

mcollina

pr closed time in 20 hours

issue closedfastify/fastify-websocket

Fastify 3.10 breaks prefixed plugins

🐛 Bug Report

Fastify 3.10, together with the use of prefixes, breaks fastify-websocket.

fastify.register(
  (fastify, opts, done) => {
    fastify.get("/", { websocket: true }, (connection, req) => {
      connection.socket.send("This works");
    });

    done();
  },
  { prefix: "/activity" }
);

To Reproduce

  • Clone https://github.com/Skn0tt/fastify-websocket-3.10-repro
  • Run index.js
  • Connect to ws://localhost:3000/activity

Your Environment

  • node version: 15.3
  • fastify version: >=3.10
  • os: Mac

Some ideas as to what may be causing this

Prior to 3.10, this line was called twice per route:

https://github.com/fastify/fastify-websocket/blob/99c94a003da2353c1f482301027166e64e743582/index.js#L36

That's why this lines makes sure to ignore one of them:

https://github.com/fastify/fastify-websocket/blob/99c94a003da2353c1f482301027166e64e743582/index.js#L42

Now with 3.10, the onRoute is called only once, and all of the routes are effectively ignored.

originally encountered in https://github.com/quirrel-dev/quirrel/issues/49

closed time in 20 hours

Skn0tt

Pull request review commentfastify/fastify-websocket

Fix / route with prefix in fastify@v3.10.1

 function close (fastify, done) { }  module.exports = fp(fastifyWebsocket, {-  fastify: '3.x',+  fastify: '>= 3.10.1',

Nope, in a real world application you should use lock files, so this wouldn't impact you until you want to upgrade.

mcollina

comment created time in 20 hours

pull request commentfastify/fastify-websocket

Fix / route with prefix in fastify@v3.10.1

This was caused by: https://github.com/fastify/fastify/pull/2782/files. We had a few bugs in other plugins because it was called twice.

(Note that the change in Fastify was not causing any tests failures here).

cc @salmanm

mcollina

comment created time in 21 hours

issue commentfastify/help

Hi can you help fastify.route execute the function twice

Please share the code and context in the issue.

frontenddima

comment created time in 21 hours

issue openedfastify/help

Hi can you help fastify.route execute the function twice

Hi can you help fastify.route execute the function twice

I can't understand why the function is executed 2 times. I posted the entire function in which this error occurs. I would be very grateful for your help!

  • node version: v14.15.1
  • fastify version: >=3.9.1
  • os: Windows
  • any other relevant information:

**code debug link to video -> https://drive.google.com/file/d/1dYCk3QgAx36nAF2UGKByDgH7dip-xDnP/view?usp=sharing

Photo link controller https://drive.google.com/file/d/1EJ4imtJYGrPfDWoDBMpVJtwMj1yxjrhf/view?usp=sharing https://drive.google.com/file/d/1raJCmlqESeiGzAYcTc0tuqMMuxcWaRPJ/view?usp=sharing https://drive.google.com/file/d/1rn5e0AdfJIlliCOKzwOth94Hd0HEG_G9/view?usp=sharing

created time in 21 hours

more