-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose jwt package #62
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff @samtuga1. Tho we'll need to relook at a few stuffs.
Co-authored-by: Chima Precious <[email protected]>
Looks like the CI is failing for some Dart Analyze issues. @samtuga1 |
Do you know what is happening? maybe its coming from the export i did |
@codekeyz check this out invertase/melos#303 (comment) |
Okay. Taking a look. Give me a moment |
This is the issue. @samtuga1 Aren't you able to view the CI-logs on here? |
You left an unused import in the JWT Example project @samtuga1 |
should be fixed now |
It totally skipped me...did not check the top |
There's another unused import in a test file. @samtuga1 See Here: https://github.com/codekeyz/pharaoh/actions/runs/7054414617/job/19203239631?pr=62 |
I dont know how those imports are appearing in the first place but should be fixed now 👍🏽 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing again. I think something broke somewhere. Please try resolve, ping me if you need assistance. @samtuga1
Seems like its coming from the test
Something is happening there |
@samtuga1 It's prolly something to do with your changes. Because Session has a some related DateTime info i think. Please verify in the test that is failing to be sure what is happening. |
Oh right. Something is wrong with the test('should create a new session', () async {
final app = Pharaoh()
.use(session(secret: 'foo bar baz'))
.get('/', (req, res) => res.json(req.session)); // <----- this is failing This is the test that is failing. @samtuga1 |
why are you not doing session.toJson() I can see you have a toJson method. Right now the type is not Datetime but its an Instance of type Session |
I think your change is altering how
See here: https://api.flutter.dev/flutter/dart-convert/jsonEncode.html |
I think you should leave it as it. Any object being passed to If it fails, that's not our responsibility. What we can do is add some comment to the |
So it means its either we make it session.toJson ourselves or check the type in the customEncoder and make it .toJson |
Let's get rid of the custom encoder. |
yeah so something like /// [params] must be encodable or? and give some examples (a value that is not a number, boolean, string, null, list or a map with string keys) |
hmm...lets explore some other solutions to see |
@codekeyz see here...this is dart's implementation of String encode(Object? value, {Object? toEncodable(dynamic object)?}) {
toEncodable ??= _toEncodable;
if (toEncodable == null) return encoder.convert(value);
// it tries to encode the non-encodable Objects below converting when the toEncodable != null
// that is the problem
return JsonEncoder(toEncodable).convert(value);
}
JsonEncoder get encoder {
if (_toEncodable == null) return const JsonEncoder();
return JsonEncoder(_toEncodable);
} maybe we can implement our own logic to work for us looking at this edit: the .convert method uses a private class so not sure its possible |
Nope. Let's stay close to the language as much as possible. Let's just add the comments. /// [object] should be json-encodable
Response json(Object? object); If this comes up again as an issue, we'll look more into this. @samtuga1 |
sure no problem, i'll add that and fix that in the test asap |
fix: expose jwt package (codekeyz#62)
Resolves #60
Description
Turns out jsonEncode used in res.json cannot encode DateTime(is not serializable).
So I created a custom encoder to encode DateTime but whenever we find out about something else
then we add it for now
Type of Change