Skip to content

Commit

Permalink
refactor(docs, gate): push for meta dev instead of meta typegate
Browse files Browse the repository at this point in the history
…on docs (#822)

<!--
Pull requests are squashed and merged using:
- their title as the commit message
- their description as the commit body

Having a good title and description is important for the users to get
readable changelog.
-->

<!-- 1. Explain WHAT the change is about -->

## Ensure documentation is pushing for meta dev instead of meta typegate
- [x] add a warning that envs are not set.

<!-- 2. Explain WHY the change cannot be made simpler -->


[MET-635](https://linear.app/metatypedev/issue/MET-635/cli-ensure-documentation-is-pushing-for-meta-dev-instead-of-meta)

<!-- 3. Explain HOW users should update their code -->

#### Migration notes

_No Migration Needed_

- [ ] The change comes with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change
  • Loading branch information
destifo authored Aug 29, 2024
1 parent 51f20a0 commit 7c64c45
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 274 deletions.
458 changes: 215 additions & 243 deletions .ghjk/lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/tasks-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const tasks: Record<string, DenoTaskDefArgs> = {
"dev-gate3": {
desc: "Launch the typegate from a locally found meta bin.",
inherit: "dev-gate1",
fn: ($) => $`meta typegate`,
fn: ($) => $`meta dev`,
},

"dev-gate4": {
Expand Down
2 changes: 1 addition & 1 deletion examples/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 40 additions & 12 deletions typegate/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,49 @@ export type GlobalConfig = z.infer<typeof globalConfigSchema>;
// These config entries are only accessible on a Typegate instance.
// They are not read from a global variable to enable test isolation and configurability.
export const typegateConfigBaseSchema = z.object({
tg_secret: z.string().transform((s: string, ctx) => {
const bytes = decodeBase64(s);
if (bytes.length != 64) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
`Base64 contains ${bytes.length} instead of 64 bytes (use openssl rand -base64 64 | tr -d '\n')`,
});
}
return bytes;
}),
tg_secret: z
.string()
.optional()
.transform((s: string | undefined, ctx) => {
if (s === undefined) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
"Error: Env var TG_SECRET is not configured. Exiting from the application.",
});

return z.NEVER;
}

const bytes = decodeBase64(s);
if (bytes.length != 64) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
`Base64 contains ${bytes.length} instead of 64 bytes (use openssl rand -base64 64 | tr -d '\n')`,
});
}
return bytes;
}),
timer_max_timeout_ms: z.coerce.number().positive().max(60000),
timer_destroy_resources: z.boolean(),
timer_policy_eval_retries: z.number().nonnegative().max(5),
tg_admin_password: z.string(),
tg_admin_password: z
.string()
.optional()
.transform((s: string | undefined, ctx) => {
if (s === undefined) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
"Error: Env var TG_ADMIN_PASSWORD is not configured. Exiting from the application.",
});

return z.NEVER;
}

return s;
}),
tmp_dir: z.string(),
jwt_max_duration_sec: z.coerce.number().positive(),
jwt_refresh_duration_sec: z.coerce.number().positive(),
Expand Down
10 changes: 1 addition & 9 deletions website/blog/2023-03-15-emulating-servers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,8 @@ npm install

Before deploying the typegraph to the embedded typegate, Run the following commands below.

Execute this command to set `tg_secret` and `tg_admin_password` environment variables, which are neccessary for the typegate to run.

```shell
export tg_secret=a4lNi0PbEItlFZbus1oeH/+wyIxi9uH6TpL8AIqIaMBNvp7SESmuUBbfUwC0prxhGhZqHw8vMDYZAGMhSZ4fLw== tg_admin_password=password
```

Start the typegate instance.

```shell
meta typegate
meta dev
```

Now that there is running instance of a typegate, you can deploy the example typegraph. From another terminal, run the command below.
Expand Down
1 change: 1 addition & 0 deletions website/docs/reference/meta-cli/available-commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| undeploy | <pre><p>meta undeploy --target dev --typegraph logs accounting services</p></pre> | Undeploy typegraphs by name |
| gen | <pre><p>meta gen mod --file path/to/typegraph.py</p><p></p>meta gen mdk</pre> | Generate script or files that are used in your typegraph |
| typegate | <pre><p>meta typegate --quiet</p></pre> | Access a minimal deno CLI |
| dev | <pre><p>meta dev</p></pre> | Launch CLI in dev mode |

:::info

Expand Down
2 changes: 1 addition & 1 deletion website/docs/reference/meta-cli/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DocCardList from "@theme/DocCardList";

<InstallMetaCli />

For development purposes, the cli bundles the typegate itself and this can be accessed through the `meta typegate` subcommand.
For development purposes, the cli bundles the typegate itself and this can be accessed through the `meta dev` subcommand.

<br />

Expand Down
6 changes: 5 additions & 1 deletion website/shared/install/typegate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import EmbeddedTypegate from "../meta-cli/embedded-typegate.mdx";
### Using Embedded Typegate (Recommended)

```shell
meta typegate
meta dev
```

:::note
You can launch the embedded typegate via two subcommands, `meta dev` and `meta typegate`. Check the [Embedded Typegate](/docs/reference/meta-cli/embedded-typegate) for more info.
:::

The typegate instance runs on port `7890` by default. You can check if the typegate node is running by accessing [http://localhost:7890](http://localhost:7890) in your browser.

<details>
Expand Down
22 changes: 18 additions & 4 deletions website/shared/meta-cli/embedded-typegate.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
The _Meta CLI_ comes with an embedded typegate packaged inside it. A [typegate](/docs/reference/typegate) instance is where you deploy your [typegraphs](/docs/reference/typegraph) where any logic written in them is exposed via an HTTP or GraphQL endpoints. You can run an embedded typegate node from the terminal, but you first need to set a couple of environment variables which are needed to instantiate the typegate node.
The _Meta CLI_ comes with an embedded typegate packaged inside it. A [typegate](/docs/reference/typegate) instance is where you deploy your [typegraphs](/docs/reference/typegraph) where any logic written in them is exposed via an HTTP or GraphQL endpoints. You can run an embedded typegate node from the terminal. There are two ways to launch the embedded typegate

:::note
If you have not installed _Meta CLI_ or you have downloaded the _thin_ version, you can check [this](/docs/reference/meta-cli#Installation) installation guide of the _CLI_.
:::

### 1. `dev` subcommand

You can start the embedded typegatxe easily with default configs using the following command.

```shell
meta dev
```

The above command can be a good gateway to get started and also for development purposes. But if you want more granular control, you can use the second approach.

### 2. `typegate` subcommand

Set the `tg_admin_password` and `tg_secret` environment variables. You can use the following command to configure a sample value for the variables and test the embedded typegate.

```shell
export tg_secret=a4lNi0PbEItlFZbus1oeH/+wyIxi9uH6TpL8AIqIaMBNvp7SESmuUBbfUwC0prxhGhZqHw8vMDYZAGMhSZ4fLw== tg_admin_password=password
```

If you have not installed _Meta CLI_ or you have downloaded the _thin_ version, you can check [this](/docs/reference/meta-cli#Installation) installation guide of the _CLI_.

Everything is setup to run the embedded typegate. Just run the following command below.
Run the instance

```shell
meta typegate
Expand Down
2 changes: 1 addition & 1 deletion website/shared/projects/tab-first-project-python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ With these simple steps, you were able to build a basic backend with database ca
You are almost there to test your first `Metatype` application. You now need to spin a [Tyepgate](/docs/reference/typegate) and deploy your typegraph to the instance. You can leverage the embedded typegate that comes with the _Meta CLI_. To run the [embedded typegate](/docs/reference/meta-cli/embedded-typegate), execute the following command from your terminal.

```shell
meta typegate
meta dev
```

Once you started your typegate instance using one of the available choice, if you open [localhost:7890](http://localhost:7890) in your browser, you will get a webpage similar to this one.
Expand Down
2 changes: 1 addition & 1 deletion website/shared/projects/tab-first-project-ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ With these three simple steps, you were able to build a basic backend with datab
You are almost there to test your first `Metatype` application. You now need to spin a [Tyepgate](/docs/reference/typegate) and deploy your typegraph to the instance. You can leverage the embedded typegate that comes with the _Meta CLI_. To run the [embedded typegate](/docs/reference/meta-cli/embedded-typegate), execute the following command from your terminal.

```bash
meta typegate
meta dev
```

Once you started your typegate instance using one of the available choice, if you open [localhost:7890](http://localhost:7890) in your browser, you will get a webpage similar to this one.
Expand Down

0 comments on commit 7c64c45

Please sign in to comment.