The open-source package registry for modern JavaScript and TypeScript
MIT License
This is the source code for https://jsr.io, the new JavaScript registry.
[!IMPORTANT] The rest of this README is only relevant to those interested in contributing to the jsr.io registry. If you are looking for information on how to use the registry, please see https://jsr.io/docs.
Goals
Implementation details
If you are just interested in making changes to the frontend, you can run the frontend in a development mode that connects to the production API.
/etc/hosts
127.0.0.1 jsr.test
127.0.0.1 api.jsr.test
127.0.0.1 npm.jsr.test
deno task prod:frontend
You can view the registry at http://jsr.test
. This frontend is connected to
the production API - use it with the same care that you would use the live
registry.
In this mode, you will run the frontend and the API locally. This is useful for making changes to the API.
Clone this repo
Install Deno (https://deno.land/#installation)
Install Rust (https://rustup.rs/)
Add the following to your /etc/hosts
127.0.0.1 jsr.test
127.0.0.1 api.jsr.test
127.0.0.1 npm.jsr.test
Set up api/.env
file:
.env
file from 1Password (it'sjsr local .env
), and set up DATABASE_URL
to point to your localapi/.env.example
to api/.env
GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
to the values from theDATABASE_URL
to point to your local Postgres database.Install sqlx
by running cargo install sqlx-cli
macOS
brew install postgresql
createdb registry
cd api
cargo sqlx migrate run
role "postgres" does not exist
, runcreateuser -s postgres
.Linux
docker
& docker-compose
installed and runningcd api
cargo sqlx migrate run
role "postgres" does not exist
, runcreateuser -s postgres
.deno task services:macos
or deno task services:linux
in one terminaldeno task dev:api
in another terminaldeno task dev:frontend
in another terminalYou can view the registry at http://jsr.test
. The API can be found at
http://api.jsr.test
.
deno.json
cd
into that directoryJSR_URL=http://jsr.test deno publish
It may be helpful to have a large variety of packages published to your local dev environment to simulate a live environment. The quickest way to fill the registry with data is to publish deno_std to the registry. This can be done via the following steps:
jsr
projectJSR_URL=http://jsr.test deno publish
to publish all of the @stdpsql registry
SELECT name,github_id from users;
UPDATE users SET is_staff = true WHERE github_id = xxxxxxx;
, replacingxxxxxxx
with your copied GitHub ID from the previous step.When the database schema has been changed, you can migrate the local database by running this command:
cd api; sqlx migrate run
To load bad words into the database:
cloud-sql-proxy -g [database connection string] -p 5433
bad_words.sql
file, with the contents as:INSERT INTO bad_words (word) VALUES
('word_1'),
-- more words
('word_2');
psql postgres://127.0.0.1:5433/registry --user [your username] -f bad_words.sql
,During local dev, traces are sent to Jaeger. You can view them at
http://localhost:16686. You can find traces in API HTTP requests by inspecting
the x-deno-ray
header.