Skip to content

Commit

Permalink
TELESTION-444 Write frontend getting started
Browse files Browse the repository at this point in the history
Use Deno land module for `telestion` library imports for Deno based backend services
  • Loading branch information
pklaschka committed Dec 15, 2023
1 parent d95a32d commit 9896316
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 196 deletions.
2 changes: 1 addition & 1 deletion docs/docs/Backend Development/typescript/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Create a file called `config.json` next to your `service.ts` file with the follo
Now, let's adjust the `service.ts` file to use the configuration:

```typescript title="service.ts"
import { startService } from "./lib.ts";
import { startService } from "https://deno.land/x/telestion/mod.ts";
import { z } from "https://deno.land/x/[email protected]/mod.ts";// (1)!

const { config: rawConfig/* (2)! */} = await startService({
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/Backend Development/typescript/e2e-log-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This tutorial will explain step-by-step how to write a log service that will lis
1. First, we need to import the `startService` function from our library (`lib.ts`) and the `encode` function from the standard Deno library.

```ts
import { startService } from "./lib.ts";
import { startService } from "https://deno.land/x/telestion/mod.ts";
import { encode } from "https://deno.land/[email protected]/encoding/hex.ts";
```

Expand Down Expand Up @@ -66,7 +66,7 @@ And that's it! Our service is now complete and ready to be used.
## Final Code

```ts
import { startService } from "./lib.ts";
import { startService } from "https://deno.land/x/telestion/mod.ts";
import { encode } from "https://deno.land/[email protected]/encoding/hex.ts";

const encoder = new TextEncoder();
Expand Down
7 changes: 1 addition & 6 deletions docs/docs/Backend Development/typescript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ touch service.ts

### Writing the Service

!!! warning "Library functions"
The library for building TypeScript services is currently not hosted on a public registry. While this will change in the future, for now, simply place the [`lib.ts`](lib.ts) file in the same directory as your `service.ts` file.

[:material-download: Download library file](lib.ts)

Open `service.ts` in your favorite editor and add the following code:

```typescript title="service.ts"
import { startService } from './lib.ts';// (1)!
import { startService } from 'https://deno.land/x/telestion/mod.ts';// (1)!

await startService/*(2)!*/({
nats: false,// (3)!
Expand Down
182 changes: 0 additions & 182 deletions docs/docs/Backend Development/typescript/lib.ts

This file was deleted.

10 changes: 5 additions & 5 deletions docs/docs/Backend Development/typescript/message-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All you need to do compared to the previous examples is to omit the `{ nats: fal
```typescript title="service.ts"
import {
startService
} from "./lib.ts";
} from "https://deno.land/x/telestion/mod.ts";

const {nc/* (1)! */} = await startService(/* (2)! */);
```
Expand Down Expand Up @@ -58,7 +58,7 @@ To send a JSON message, you need to create a JSON object and pass it to the `pub
import {
JSONCodec,
startService
} from "./lib.ts";
} from "https://deno.land/x/telestion/mod.ts";
// or: import { JSONCodec } from "https://deno.land/x/nats/src/mod.ts";

const {nc} = await startService();
Expand All @@ -82,7 +82,7 @@ To send a binary message, you need to create a `Uint8Array` containing the bytes
```typescript title="service.ts"
import {
startService
} from "./lib.ts";
} from "https://deno.land/x/telestion/mod.ts";

const {nc} = await startService();

Expand All @@ -99,7 +99,7 @@ There are multiple ways to subscribe to messages on a subject. The most common w
```typescript title="service.ts"
import {
startService
} from "./lib.ts";
} from "https://deno.land/x/telestion/mod.ts";

const {nc} = await startService();

Expand All @@ -121,7 +121,7 @@ Unfortunately, this won't decode our JSON messages automatically. We need to do
import {
JSONCodec,
startService
} from "./lib.ts";
} from "https://deno.land/x/telestion/mod.ts";

const {nc} = await startService();

Expand Down

0 comments on commit 9896316

Please sign in to comment.