dadi/web

Dependency in maintenance

jimlambie opened this issue · 5 comments

The circular-json dependency reports it is in maintenance and a new module should be used in its place:

> circular-json@0.5.7 postinstall /dadi/sandbox/web/node_modules/circular-json
> echo ''; echo "\x1B[1mCircularJSON\x1B[0m is in \x1B[4mmaintenance only\x1B[0m, \x1B[1mflatted\x1B[0m is its successor."; echo ''

\x1B[1mCircularJSON\x1B[0m is in \x1B[4mmaintenance only\x1B[0m, \x1B[1mflatted\x1B[0m is its successor.

The new dependancy package is called Flatted. While this contains the same function definitions, the functionality has changed and the response object is different. It now returns a stringified object wrapped in [] (see https://github.com/WebReflection/flatted/blob/master/index.js#L66).

Because the response object is a string, it would require some hacky code to manipulate it into a useable response.

Is it worth moving the original package functionality into web as a util?

@philip-hunt remind me where we use the current circular-json dependency, and I may be able to confirm. I believe circular-json returns the same sort of response, doesn't it? The idea is to not keep adding nested objects, and rather stop the tree building by adding a string to say "I'm not repeating myself"

@jimlambie yes I believe that is correct, it's used just before we output a json response here: https://github.com/dadi/web/blob/master/dadi/lib/view/send.js#L19

Here's a comparison of the output formats for both libraries. Both are strings so it wouldn't make sense to try and convert the Flatted output to the original CircularJSON.

CircularJSON:

{
"result": "success",
"message": "Cache cleared successfully"
}

Flatted:

[{
"result": "1",
"message": "2"
},"success","Cache cleared successfully"]

Ah @philip-hunt I see what you mean... perhaps we need something simpler for this then - we've used https://github.com/moll/json-stringify-safe before with good results.

Should produce something like: {"a":"[Circular ~]"} which is closer to the circular-json response?

Closed by 84bbff3, thanks @philip-hunt