Comments (5)
Then the question is how https://github.com/fastify/fastify/blob/6564ba9b7d8ec7c236cc16f4bf3cdb3cabff69f0/lib/schema-controller.js#L159 be even possible?
from fast-json-stringify-compiler.
Then the question is how https://github.com/fastify/fastify/blob/6564ba9b7d8ec7c236cc16f4bf3cdb3cabff69f0/lib/schema-controller.js#L159 be even possible?
I would say : https://github.com/fastify/fast-json-stringify-compiler/blob/main/standalone.js#L25
from fast-json-stringify-compiler.
But it is not imported as standalone and the two version expect different arguments.
cc @Eomm
from fast-json-stringify-compiler.
Let's follow the happy path:
- fastify starts and the user has set 1 response schema at least
- fastify creates the default schema controller https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/fastify.js#L214
- while creating the schema controller, the default serializer factory is instantiated https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/lib/schema-controller.js#L27C40-L27C58
- Here is the factory function:
fast-json-stringify-compiler/index.js
Line 6 in 6e8d53a
- Now the server is starting and fastify processes the route with the json schema
- Since we don't have a FJS instance, the route asks to the schema controller to build a serializer https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/lib/route.js#L420
- The serializer is built using the factory at step 3 (interface at step 4) https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/lib/schema-controller.js#L159
- Finally we have the
compile
function generated by FJS and it is used to build the serializer-function https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/lib/validation.js#L35
My conclusion is that SerializerCompiler should be:
It makes sense, but porting a real test case here will solve any doubt: https://github.com/fastify/fastify/blob/main/test/schema-serialization.test.js
from fast-json-stringify-compiler.
Thanks for the fast feedback.
Indeed, in the happy path the compile function of type SerializerCompiler
is called https://github.com/fastify/fastify/blob/main/lib/validation.js#L45 and https://github.com/fastify/fastify/blob/main/lib/validation.js#L45
In my opinion, it matches completely my initial suggestion.
About the real test case, as it is a js file and I am trying to solve a typing issue, I don't really understand what I could add to the PR, can you explain a bit more ?
Maybe less important httpStatus
might be null : https://github.com/fastify/fastify/blob/c90ac14c7179606bb0833447dda1b83007156fa5/lib/reply.js#L382
from fast-json-stringify-compiler.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-json-stringify-compiler.