Skip to content
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

NOISSUE - Add functionality to sdk-js #2

Merged
merged 24 commits into from
Mar 22, 2024
Merged

NOISSUE - Add functionality to sdk-js #2

merged 24 commits into from
Mar 22, 2024

Conversation

Musilah
Copy link
Contributor

@Musilah Musilah commented Sep 5, 2023

What does this do?

Add functioning code to JS SDK.

Which issue(s) does this PR fix/relate to?

No issue

List any changes that modify/break current functionality

  1. Create a mainflux- sdk package in npm.
  2. Add users, things, channels, groups and more.
  3. Add manual tests to the sdk.

Have you included tests for your changes?

Yes. Manually tested.

Did you document any new/modified functionality?
No

Notes

@drasko drasko changed the title Add functionality to sdk-js. NOISSUE - Add functionality to sdk-js Sep 6, 2023
Musilah added 10 commits September 13, 2023 15:05
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
Musilah added 5 commits September 14, 2023 11:00
@Musilah Musilah marked this pull request as ready for review October 2, 2023 09:22
Copy link
Contributor

@SammyOina SammyOina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also consider adding validation before making requests

const options = {
method: "post",
maxBodyLength: Infinity,
url: `${this.bootstraps_url}/things/${this.bootstrapsEndpoint}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



class Errors {
HandleError(error_dict, status_code) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is error_dict defined

401: "Missing or invalid access token provided.",
},
login: {
404: "A non-existent entity request.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
404: "A non-existent entity request.",

let subtopic = "";

if (chan_name_parts.length == 2) {
subtopic = chan_name_parts[1].replace(".", "/", -1);

This comment was marked as resolved.

Copy link
Contributor

@SammyOina SammyOina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also consider adding validation before making requests

Copy link
Contributor

@SammyOina SammyOina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional note on error handling, I think the js way is to throw error rather than return error, also add an informative error message simillar to go SDK

"Content-Type": this.content_type,
Authorization: `Bearer ${token}`,
},
data: JSON.stringify(config),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axios converts js objects to json so no need for JSON.stringify() look at other simillar cases

};
return axios.request(options)
.then((_response) => {
return "DELETED";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps return the status code

Musilah added 3 commits October 15, 2023 23:56
Musilah added 2 commits October 16, 2023 01:22
Signed-off-by: Musilah <[email protected]>
Signed-off-by: Musilah <[email protected]>
@Musilah
Copy link
Contributor Author

Musilah commented Nov 8, 2023

I've done all these changes in the pull request #4.

@drasko drasko merged commit 73630e8 into absmach:main Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants