Some of the utility functions currently used in the examples are quite useful and generic enough that they could be provided by uWebSockets.js itself.
For example, a helper such as readJson could be exposed as part of the library instead of requiring users to copy the implementation from the examples.
This would have a couple of advantages:
- users wouldn't have to copy and maintain these utilities themselves;
- improvements and bug fixes could be propagated to all users through library updates;
- examples could use the same utilities that are recommended for real applications;
- it would make some common tasks easier without adding much complexity to the API.
For example, something along the lines of:
const { readJson } = uWS.utils;
app.post('/api', (res, req) => {
readJson(res, () => {
// ...
});
// ...
});
Have you ever considered providing some of these example utilities as part of the public API?
Some of the utility functions currently used in the examples are quite useful and generic enough that they could be provided by uWebSockets.js itself.
For example, a helper such as readJson could be exposed as part of the library instead of requiring users to copy the implementation from the examples.
This would have a couple of advantages:
For example, something along the lines of:
Have you ever considered providing some of these example utilities as part of the public API?