Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul SDK docs #89

Merged
merged 22 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ lint:
- linters: [ALL]
paths:
- styles
- snippets
- linters: [checkov]
paths:
- mint.json
Expand Down
80 changes: 72 additions & 8 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
"url": "modus"
}
],
"redirects": [
{
"source": "/modus/sdk/:slug*",
"destination": "/modus/sdk/assemblyscript/:slug*"
}
],
"navigation": [
{
"group": "Getting Started",
Expand Down Expand Up @@ -98,14 +104,72 @@
{
"group": "API Reference",
"pages": [
"modus/sdk/collections",
"modus/sdk/console",
"modus/sdk/dgraph",
"modus/sdk/graphql",
"modus/sdk/http",
"modus/sdk/neo4j",
"modus/sdk/models",
"modus/sdk/postgresql"
{
"group": "AssemblyScript",
"pages": [
{
"group": "Client APIs",
"pages": [
"modus/sdk/assemblyscript/graphql",
"modus/sdk/assemblyscript/http"
]
},
{
"group": "Database APIs",
"pages": [
"modus/sdk/assemblyscript/dgraph",
"modus/sdk/assemblyscript/mysql",
"modus/sdk/assemblyscript/neo4j",
"modus/sdk/assemblyscript/postgresql"
]
},
{
"group": "Inference APIs",
"pages": ["modus/sdk/assemblyscript/models"]
},
{
"group": "Storage APIs",
"pages": ["modus/sdk/assemblyscript/collections"]
},
{
"group": "System APIs",
"pages": [
"modus/sdk/assemblyscript/console",
"modus/sdk/assemblyscript/localtime"
]
}
]
},
{
"group": "Go",
"pages": [
{
"group": "Client APIs",
"pages": ["modus/sdk/go/graphql", "modus/sdk/go/http"]
},
{
"group": "Database APIs",
"pages": [
"modus/sdk/go/dgraph",
"modus/sdk/go/mysql",
"modus/sdk/go/neo4j",
"modus/sdk/go/postgresql"
]
},
{
"group": "Inference APIs",
"pages": ["modus/sdk/go/models"]
},
{
"group": "Storage APIs",
"pages": ["modus/sdk/go/collections"]
},
{
"group": "System APIs",
"pages": ["modus/sdk/go/console", "modus/sdk/go/localtime"]
}
]
}
]
},
{
Expand Down
147 changes: 98 additions & 49 deletions modus/app-manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ connection types:
| Type | Purpose | Function Classes |
| :----------- | :------------------------------- | :-------------------------- |
| `http` | Connect to an HTTP(S) web server | `http`, `graphql`, `models` |
| `postgresql` | Connect to a PostgreSQL database | `postgresql` |
| `dgraph` | Connect to a Dgraph database | `dgraph` |
| `mysql` | Connect to a MySQL database | `mysql` |
| `neo4j` | Connect to a Neo4j database | `neo4j` |
| `postgresql` | Connect to a PostgreSQL database | `postgresql` |

<Warning>
**Don't include secrets directly in the manifest!**
Expand Down Expand Up @@ -246,88 +247,83 @@ This example specifies a query parameter named `key` provided by a secret named
</Accordion>
</ResponseField>

### PostgreSQL connection
### Dgraph connection

This connection type supports connecting to PostgreSQL databases. You can use
the [PostgreSQL APIs](/modus/sdk/postgresql) in the Modus SDK to interact with
the database.
This connection type supports connecting to Dgraph databases. You can use the
[Dgraph APIs](/modus/sdk/dgraph) in the Modus SDK to interact with the database.

**Example:**

```json modus.json
{
"connections": {
"my-database": {
"type": "postgresql",
"connString": "postgresql://{{PG_USER}}:{{PG_PASSWORD}}@db.example.com:5432/data?sslmode=require"
"my-dgraph": {
"type": "dgraph",
"grpcTarget": "frozen-mango.grpc.eu-central-1.aws.cloud.dgraph.io:443",
"key": "{{DGRAPH_API_KEY}}"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"postgresql"` for this connection type.
Always set to `"dgraph"` for this connection type.
</ResponseField>

<ResponseField name="connString" type="string" required>
The connection string for the PostgreSQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `PG_USER` & `PG_PASSWORD`
- A host named `db.example.com` on port `5432`
- A database named `data`
- SSL mode set to `require` - which is highly recommended for secure connections

Refer to
[the PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
for more details on connection strings.

<Tip>

Managed PostgreSQL providers often provide a pre-made connection string for you
to copy. Check your provider's documentation for details.

For example, if using Neon, refer to the
[Neon documentation](https://neon.tech/docs/connect/connect-from-any-app).

</Tip>
<ResponseField name="grpcTarget" type="string" required>
The gRPC target for the Dgraph database.
</ResponseField>

<ResponseField name="key" type="string" required>
The API key for the Dgraph database.
</ResponseField>

### Dgraph connection
### MySQL connection

This connection type supports connecting to Dgraph databases. You can use the
[Dgraph APIs](/modus/sdk/dgraph) in the Modus SDK to interact with the database.
This connection type supports connecting to MySQL databases. You can use the
[MySQL APIs](/modus/sdk/mysql) in the Modus SDK to interact with the database.

**Example:**

```json modus.json
{
"connections": {
"my-dgraph": {
"type": "dgraph",
"grpcTarget": "frozen-mango.grpc.eu-central-1.aws.cloud.dgraph.io:443",
"key": "{{DGRAPH_API_KEY}}"
"my-database": {
"type": "mysql",
"connString": "mysql://{{USERNAME}}:{{PASSWORD}}@db.example.com:3306/dbname?tls=true"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"dgraph"` for this connection type.
Always set to `"mysql"` for this connection type.
</ResponseField>

<ResponseField name="grpcTarget" type="string" required>
The gRPC target for the Dgraph database.
</ResponseField>
<ResponseField name="connString" type="string" required>
The connection string for the MySQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `USERNAME` & `PASSWORD`
- A host named `db.example.com` on port `3306`
- A database named `dbname`
- Encryption enabled via `tls=true` - which is highly recommended for secure
connections

Set the connection string using a URI format
[as described in the MySQL documentation](https://dev.mysql.com/doc/refman/8.4/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri).

However, any optional parameters provided should be in the form specified by the
Go MySQL driver used by the Modus Runtime,
[as described here](https://github.com/go-sql-driver/mysql/blob/master/README.md#parameters)

For example, use `tls=true` to enable encryption (not `sslmode=require`).

<ResponseField name="key" type="string" required>
The API key for the Dgraph database.
</ResponseField>

### Neo4j connection
Expand Down Expand Up @@ -366,6 +362,59 @@ This connection type supports connecting to Neo4j databases. You can use the
The password for the Neo4j database.
</ResponseField>

### PostgreSQL connection

This connection type supports connecting to PostgreSQL databases. You can use
the [PostgreSQL APIs](/modus/sdk/postgresql) in the Modus SDK to interact with
the database.

**Example:**

```json modus.json
{
"connections": {
"my-database": {
"type": "postgresql",
"connString": "postgresql://{{PG_USER}}:{{PG_PASSWORD}}@db.example.com:5432/data?sslmode=require"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"postgresql"` for this connection type.
</ResponseField>

<ResponseField name="connString" type="string" required>
The connection string for the PostgreSQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `PG_USER` & `PG_PASSWORD`
- A host named `db.example.com` on port `5432`
- A database named `data`
- SSL mode set to `require` - which is highly recommended for secure connections

Refer to
[the PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
for more details on connection strings.

<Tip>

Managed PostgreSQL providers often provide a pre-made connection string for you
to copy. Check your provider's documentation for details.

For example, if using Neon, refer to the
[Neon documentation](https://neon.tech/docs/connect/connect-from-any-app).

</Tip>

</ResponseField>

### Working locally with secrets

When you run your app locally using `modus dev`, the runtime replaces the
Expand Down
Loading
Loading