fastify / fast-json-stringify-compiler Goto Github PK
View Code? Open in Web Editor NEWBuild and manage the fast-json-stringify instances for the fastify framework
License: MIT License
Build and manage the fast-json-stringify instances for the fastify framework
License: MIT License
4.20
4.3.0
20.x
Linux
Every compiled schema contains a stringified version of the schema. Issue is when the schema is huged.
Today it almost kills the advantage of compilation.
It comes from the bump to v5.7.0 of fast-json-stringify
.
And to be specific if comes from : fastify/fast-json-stringify#617.
It seems that this getState() of the serializer is never used.
async function main() {
const app = fastify({
exposeHeadRoutes: false,
jsonShorthand: false,
schemaController: {
compilersFactory: {
buildSerializer: writeSerializerFactory,
},
},
logger: {
level: 'debug'
}
});
addAllSchemas(app);
await app.register(async api => {
api.register(... all handlers ...)
});
await app.ready().then(() => {
app.log.info('Ready, all serializer compiled');
app.close();
});
}
export const writeSerializerFactory = StandaloneSerializer({
readMode: false,
storeFunction(routeOpts, schemaSerializationCode) {
if (routeOpts.method === 'HEAD') {
return;
}
writeFileSync(generateSerializerFilePath(routeOps), schemaSerializationCode);
},
});
Why have this serializerState
? Is does not seem to be used at all ?
๐ I'm Matteo, and would like to work on this.
Coming from Fastify issue #5116 (fastify/fastify#5116)
From what I've understood, I need to:
If there's anything I'm missing, please do let me know
4.0.1
3.0.0
16.14.2
Linux
Unrelated
In fastify/fastify@cf46dea a new fast-json-stringify version is used but only as a dev dependency. I have an older project upgraded to Fastify 4.0.1, but the fast-json-stringify version in my package-lock remained at 4.0.0 instead of 4.1.0, so bumping the version here seems appropriate.
Upgrading a project with a lock made prior to the 4.1.0 release.
No response
Hello,
From my research, I have the feeling that the declared SerializerCompiler
might be wrong.
In fastify, compiler is eventually called this way :
serializerCompiler({
schema,
method,
url,
httpStatus,
contentType
})
In fast-json-stringify-compiler; with jfsOpts being already bounded,
function responseSchemaCompiler (fjsOpts, { schema /* method, url, httpStatus */ }) { ... }
My conclusion is that SerializerCompiler
should be:
export type SerializerCompiler = (routeDef : RouteDefinition) => Serializer;
What do you think ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.