nestdotland / nest.land

🦕 The Nest Website
https://nest.land
MIT License
371 stars 19 forks source link

Use /x or /mod instead of /package #287

Open martonlederer opened 3 years ago

martonlederer commented 3 years ago

Right now we are using the /package/:pkgname route for modules. To align more with the Deno philosophy, we could switch to /x/:modname or /mod/:modname

SteelAlloy commented 3 years ago

I completely agree After that it would also be a good idea to replace all occurrences of the word package by module in the internal code

martonlederer commented 3 years ago

We could also add a simple redirect for /package/:pkgname. Luckily we don't have it in the actual registry URLs

t8 commented 3 years ago

I like this idea. I would prefer not to have /x (just to avoid confusion between x.nest.land and nest.land/x) unless we can get something working like how deno.land/x does it...

Though, I think @maximousblk has looked into this before, and it may be more effort than I think.

Regardless, @martonlederer's idea of a redirect from the current references would be absolutely critical.

martonlederer commented 3 years ago

It can be done with cloudflare workers. We should talk about this too in our meeting

maximousblk commented 3 years ago

it can also be done with vercel functions. I couldn't implement it in a simple way earlier because the URLs for the raw and web versions were way different. It won't take much effort if the routes work the same way on the web and in deno

what we have now:

what we need:

then we can create a serverless function to forward the requests to the right place and deploy that to https://nest.land/...

you can boil all of that down to "the site is inconsistent"

VienDinhCom commented 3 years ago

Use the term "module" instead of "library" or "package".

For clarity and consistency avoid the terms "library" and "package". Instead use "module" to refer to a single JS or TS file and also to refer to a directory of TS/JS code.

https://deno.land/manual@v1.4.6/contributing/style_guide#use-the-term-quotmodulequot-instead-of-quotlibraryquot-or-quotpackagequot

I think we should use https://deno.land/std for Standard Library and https://deno.land/x for Third Party Modules just like the https://deno.land/.

t8 commented 3 years ago

Hi @Maxvien! Thanks for the input.

This was our original plan for the system, however, we encountered some technical issues with that. Because our API is completely separate from the site, we had to put x on its own subdomain.

I wouldn't be against investigating a solution to allow for the /x and /std routes on Nest.land, but I personally do not know of a way around this issue. Note: We'd like to keep our Vercel sponsorship, as our site development/deployment workflow is massively simplified this way.

jasonappah commented 3 years ago

I wouldn't be against investigating a solution to allow for the /x and /std routes on Nest.land, but I personally do not know of a way around this issue. Note: We'd like to keep our Vercel sponsorship, as our site development/deployment workflow is massively simplified this way.

If I'm understanding this correctly, we should be able to get away with setting up routes in the vercel.json file. See here for more info.

Basically at the root of the repo we would create the vercel.json file, and add something like this:

{
  "routes": [
    { "source": "/x/(.*)", "destination": "https://x.nest.land/$1" },
    { "source": "/std/(?<ver>[^/]+)/(.*)", "destination": "https://x.nest.land/std@$ver\$STD_VERSION/$1" }
  ]
}
maximousblk commented 3 years ago

yes we can set the routes in the vercel.json file but that won't let us dynamically serve the website and raw module based on the request.