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

API for Retrieving Package Tarball #69

Closed
ZitRos opened this issue Oct 23, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@ZitRos
Copy link

commented Oct 23, 2017

Hello! Thank you for an awesome service and all the work put towards creating it.

I am building an application which works with NPM package tarballs in a browser. Today I got stuck at the very interesting thing: NPM registry suddenly stopped sending Access-Control-Allow-Origin: * response headers on *.tgz endpoints, hence my app crashed. I searched around for this issue and realized that I should probably not ever expect this header to come again from the server.

From the other point of view, unpkg.com does pretty much the same thing, but in case of my application, I need to retrieve a list of files at least, which was possible by downloading and extracting tarball in a browser.

So I am curious, are you interested in adding, say, new endpoint to unpkg.com which just relays a *.tgz tarball? I've checked that unpkg.com already does this, but it also extracts files and serves them. I can assist and code this change if you don't mind. I can come up with something like https://unpkg.com/package?tarball for now.

Looking forward to hearing from you. Thank you.

@mjackson

This comment has been minimized.

Copy link
Member

commented Oct 24, 2017

unpkg will already give you a listing of files in a package. Just use the ?meta flag on any dir name. For example https://unpkg.com/react/?meta

@ZitRos

This comment has been minimized.

Copy link
Author

commented Oct 24, 2017

Wow, how could I missed this. Thank you!

I figured out why I missed this: I've tried https://unpkg.com/react-dom?meta instead of https://unpkg.com/react-dom/?meta (putting / at the end does the trick).

Hm, maybe, it's worth mentioning in a description on unpkg.com? Like:

From:

?meta
   Return metadata about any file in a package as JSON (e.g. /any/file?meta)

To:

?meta
   Return metadata about any file or directory in a package as JSON (e.g. /any/file?meta
   or /any/file/?meta). Directories metadata includes a list of files in a directory.
@ZitRos

This comment has been minimized.

Copy link
Author

commented Oct 24, 2017

Haha, putting a slash to list a directory does pretty much everything I wanted in my web application 😄

I've missed this in a description on unpkg.com:

Append a / at the end of a URL to view a listing of all the files in a package.

Thanks! So I think I will turn my web app into "just a different UI" to unpkg.com directory listings.

@ZitRos

This comment has been minimized.

Copy link
Author

commented Oct 24, 2017

Also I found that sometimes, when querying some packages for the first time (I believe) in unpkg history, like https://unpkg.com/never_ever_seen_before_package_name/?meta, unpkg does not display files:

2017-10-24_144926

After the first try, the package files are served properly:

2017-10-24_145049

And sometimes it happens to files themselves:

2017-10-24_151517

@mjackson

This comment has been minimized.

Copy link
Member

commented Oct 27, 2017

Glad you got it figured out :)

@mjackson mjackson closed this Oct 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.