Skip to content

Commit

Permalink
Entrypoints doc updates (#113)
Browse files Browse the repository at this point in the history
Reflect changes to `entrypoints` management in DBOS Transact
  • Loading branch information
maxdml authored Apr 23, 2024
1 parent 5fd14e8 commit c12638c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
18 changes: 8 additions & 10 deletions docs/api-reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ The DBOS Transact CLI helps you run applications locally.

### `npx dbos start`

**Description:**
**Description:**
This command launches the DBOS Transact runtime and HTTP server to serve an application.
It registers all functions and serves all endpoints in classes exported from the specified entrypoint file (typically `src/operations.ts`).
It registers all functions and serves all endpoints in classes exported by the [declared entrypoint files](./configuration#runtime) (`dist/operations.js` by default).
Parameters set from the command line take precedence over parameters set in the [configuration file](./configuration).
You must compile your code (`npm run build`) before running this command.

**Parameters:**
**Parameters:**
- `-p, --port <port-number>`: The port on which to serve your functions.
- `-l, --loglevel <log-level>`: The severity of log entries emitted. Can be one of `debug`, `info`, `warn`, `error`, `emerg`, `crit`, `alert`.
- `-c, --configfile <config-file>`: The path to a YAML [configuration file](./configuration) to use.
- `-e, --entrypoint <entrypoint-file>`: The path to an [entrypoint file](./configuration) to use.

---

Expand All @@ -31,10 +30,10 @@ You must compile your code (`npm run build`) before running this command.
**Synonyms**
`npm create @dbos-inc` and `npm init @dbos-inc` are synonyms for `npx @dbos-inc/create`. When using `npm create @dbos-inc` with any of the command line switches below, be sure to use `--` to separate `npm` arguments from the arguments intended for `@dbos-inc/create`.

**Description:**
**Description:**
This command initializes a new DBOS application from a template into a target directory. By default, it instantiates the "Hello, Database!" application used in the [quickstart](../getting-started/quickstart).

**Parameters:**
**Parameters:**
- `-n, --appName <app-name>`: The name and directory to which to instantiate the application. Application names should be between 3 and 30 characters and must contain only lowercase letters and numbers, dashes (`-`), and underscores (`_`).
- `-t, --templateName <template>`: The template to use for project creation, such as 'hello'.

Expand Down Expand Up @@ -80,16 +79,15 @@ You must compile your code (`npm run build`) and start the debug proxy before ru
- `-x, --proxy <string>`: The time travel debug proxy URL (default: "postgresql://localhost:2345").
- `-l, --loglevel <log-level>`: The severity of log entries emitted. Can be one of `debug`, `info`, `warn`, `error`, `emerg`, `crit`, `alert`.
- `-c, --configfile <config-file>`: The path to a YAML [configuration file](./configuration) to use.
- `-e, --entrypoint <entrypoint-file>`: The path to an [entrypoint file](./configuration) to use.

---

### `npx dbos-openapi generate`

**Description:**
**Description:**
This command generates an [OpenAPI 3.0.x](https://www.openapis.org/) definition file for a DBOS application.
The generated file is named `openapi.yaml` and is saved to the same directory as the TypeScript entrypoint file.
For more information, please see the [OpenAPI Tutorial](../tutorials/openapi-tutorial.md).

**Arguments:**
- `<entrypoint>`: Path to the application's TypeScript entrypoint (typically `src/operations.ts`)
**Arguments:**
- `<entrypoints>`: Path to the application's TypeScript entrypoints (for example, `src/a.ts src/b.ts`)
7 changes: 4 additions & 3 deletions docs/api-reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ If either does not exist, the Postgres role must have the [`CREATEDB`](https://w
This section is used to specify DBOS runtime parameters.

- **port** (optional): The port from which to serve your functions. Defaults to `3000`. Using [`npx dbos start -p <port>`](./cli#npx-dbos-start) overrides this config parameter.
- **entrypoint** (optional): The compiled Javascript file where DBOS looks for your application's code. At startup, the DBOS runtime automatically loads all classes exported from this file, serving their endpoints and registering their decorated functions. Defaults to `dist/operations.js`. Using [`npx dbos start -e <entrypoint-file>`](./cli#npx-dbos-start) overrides this config parameter.
- **entrypoints** (optional): The compiled Javascript files where DBOS looks for your application's code. At startup, the DBOS runtime automatically loads all classes exported from these files, serving their endpoints and registering their decorated functions. Defaults to `[dist/operations.js]`.

**Example**:

```yaml
runtimeConfig:
port: 6000 # Optional, defaults to 3000
entrypoint: 'dist/operations.js' # (default)
port: 3000 # (default)
entrypoints:
- 'dist/operations.js' # (default)
```
---

Expand Down
2 changes: 1 addition & 1 deletion docs/explanations/application-structure-explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ In a larger application, you can write your code wherever you want, but should u
export { OperationClass1, OperationClass2 } from './FileA';
export { OperationClass3 } from './operations/FileB';
```
You can also configure the entrypoint in our [configuration file](../api-reference/configuration#runtime).
You can also configure a list of entrypoints using the `runtimeConfig` section of the [configuration](../api-reference/configuration#runtime).

As for the rest of the directory:

Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started/quickstart-programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ import {
import { Knex } from "knex";

export class Greetings {
@Communicator()
static async SendGreetingEmail(ctxt: CommunicatorContext, friend: string, content: string) {
ctxt.logger.info(`Sending email "${content}" to ${friend}...`);
// Code omitted for simplicity
ctxt.logger.info("Email sent!");
}
@Communicator()
static async SendGreetingEmail(ctxt: CommunicatorContext, friend: string, content: string) {
ctxt.logger.info(`Sending email "${content}" to ${friend}...`);
// Code omitted for simplicity
ctxt.logger.info("Email sent!");
}

@Transaction()
static async InsertGreeting(ctxt: TransactionContext<Knex>, friend: string, content: string) {
Expand Down
12 changes: 6 additions & 6 deletions docs/tutorials/openapi-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ To generate a OpenAPI definition file for a DBOS application, run the following
npx dbos-openapi generate src/operations.ts
```

This command takes a single required argument - the path to the DBOS application's TypeScript entrypoint file.
This command takes a single required argument - the path to the DBOS application's TypeScript entrypoint files.
For DBOS applications generated by [`npx @dbos-inc/create`](../api-reference/cli.md#npx-dbos-inccreate), the entrypoint will be `src/operations.ts`.

The `dbos-openapi generate` command generates an OpenAPI definition file `openapi.yaml` in the same folder as the entrypoint file.
The `dbos-openapi generate` command generates an OpenAPI definition file `openapi.yaml` in the same folder as the entrypoint files.

::::info
This entrypoint argument is slightly different from the [`runtimeConfig.entrypoint`](../api-reference/configuration.md#runtime) config setting.
The `dbos-openapi generate` argument references the TypeScript entrypoint file.
The `runtimeConfig.entrypoint` setting references the JavaScript file generated from the TypeScript entrypoint file.
This `entrypoints` argument is slightly different from the [`runtimeConfig.entrypoints`](../api-reference/configuration.md#runtime) config setting.
The `dbos-openapi generate` argument references the TypeScript entrypoint files.
The `runtimeConfig.entrypoints` setting references the JavaScript file generated from the TypeScript entrypoint files.
::::

### Generate Client Code From OpenAPI Definition
Expand All @@ -46,7 +46,7 @@ Some of these tools include:

We can't provide tutorials for all of these OpenAPI generator tools, but the Swagger Editor runs in the browser so is straightforward to use for a simple tutorial

First, you need to run `npx dbos-openapi generate` against your DBOS application entrypoint as described above.
First, you need to run `npx dbos-openapi generate` against your DBOS application entrypoints as described above.

::::info
Note, the shop and payment backend applications from the [DBOS E-Commerce demo app](./demo-apps.md#e-commerce)
Expand Down

0 comments on commit c12638c

Please sign in to comment.