Skip to content

feat: node-appwrite use ts #799

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

Merged
merged 31 commits into from
Apr 17, 2024
Merged

feat: node-appwrite use ts #799

merged 31 commits into from
Apr 17, 2024

Conversation

loks0n
Copy link
Member

@loks0n loks0n commented Mar 12, 2024

  • Migrates node-appwrite SDK to TypeScript.
  • Removes all dependencies on node modules from main entrypoint.
  • Adds optional entrypoint conditional import for InputFile module that depends on fs.
  • Enables support for edge runtimes such as Cloudflare and Next.js

I've published a test package at luke-node-appwrite-edge@0.0.32

Valuable context/reading:

Closes #652 appwrite/sdk-for-node#47

}
return 'string[]';
case self::TYPE_FILE:
return "File";
Copy link
Member

Choose a reason for hiding this comment

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

This should still be InputFile right? Otherwise the storage service param will expect a File?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've switched this to File on purpose. The InputFile class now returns an instance of the File class.

File is a web Javascript standard API[1] and is available on most edge runtimes including vercel[2].
It's available in Node.js from version 18, and we use node-fetch-native to fallback on a polyfill where it doesn't exist.

[1] https://developer.mozilla.org/en-US/docs/Web/API/File
[2] https://nextjs.org/docs/pages/api-reference/edge
[3] https://nodejs.org/docs/latest/api/buffer.html#class-file

Copy link
Member

Choose a reason for hiding this comment

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

Does this change the service method parameter types? We can use File internally, but should still expect an InputFile in the user-facing methods like storage.createFile

Copy link
Member Author

@loks0n loks0n Mar 20, 2024

Choose a reason for hiding this comment

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

Yes, because the user's InputFile helpers import will break on edge runtimes (due to its dependency on Node's fs module), so if we want storage.createFile to work on edge runtimes, we'll have to use the builtin File object.

If we use InputFile in the service method parameters then it is more obvious to the user that the helpers exist, but it will only work in Node-like environments

@loks0n loks0n requested a review from abnegate March 20, 2024 13:53
@stnguyen90
Copy link
Contributor

@loks0n, feel free to re-request a review once you're ready for me to review again.

@loks0n loks0n requested a review from stnguyen90 March 27, 2024 11:07
Copy link
Contributor

@stnguyen90 stnguyen90 left a comment

Choose a reason for hiding this comment

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

Let's get this released as an RC release and see how it performs.

@docimin
Copy link

docimin commented Apr 16, 2024

Let's get this released as an RC release and see how it performs.

Been using it for over a week now and it's pretty solid.

@christyjacob4 christyjacob4 merged commit d875e74 into master Apr 17, 2024
@christyjacob4 christyjacob4 deleted the feat-node-sdk-typescript branch April 17, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Allow user-defined fetch function for web sdk
6 participants