From 49b5864057b85a29a3e8552a35be09619b8d6f18 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Thu, 4 Jul 2024 17:51:06 +0100 Subject: [PATCH] adding docs on private registries --- runtime/_data.ts | 4 +- .../manual/basics/modules/grpc_connections.md | 20 +++++++ .../basics/modules/private_registries.md | 56 +++++++++++++++++++ .../{private.md => private_repositories.md} | 0 .../getting_started/setup_your_environment.md | 2 +- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 runtime/manual/basics/modules/grpc_connections.md create mode 100644 runtime/manual/basics/modules/private_registries.md rename runtime/manual/basics/modules/{private.md => private_repositories.md} (100%) diff --git a/runtime/_data.ts b/runtime/_data.ts index b827bc7a5..900a2f69b 100644 --- a/runtime/_data.ts +++ b/runtime/_data.ts @@ -37,7 +37,9 @@ export const sidebar = [ items: [ "/runtime/manual/basics/modules/", "/runtime/manual/basics/modules/reloading_modules/", - "/runtime/manual/basics/modules/private/", + "/runtime/manual/basics/modules/private_repositories/", + "/runtime/manual/basics/modules/private_registries/", + "/runtime/manual/basics/modules/grpc_connections/", "/runtime/manual/basics/modules/proxies/", "/runtime/manual/basics/modules/integrity_checking/", "/runtime/manual/advanced/publishing/", diff --git a/runtime/manual/basics/modules/grpc_connections.md b/runtime/manual/basics/modules/grpc_connections.md new file mode 100644 index 000000000..a122766a1 --- /dev/null +++ b/runtime/manual/basics/modules/grpc_connections.md @@ -0,0 +1,20 @@ +--- +title: "gRPC Connections" +--- + +gRPC is a high-performance, open-source, universal RPC framework that enables efficient communication between services. With gRPC support, you can build real-time, interactive applications that leverage the low-latency communication capabilities of gRPC. + +Deno supports gRPC connections using the `@grpc/grpc-js` client library from npm. This enables you to connect to gRPC services, such as Google Cloud Platform, directly from Deno. For example, you can classify an image using the Google Cloud Vision API: + +```typescript title="classifyImage.ts" + +import { ImageAnnotatorClient } from "npm:@google-cloud/vision"; + +const client = new ImageAnnotatorClient(); +const [result] = await client.labelDetection("./cat_dog.webp"); +const labels = result.labelAnnotations; +console.log("Labels:"); +for (const label of labels) { + console.log(" - ", label.description); +} +``` diff --git a/runtime/manual/basics/modules/private_registries.md b/runtime/manual/basics/modules/private_registries.md new file mode 100644 index 000000000..78afe09ae --- /dev/null +++ b/runtime/manual/basics/modules/private_registries.md @@ -0,0 +1,56 @@ +--- +title: "Private Registries" +--- + +Deno supports private registries, which allow you to host and share your own +modules. This is useful for organizations that want to keep their code private +or for individuals who want to share their code with a select group of people. + +## What are private registries? + +Large organizations often host their own private npm registries to manage internal packages securely. These private registries serve as repositories where organizations can publish and store their proprietary or custom packages. Unlike public npm registries, private registries are accessible only to authorized users within the organization. + +## How to use private registries with Deno + +First, configure your `.npmrc` file to point to your private registry. You can do this by adding the following line to your `.npmrc` file: + +```sh +@mycompany:registry=http://mycompany.com:8111/ +//mycompany.com:8111/:_auth=secretToken +``` + +Replace `http://mycompany.com:8111/` with the actual URL of your private registry and `secretToken` with your authentication token. + +Then update Your `deno.json` or `package.json` to specify the import path for your private package. For example: + +```json title="deno.json" +{ + "imports": { + "@mycompany/package": "npm:@mycompany/package@1.0.0" + } +} +``` + +or if you're using a `package.json`: + +```json title="package.json" +{ + "dependencies": { + "@mycompany/package": "1.0.0" + } +} +``` + +Now you can import your private package in your Deno code: + +```typescript title="main.ts" +import { hello } from "@mycompany/package"; + +console.log(hello()); +``` + +and run it using the `deno run` command: + +```sh +deno run main.ts +``` diff --git a/runtime/manual/basics/modules/private.md b/runtime/manual/basics/modules/private_repositories.md similarity index 100% rename from runtime/manual/basics/modules/private.md rename to runtime/manual/basics/modules/private_repositories.md diff --git a/runtime/manual/getting_started/setup_your_environment.md b/runtime/manual/getting_started/setup_your_environment.md index 77754f2f1..dd9897a88 100644 --- a/runtime/manual/getting_started/setup_your_environment.md +++ b/runtime/manual/getting_started/setup_your_environment.md @@ -396,7 +396,7 @@ There are several environment variables which can impact the behavior of Deno: - `DENO_AUTH_TOKENS` - a list of authorization tokens which can be used to allow Deno to access remote private code. See the - [Private modules and repositories](../basics/modules/private.md) section for + [Private modules and repositories](../basics/modules/private_repositories.md) section for more details. - `DENO_TLS_CA_STORE` - a list of certificate stores which will be used when establishing TLS connections. The available stores are `mozilla` and `system`.