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

Entrypoints doc updates #113

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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) (`src/operations.ts` by default).
maxdml marked this conversation as resolved.
Show resolved Hide resolved
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
9 changes: 1 addition & 8 deletions docs/explanations/application-structure-explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ All options are documented in our [configuration reference](../api-reference/con
`src/operations.ts` is the _entrypoint_, where DBOS looks for your code.
At startup, the DBOS runtime automatically loads all classes exported from this file, serving their endpoints and registering their decorated functions.
More precisely, DBOS assumes your compiled code is exported from `dist/operations.js`, the default location to which `src/operations.ts` is compiled.
If you're writing a small application, you can write all your code directly in this file.
In a larger application, you can write your code wherever you want, but should use `src/operations.ts` as an index file, exporting code written elsewhere:
maxdml marked this conversation as resolved.
Show resolved Hide resolved
```typescript
// Placed in operations.ts:
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
Loading