@dbos-inc/create 1.31.13-preview.g4f38e6e769 → 1.31.16-preview

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/templates/hello/README.md +11 -30
  3. package/templates/hello/package.json +1 -5
  4. package/templates/hello/src/operations.test.ts +7 -8
  5. package/templates/hello/src/operations.ts +11 -13
  6. package/templates/{hello-v2 → hello-contexts}/README.md +30 -9
  7. package/templates/{hello-v2 → hello-contexts}/package.json +5 -1
  8. package/templates/{hello-v2 → hello-contexts}/src/operations.test.ts +8 -7
  9. package/templates/{hello-v2 → hello-contexts}/src/operations.ts +13 -11
  10. package/templates/hello-drizzle/README.md +6 -6
  11. package/templates/hello-drizzle/package.json +2 -2
  12. package/templates/hello-drizzle/src/operations.test.ts +7 -8
  13. package/templates/hello-drizzle/src/operations.ts +7 -7
  14. package/templates/hello-express/README.md +10 -8
  15. package/templates/hello-express/dbos-config.yaml +1 -1
  16. package/templates/hello-express/src/main.test.ts +1 -1
  17. package/templates/hello-express/src/main.ts +86 -3
  18. package/templates/hello-nextjs/README.md +21 -12
  19. package/templates/hello-nextjs/src/actions/dbosWorkflow.tsx +24 -0
  20. package/templates/hello-nextjs/src/app/crash/route.ts +8 -0
  21. package/templates/hello-nextjs/src/app/page.tsx +10 -2
  22. package/templates/hello-nextjs/src/app/step/[slug]/route.ts +15 -0
  23. package/templates/hello-nextjs/src/app/tasks/[slug]/route.ts +18 -0
  24. package/templates/hello-nextjs/src/components/client/BackGroundTask.tsx +180 -0
  25. package/templates/hello-prisma/README.md +8 -8
  26. package/templates/hello-prisma/src/operations.test.ts +6 -6
  27. package/templates/hello-prisma/src/operations.ts +7 -7
  28. package/templates/hello-typeorm/README.md +8 -8
  29. package/templates/hello-typeorm/src/operations.test.ts +7 -6
  30. package/templates/hello-typeorm/src/operations.ts +7 -7
  31. package/templates/hello-express/src/operations.ts +0 -81
  32. /package/templates/{hello-v2 → hello-contexts}/.vscode/extensions.json +0 -0
  33. /package/templates/{hello-v2 → hello-contexts}/.vscode/launch.json +0 -0
  34. /package/templates/{hello-v2 → hello-contexts}/.vscode/tasks.json +0 -0
  35. /package/templates/{hello-v2 → hello-contexts}/dbos-config.yaml +0 -0
  36. /package/templates/{hello-v2 → hello-contexts}/eslint.config.js +0 -0
  37. /package/templates/{hello-v2 → hello-contexts}/gitignore.template +0 -0
  38. /package/templates/{hello-v2 → hello-contexts}/jest.config.js +0 -0
  39. /package/templates/{hello-v2 → hello-contexts}/knexfile.js +0 -0
  40. /package/templates/{hello-v2 → hello-contexts}/migrations/20240212161006_create_dbos_hello_tables.js +0 -0
  41. /package/templates/{hello-v2 → hello-contexts}/nodemon.json +0 -0
  42. /package/templates/{hello-v2 → hello-contexts}/start_postgres_docker.js +0 -0
  43. /package/templates/{hello-v2 → hello-contexts}/tsconfig.json +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/create",
3
- "version": "1.31.13-preview.g4f38e6e769",
3
+ "version": "1.31.16-preview",
4
4
  "description": "Tool for performing project initialization from template",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  # DBOS Hello
2
2
 
3
- This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Knex](https://docs.dbos.dev/tutorials/using-knex).
3
+ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Knex](https://docs.dbos.dev/typescript/tutorials/orms/using-knex).
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -14,11 +14,11 @@ node start_postgres_docker.js
14
14
 
15
15
  If successful, the script should print `Database started successfully!`.
16
16
 
17
- Next, you can build and run the app in one step under `nodemon`:
18
-
17
+ To build the app, set up the database, and run, in one step:
19
18
  ```bash
20
19
  npm run dev
21
20
  ```
21
+ This uses `nodemon`, so if you change your app it will automatically restart with changes.
22
22
 
23
23
  To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
24
24
  You should get this message: `Hello, dbos! You have been greeted 1 times.`
@@ -26,10 +26,9 @@ Each time you refresh the page, the counter should go up by one!
26
26
 
27
27
  Congratulations! You just launched a DBOS application.
28
28
 
29
- ## Production build
30
-
31
- In production, instead of using `nodemon`, the following separate steps should be used to build, run database setup, and start the app.
29
+ ### Separate Build and Run Steps
32
30
 
31
+ To build the app:
33
32
  ```bash
34
33
  npm run build
35
34
  ```
@@ -37,7 +36,7 @@ npm run build
37
36
  Then, run a schema migration to create some tables:
38
37
 
39
38
  ```bash
40
- npx dbos-sdk migrate
39
+ npx dbos migrate
41
40
  ```
42
41
 
43
42
  If successful, the migration should print `Migration successful!`.
@@ -45,30 +44,12 @@ If successful, the migration should print `Migration successful!`.
45
44
  Finally, run the app:
46
45
 
47
46
  ```bash
48
- npx dbos-sdk start
49
- ```
50
-
51
- ## The application
52
-
53
- The core of the application resides in `src/operations.ts`. It declares an "hello world" DBOS workflow served at `/greetings/:user`. To add more functionality, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
54
-
55
- ## Running in DBOS Cloud
56
-
57
- To deploy this app to DBOS Cloud, first install the DBOS Cloud CLI (example with [npm](https://www.npmjs.com/)):
58
-
59
- ```shell
60
- npm i -g @dbos-inc/dbos-cloud
61
- ```
62
-
63
- Then, run this command to deploy your app:
64
-
65
- ```shell
66
- dbos-cloud app deploy
47
+ npx dbos start
67
48
  ```
68
49
 
69
- functionality to this application, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
70
-
71
50
  ## Next Steps
72
51
 
73
- - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
74
- - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-transact).
52
+ - To add more functionality to this application, modify `src/operations.ts`, and save it. If you are using, `npm run dev`, `nodemon` will rebuild and restart the app automatically.
53
+ - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
54
+ - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/quickstart)
55
+ - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc).
@@ -1,19 +1,15 @@
1
1
  {
2
- "name": "dbos-hello",
2
+ "name": "dbos-hello-v2",
3
3
  "version": "0.0.1",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "test": "npx dbos rollback && npx dbos migrate && jest",
7
- "lint": "eslint src",
8
- "lint-fix": "eslint --fix src",
9
7
  "dev": "nodemon",
10
8
  "start": "npx dbos start"
11
9
  },
12
10
  "devDependencies": {
13
- "@dbos-inc/eslint-plugin": "^3.3.4",
14
11
  "@types/jest": "^29.5.12",
15
12
  "@types/supertest": "^2.0.16",
16
- "eslint": "^8.57.0",
17
13
  "jest": "^29.7.0",
18
14
  "nodemon": "^3.1.0",
19
15
  "supertest": "^7.0.0",
@@ -1,27 +1,26 @@
1
- import { TestingRuntime, createTestingRuntime } from "@dbos-inc/dbos-sdk";
1
+ import { DBOS } from "@dbos-inc/dbos-sdk";
2
2
  import { Hello, dbos_hello } from "./operations";
3
3
  import request from "supertest";
4
4
 
5
5
  describe("operations-test", () => {
6
- let testRuntime: TestingRuntime;
7
-
8
6
  beforeAll(async () => {
9
- testRuntime = await createTestingRuntime();
7
+ await DBOS.launch();
8
+ await DBOS.launchAppHTTPServer();
10
9
  });
11
10
 
12
11
  afterAll(async () => {
13
- await testRuntime.destroy();
12
+ await DBOS.shutdown();
14
13
  });
15
14
 
16
15
  /**
17
16
  * Test the transaction.
18
17
  */
19
18
  test("test-transaction", async () => {
20
- const res = await testRuntime.invoke(Hello).helloTransaction("dbos");
19
+ const res = await Hello.helloTransaction("dbos");
21
20
  expect(res).toMatch("Hello, dbos! You have been greeted");
22
21
 
23
22
  // Check the greet count.
24
- const rows = await testRuntime.queryUserDB<dbos_hello>("SELECT * FROM dbos_hello WHERE name=$1", "dbos");
23
+ const rows = await DBOS.executor.queryUserDB("SELECT * FROM dbos_hello WHERE name=$1", ["dbos"]) as dbos_hello[];
25
24
  expect(rows[0].greet_count).toBe(1);
26
25
  });
27
26
 
@@ -29,7 +28,7 @@ describe("operations-test", () => {
29
28
  * Test the HTTP endpoint.
30
29
  */
31
30
  test("test-endpoint", async () => {
32
- const res = await request(testRuntime.getHandlersCallback()).get(
31
+ const res = await request(DBOS.getHTTPHandlersCallback()).get(
33
32
  "/greeting/dbos"
34
33
  );
35
34
  expect(res.statusCode).toBe(200);
@@ -2,36 +2,34 @@
2
2
 
3
3
  // This is a sample "Hello" app built with DBOS.
4
4
  // It greets visitors and keeps track of how many times each visitor has been greeted.
5
- // To run this app, visit our Quickstart: https://docs.dbos.dev/getting-started/quickstart
6
5
 
7
- import { HandlerContext, TransactionContext, Transaction, GetApi, ArgSource, ArgSources } from "@dbos-inc/dbos-sdk";
8
- import { Knex } from "knex";
6
+ // First, let's import DBOS
7
+ import { DBOS } from "@dbos-inc/dbos-sdk";
9
8
 
10
- // The schema of the database table used in this example.
9
+ // Then, let's declare a type representing the "dbos_hello" database table
11
10
  export interface dbos_hello {
12
11
  name: string;
13
12
  greet_count: number;
14
13
  }
15
14
 
15
+ // Now let's define a class with some static functions.
16
+ // DBOS uses TypeScript decorators to automatically make your functions reliable, so they need to be static.
16
17
  export class Hello {
17
18
  // Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
18
- // The @Transaction() decorator ensures that this function runs as a database transaction.
19
- @GetApi("/greeting/:user")
20
- @Transaction() // Run this function as a database transaction
21
- static async helloTransaction(ctxt: TransactionContext<Knex>, @ArgSource(ArgSources.URL) user: string) {
19
+ @DBOS.getApi("/greeting/:user")
20
+ @DBOS.transaction() // Run this function as a database transaction
21
+ static async helloTransaction(user: string) {
22
22
  // Retrieve and increment the number of times this user has been greeted.
23
23
  const query = "INSERT INTO dbos_hello (name, greet_count) VALUES (?, 1) ON CONFLICT (name) DO UPDATE SET greet_count = dbos_hello.greet_count + 1 RETURNING greet_count;";
24
- const { rows } = await ctxt.client.raw(query, [user]) as { rows: dbos_hello[] };
24
+ const { rows } = (await DBOS.knexClient.raw(query, [user])) as { rows: dbos_hello[] };
25
25
  const greet_count = rows[0].greet_count;
26
26
  const greeting = `Hello, ${user}! You have been greeted ${greet_count} times.`;
27
27
  return Hello.makeHTML(greeting);
28
28
  }
29
29
 
30
- // Let's declare helper functions to serve static HTML
31
-
32
30
  // Serve a quick readme for the app at the / endpoint
33
- @GetApi('/')
34
- static async readme(_ctxt: HandlerContext) {
31
+ @DBOS.getApi("/")
32
+ static async readme() {
35
33
  const message = Hello.makeHTML(
36
34
  `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
37
35
  For example, visit <code class="bg-gray-100 px-1 rounded"><a href="/greeting/Mike" class="text-blue-600 hover:underline">/greeting/Mike</a></code><br>
@@ -1,6 +1,8 @@
1
1
  # DBOS Hello
2
2
 
3
- This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Knex](https://docs.dbos.dev/tutorials/using-knex).
3
+ *NOTE:* This is an older version of the DBOS `hello` app that uses a previous API based on passing [DBOS contexts](https://docs.dbos.dev/typescript/reference/transactapi/oldapi/contexts) around as function arguments.
4
+
5
+ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Knex](https://docs.dbos.dev/typescript/tutorials/orms/using-knex).
4
6
 
5
7
  ## Getting Started
6
8
 
@@ -14,11 +16,11 @@ node start_postgres_docker.js
14
16
 
15
17
  If successful, the script should print `Database started successfully!`.
16
18
 
17
- To build the app, set up the database, and run, in one step:
19
+ Next, you can build and run the app in one step under `nodemon`:
20
+
18
21
  ```bash
19
22
  npm run dev
20
23
  ```
21
- This uses `nodemon`, so if you change your app it will automatically restart with changes.
22
24
 
23
25
  To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
24
26
  You should get this message: `Hello, dbos! You have been greeted 1 times.`
@@ -26,9 +28,10 @@ Each time you refresh the page, the counter should go up by one!
26
28
 
27
29
  Congratulations! You just launched a DBOS application.
28
30
 
29
- ### Separate Build and Run Steps
31
+ ## Production build
32
+
33
+ In production, instead of using `nodemon`, the following separate steps should be used to build, run database setup, and start the app.
30
34
 
31
- To build the app:
32
35
  ```bash
33
36
  npm run build
34
37
  ```
@@ -36,7 +39,7 @@ npm run build
36
39
  Then, run a schema migration to create some tables:
37
40
 
38
41
  ```bash
39
- npx dbos-sdk migrate
42
+ npx dbos migrate
40
43
  ```
41
44
 
42
45
  If successful, the migration should print `Migration successful!`.
@@ -44,12 +47,30 @@ If successful, the migration should print `Migration successful!`.
44
47
  Finally, run the app:
45
48
 
46
49
  ```bash
47
- npx dbos-sdk start
50
+ npx dbos start
48
51
  ```
49
52
 
53
+ ## The application
54
+
55
+ The core of the application resides in `src/operations.ts`. It declares an "hello world" DBOS workflow served at `/greetings/:user`. To add more functionality, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
56
+
57
+ ## Running in DBOS Cloud
58
+
59
+ To deploy this app to DBOS Cloud, first install the DBOS Cloud CLI (example with [npm](https://www.npmjs.com/)):
60
+
61
+ ```shell
62
+ npm i -g @dbos-inc/dbos-cloud
63
+ ```
64
+
65
+ Then, run this command to deploy your app:
66
+
67
+ ```shell
68
+ dbos-cloud app deploy
69
+ ```
70
+
71
+ functionality to this application, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
72
+
50
73
  ## Next Steps
51
74
 
52
- - To add more functionality to this application, modify `src/operations.ts`, and save it. If you are using, `npm run dev`, `nodemon` will rebuild and restart the app automatically.
53
75
  - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
54
- - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/getting-started/quickstart-cloud/)
55
76
  - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-transact).
@@ -1,15 +1,19 @@
1
1
  {
2
- "name": "dbos-hello-v2",
2
+ "name": "dbos-hello",
3
3
  "version": "0.0.1",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "test": "npx dbos rollback && npx dbos migrate && jest",
7
+ "lint": "eslint src",
8
+ "lint-fix": "eslint --fix src",
7
9
  "dev": "nodemon",
8
10
  "start": "npx dbos start"
9
11
  },
10
12
  "devDependencies": {
13
+ "@dbos-inc/eslint-plugin": "^3.3.4",
11
14
  "@types/jest": "^29.5.12",
12
15
  "@types/supertest": "^2.0.16",
16
+ "eslint": "^8.57.0",
13
17
  "jest": "^29.7.0",
14
18
  "nodemon": "^3.1.0",
15
19
  "supertest": "^7.0.0",
@@ -1,26 +1,27 @@
1
- import { DBOS } from "@dbos-inc/dbos-sdk";
1
+ import { TestingRuntime, createTestingRuntime } from "@dbos-inc/dbos-sdk";
2
2
  import { Hello, dbos_hello } from "./operations";
3
3
  import request from "supertest";
4
4
 
5
5
  describe("operations-test", () => {
6
+ let testRuntime: TestingRuntime;
7
+
6
8
  beforeAll(async () => {
7
- await DBOS.launch();
8
- await DBOS.launchAppHTTPServer();
9
+ testRuntime = await createTestingRuntime();
9
10
  });
10
11
 
11
12
  afterAll(async () => {
12
- await DBOS.shutdown();
13
+ await testRuntime.destroy();
13
14
  });
14
15
 
15
16
  /**
16
17
  * Test the transaction.
17
18
  */
18
19
  test("test-transaction", async () => {
19
- const res = await Hello.helloTransaction("dbos");
20
+ const res = await testRuntime.invoke(Hello).helloTransaction("dbos");
20
21
  expect(res).toMatch("Hello, dbos! You have been greeted");
21
22
 
22
23
  // Check the greet count.
23
- const rows = await DBOS.executor.queryUserDB("SELECT * FROM dbos_hello WHERE name=$1", ["dbos"]) as dbos_hello[];
24
+ const rows = await testRuntime.queryUserDB<dbos_hello>("SELECT * FROM dbos_hello WHERE name=$1", "dbos");
24
25
  expect(rows[0].greet_count).toBe(1);
25
26
  });
26
27
 
@@ -28,7 +29,7 @@ describe("operations-test", () => {
28
29
  * Test the HTTP endpoint.
29
30
  */
30
31
  test("test-endpoint", async () => {
31
- const res = await request(DBOS.getHTTPHandlersCallback()).get(
32
+ const res = await request(testRuntime.getHandlersCallback()).get(
32
33
  "/greeting/dbos"
33
34
  );
34
35
  expect(res.statusCode).toBe(200);
@@ -2,34 +2,36 @@
2
2
 
3
3
  // This is a sample "Hello" app built with DBOS.
4
4
  // It greets visitors and keeps track of how many times each visitor has been greeted.
5
+ // To run this app, visit our Quickstart: https://docs.dbos.dev/getting-started/quickstart
5
6
 
6
- // First, let's import DBOS
7
- import { DBOS } from "@dbos-inc/dbos-sdk";
7
+ import { HandlerContext, TransactionContext, Transaction, GetApi, ArgSource, ArgSources } from "@dbos-inc/dbos-sdk";
8
+ import { Knex } from "knex";
8
9
 
9
- // Then, let's declare a type representing the "dbos_hello" database table
10
+ // The schema of the database table used in this example.
10
11
  export interface dbos_hello {
11
12
  name: string;
12
13
  greet_count: number;
13
14
  }
14
15
 
15
- // Now let's define a class with some static functions.
16
- // DBOS uses TypeScript decorators to automatically make your functions reliable, so they need to be static.
17
16
  export class Hello {
18
17
  // Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
19
- @DBOS.getApi("/greeting/:user")
20
- @DBOS.transaction() // Run this function as a database transaction
21
- static async helloTransaction(user: string) {
18
+ // The @Transaction() decorator ensures that this function runs as a database transaction.
19
+ @GetApi("/greeting/:user")
20
+ @Transaction() // Run this function as a database transaction
21
+ static async helloTransaction(ctxt: TransactionContext<Knex>, @ArgSource(ArgSources.URL) user: string) {
22
22
  // Retrieve and increment the number of times this user has been greeted.
23
23
  const query = "INSERT INTO dbos_hello (name, greet_count) VALUES (?, 1) ON CONFLICT (name) DO UPDATE SET greet_count = dbos_hello.greet_count + 1 RETURNING greet_count;";
24
- const { rows } = (await DBOS.knexClient.raw(query, [user])) as { rows: dbos_hello[] };
24
+ const { rows } = await ctxt.client.raw(query, [user]) as { rows: dbos_hello[] };
25
25
  const greet_count = rows[0].greet_count;
26
26
  const greeting = `Hello, ${user}! You have been greeted ${greet_count} times.`;
27
27
  return Hello.makeHTML(greeting);
28
28
  }
29
29
 
30
+ // Let's declare helper functions to serve static HTML
31
+
30
32
  // Serve a quick readme for the app at the / endpoint
31
- @DBOS.getApi("/")
32
- static async readme() {
33
+ @GetApi('/')
34
+ static async readme(_ctxt: HandlerContext) {
33
35
  const message = Hello.makeHTML(
34
36
  `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
35
37
  For example, visit <code class="bg-gray-100 px-1 rounded"><a href="/greeting/Mike" class="text-blue-600 hover:underline">/greeting/Mike</a></code><br>
@@ -1,6 +1,6 @@
1
1
  # DBOS Hello with Drizzle
2
2
 
3
- This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Drizzle](https://docs.dbos.dev/tutorials/using-drizzle).
3
+ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Drizzle](https://docs.dbos.dev/typescript/tutorials/orms/using-drizzle).
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -23,7 +23,7 @@ npm run build
23
23
  Then, run a schema migration to create some tables:
24
24
 
25
25
  ```bash
26
- npx dbos-sdk migrate
26
+ npx dbos migrate
27
27
  ```
28
28
 
29
29
  If successful, the migration should print `Migration successful!`.
@@ -31,7 +31,7 @@ If successful, the migration should print `Migration successful!`.
31
31
  Finally, run the app:
32
32
 
33
33
  ```bash
34
- npx dbos-sdk start
34
+ npx dbos start
35
35
  ```
36
36
 
37
37
  To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
@@ -43,6 +43,6 @@ Congratulations! You just launched a DBOS application.
43
43
  ## Next Steps
44
44
 
45
45
  - To add more functionality to this application, modify `src/operations.ts`, then rebuild and restart it. Alternatively, `npm run dev` uses `nodemon` to automatically rebuild and restart the app when source files change, using instructions specified in `nodemon.json`.
46
- - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
47
- - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/getting-started/quickstart-cloud/)
48
- - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-transact).
46
+ - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
47
+ - To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/quickstart)
48
+ - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc).
@@ -13,7 +13,7 @@
13
13
  "@dbos-inc/eslint-plugin": "^3.3.4",
14
14
  "@types/jest": "^29.5.12",
15
15
  "@types/supertest": "^2.0.16",
16
- "drizzle-kit": "^0.23.2",
16
+ "drizzle-kit": "^0.30.1",
17
17
  "eslint": "^8.57.0",
18
18
  "jest": "^29.7.0",
19
19
  "nodemon": "^3.1.0",
@@ -23,6 +23,6 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@dbos-inc/dbos-sdk": "file:../../../..",
26
- "drizzle-orm": "^0.32.2"
26
+ "drizzle-orm": "^0.38.3"
27
27
  }
28
28
  }
@@ -1,27 +1,26 @@
1
- import { TestingRuntime, createTestingRuntime } from "@dbos-inc/dbos-sdk";
1
+ import { DBOS } from "@dbos-inc/dbos-sdk";
2
2
  import { Hello } from "./operations";
3
3
  import request from "supertest";
4
4
 
5
5
  describe("operations-test", () => {
6
- let testRuntime: TestingRuntime;
7
-
8
6
  beforeAll(async () => {
9
- testRuntime = await createTestingRuntime();
7
+ await DBOS.launch();
8
+ await DBOS.launchAppHTTPServer();
10
9
  });
11
10
 
12
11
  afterAll(async () => {
13
- await testRuntime.destroy();
12
+ await DBOS.shutdown();
14
13
  });
15
14
 
16
15
  /**
17
16
  * Test the transaction.
18
17
  */
19
18
  test("test-transaction", async () => {
20
- const res = await testRuntime.invoke(Hello).helloTransaction("dbos");
19
+ const res = await Hello.helloTransaction("dbos");
21
20
  expect(res).toMatch("Hello, dbos! We have made");
22
21
 
23
22
  // Check the greet count.
24
- const rows = await testRuntime.queryUserDB("SELECT * FROM dbos_hello WHERE greet_count=1");
23
+ const rows = await DBOS.executor.queryUserDB("SELECT * FROM dbos_hello WHERE greet_count=1");
25
24
  expect(rows.length).toEqual(1);
26
25
  });
27
26
 
@@ -29,7 +28,7 @@ describe("operations-test", () => {
29
28
  * Test the HTTP endpoint.
30
29
  */
31
30
  test("test-endpoint", async () => {
32
- const res = await request(testRuntime.getHandlersCallback()).get(
31
+ const res = await request(DBOS.getHTTPHandlersCallback()).get(
33
32
  "/greeting/dbos"
34
33
  );
35
34
  expect(res.statusCode).toBe(200);
@@ -3,25 +3,25 @@
3
3
  // This is the Quickstart Drizzle template app. It greets visitors, counting how many total greetings were made.
4
4
  // To learn how to run this app, visit the Drizzle tutorial: https://docs.dbos.dev/tutorials/using-drizzle
5
5
 
6
- import { HandlerContext, TransactionContext, Transaction, GetApi } from '@dbos-inc/dbos-sdk';
6
+ import { DBOS } from '@dbos-inc/dbos-sdk';
7
7
  import { dbosHello } from './schema';
8
8
  import { NodePgDatabase } from 'drizzle-orm/node-postgres';
9
9
 
10
10
  export class Hello {
11
11
 
12
12
  // Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
13
- @GetApi('/greeting/:user')
14
- @Transaction()
15
- static async helloTransaction(ctxt: TransactionContext<NodePgDatabase>, user: string) {
13
+ @DBOS.getApi('/greeting/:user')
14
+ @DBOS.transaction()
15
+ static async helloTransaction(user: string) {
16
16
  const greeting = `Hello, ${user}!`;
17
- const greetings_output = await ctxt.client.insert(dbosHello).values({greeting}).returning({greet_count: dbosHello.greet_count});
17
+ const greetings_output = await (DBOS.drizzleClient as NodePgDatabase).insert(dbosHello).values({greeting}).returning({greet_count: dbosHello.greet_count});
18
18
  const greeting_message = `${greeting} We have made ${greetings_output[0].greet_count} greetings.`;
19
19
  return Hello.makeHTML(greeting_message);
20
20
  }
21
21
 
22
22
  // Serve a quick readme for the app at the / endpoint
23
- @GetApi('/')
24
- static async readme(_ctxt: HandlerContext) {
23
+ @DBOS.getApi('/')
24
+ static async readme() {
25
25
  const message = Hello.makeHTML(
26
26
  `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
27
27
  For example, visit <code class="bg-gray-100 px-1 rounded"><a href="/greeting/Mike" class="text-blue-600 hover:underline">/greeting/Mike</a></code><br>
@@ -1,6 +1,6 @@
1
1
  # DBOS Hello
2
2
 
3
- This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create`, using [Express.js](https://expressjs.com/) and [Knex](https://docs.dbos.dev/tutorials/using-knex) to interact with postgres.
3
+ This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create`, using [Express.js](https://expressjs.com/) and [Knex](https://docs.dbos.dev/typescript/tutorials/orms/using-knex) to interact with postgres.
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -37,7 +37,7 @@ npm run build
37
37
  Then, run a schema migration to create some tables:
38
38
 
39
39
  ```bash
40
- npx dbos-sdk migrate
40
+ npx dbos migrate
41
41
  ```
42
42
 
43
43
  If successful, the migration should print `Migration successful!`.
@@ -45,15 +45,17 @@ If successful, the migration should print `Migration successful!`.
45
45
  Finally, run the app:
46
46
 
47
47
  ```bash
48
- npx dbos-sdk start
48
+ npx dbos start
49
49
  ```
50
50
 
51
51
  ## The application
52
52
 
53
- - In `src/operations.ts`, the Express app object is created and configured to serve an "hello world" DBOS workflow on `/greetings/:user`. This file also hosts the code of said DBOS workflow: an `Hello` class with a single `helloTransaction` method.
54
- - `src/main.ts` declares the code to start a DBOS instance and an Express application. When you pass the Express app object as parameter to `DBOS.launch()`, DBOS will wrap all routes with an [OpenTelemetry](https://opentelemetry.io/) tracing middleware and tie HTTP traces to DBOS workflow traces.
53
+ In `src/main.ts`, the Express app object is created and configured to serve an "hello world" DBOS workflow on `/greetings/:user`. This file also hosts the code of said DBOS workflow: an `Hello` class with a single `helloTransaction` method.
55
54
 
56
- To add more functionality to this application, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
55
+
56
+ Then the `main()` function declares the code to start a DBOS instance and an Express application. When you pass the Express app object as parameter to `DBOS.launch()`, DBOS will wrap all routes with an [OpenTelemetry](https://opentelemetry.io/) tracing middleware and tie HTTP traces to DBOS workflow traces.
57
+
58
+ To add more functionality to this application, modify `src/main.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
57
59
 
58
60
  ## Running in DBOS Cloud
59
61
 
@@ -71,5 +73,5 @@ dbos-cloud app deploy
71
73
 
72
74
  ## Next Steps
73
75
 
74
- - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/getting-started/quickstart-programming).
75
- - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc/dbos-transact).
76
+ - For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
77
+ - To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc).
@@ -17,4 +17,4 @@ database:
17
17
  - npx knex migrate:rollback
18
18
  runtimeConfig:
19
19
  start:
20
- - dist/main.js
20
+ - node dist/main.js
@@ -1,5 +1,5 @@
1
1
  import { DBOS } from "@dbos-inc/dbos-sdk";
2
- import { app, dbos_hello, Hello } from "./operations";
2
+ import { app, dbos_hello, Hello } from "./main";
3
3
  import request from "supertest";
4
4
 
5
5
  describe("operations-test", () => {