Closed edgesite closed 5 years ago
Good Idea :). I suggest this implementation:
const SALT = 'SALT';
class Entity {
@PropertySerialize(v => hashids.encode(SALT, v))
@PropertyDeserialize(e => hashids.decode(SALT, e))
@PrimaryColumn()
id: number;
}
What do you think ?
Great. Maybe better also add it to JsonPropertyOptions? I just made an example https://github.com/edgesite/ts-express-decorators/commit/5f6f439e38b7fc909fbab2258f8e9499153ef7ca
Also, I noticed the https://github.com/TypedProject/ts-express-decorators/pull/539 but it's seems stalled. Split ser/des to a standalone package is a great idea, the existing converter system is a bit tricky. It would be nice to redesign the API of the converter system to keep it clean and elegant.
@edgesite I don't understand in your code why you change the IConverterOptions with decode and encode, because decode/encode are applied on a specific prop.
Yes #539 is a test. Problem: It's a breaking change for developers, because it require to add this dependency in package.json for each projects using Ts.ED (like @tsed/di and @tsed/common). But in future the converters and jsonschema will be splited. Redesign jsonschema API is planed also. For the converter, isn't planed. The tricky code is over JsonSchema / PropertyMetada / PropertyRegistry. This part is really confusing and redundante.
Right know, I'll work on your feature ;). Refactoring jsonschema/converter will be done in another PR in future.
See you Romain
@Romakita oh I just miss push -f
when I amend the commit.
Check https://github.com/edgesite/ts-express-decorators/commit/5837227a9a4e27b3224cb55de025308ed8ae6663
Also, can we document *Registry to show users how to create custom filters? It's really a pain feature and needs looking into the code right now.
Information
Description
Add value transformer to des/serializer can help apply Hashids like mechanism much easier.
Example