@dbos-inc/create 1.31.8-preview → 1.31.12-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.
- package/package.json +1 -1
- package/templates/hello/README.md +9 -28
- package/templates/hello/package.json +1 -5
- package/templates/hello/src/operations.test.ts +7 -8
- package/templates/hello/src/operations.ts +11 -13
- package/templates/{hello-v2 → hello-contexts}/README.md +28 -7
- package/templates/{hello-v2 → hello-contexts}/package.json +5 -1
- package/templates/{hello-v2 → hello-contexts}/src/operations.test.ts +8 -7
- package/templates/{hello-v2 → hello-contexts}/src/operations.ts +13 -11
- package/templates/hello-drizzle/README.md +4 -4
- package/templates/hello-drizzle/package.json +2 -2
- package/templates/hello-drizzle/src/operations.test.ts +7 -8
- package/templates/hello-drizzle/src/operations.ts +7 -7
- package/templates/hello-express/README.md +3 -3
- package/templates/hello-nextjs/README.md +3 -3
- package/templates/hello-prisma/README.md +6 -6
- package/templates/hello-prisma/src/operations.test.ts +6 -6
- package/templates/hello-prisma/src/operations.ts +7 -7
- package/templates/hello-typeorm/README.md +6 -6
- package/templates/hello-typeorm/src/operations.test.ts +7 -6
- package/templates/hello-typeorm/src/operations.ts +7 -7
- /package/templates/{hello-v2 → hello-contexts}/.vscode/extensions.json +0 -0
- /package/templates/{hello-v2 → hello-contexts}/.vscode/launch.json +0 -0
- /package/templates/{hello-v2 → hello-contexts}/.vscode/tasks.json +0 -0
- /package/templates/{hello-v2 → hello-contexts}/dbos-config.yaml +0 -0
- /package/templates/{hello-v2 → hello-contexts}/eslint.config.js +0 -0
- /package/templates/{hello-v2 → hello-contexts}/gitignore.template +0 -0
- /package/templates/{hello-v2 → hello-contexts}/jest.config.js +0 -0
- /package/templates/{hello-v2 → hello-contexts}/knexfile.js +0 -0
- /package/templates/{hello-v2 → hello-contexts}/migrations/20240212161006_create_dbos_hello_tables.js +0 -0
- /package/templates/{hello-v2 → hello-contexts}/nodemon.json +0 -0
- /package/templates/{hello-v2 → hello-contexts}/start_postgres_docker.js +0 -0
- /package/templates/{hello-v2 → hello-contexts}/tsconfig.json +0 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
```
|
|
@@ -48,27 +47,9 @@ Finally, run the app:
|
|
|
48
47
|
npx dbos start
|
|
49
48
|
```
|
|
50
49
|
|
|
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
|
|
67
|
-
```
|
|
68
|
-
|
|
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
|
-
-
|
|
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
|
+
- 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 {
|
|
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
|
-
|
|
7
|
+
await DBOS.launch();
|
|
8
|
+
await DBOS.launchAppHTTPServer();
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
afterAll(async () => {
|
|
13
|
-
await
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
8
|
-
import {
|
|
6
|
+
// First, let's import DBOS
|
|
7
|
+
import { DBOS } from "@dbos-inc/dbos-sdk";
|
|
9
8
|
|
|
10
|
-
//
|
|
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
|
-
|
|
19
|
-
@
|
|
20
|
-
|
|
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
|
|
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
|
-
@
|
|
34
|
-
static async readme(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
```
|
|
@@ -47,9 +50,27 @@ Finally, run the app:
|
|
|
47
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
|
|
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 {
|
|
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
|
|
8
|
-
await DBOS.launchAppHTTPServer();
|
|
9
|
+
testRuntime = await createTestingRuntime();
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
afterAll(async () => {
|
|
12
|
-
await
|
|
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
|
|
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(
|
|
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
|
-
|
|
7
|
-
import {
|
|
7
|
+
import { HandlerContext, TransactionContext, Transaction, GetApi, ArgSource, ArgSources } from "@dbos-inc/dbos-sdk";
|
|
8
|
+
import { Knex } from "knex";
|
|
8
9
|
|
|
9
|
-
//
|
|
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
|
-
@
|
|
20
|
-
@
|
|
21
|
-
|
|
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 } =
|
|
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
|
-
@
|
|
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
|
|
|
@@ -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/
|
|
47
|
-
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/
|
|
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
|
|
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.
|
|
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.
|
|
26
|
+
"drizzle-orm": "^0.38.3"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
7
|
+
await DBOS.launch();
|
|
8
|
+
await DBOS.launchAppHTTPServer();
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
afterAll(async () => {
|
|
13
|
-
await
|
|
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
|
|
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
|
|
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(
|
|
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 {
|
|
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
|
-
@
|
|
14
|
-
@
|
|
15
|
-
static async helloTransaction(
|
|
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
|
|
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
|
-
@
|
|
24
|
-
static async readme(
|
|
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
|
|
|
@@ -73,5 +73,5 @@ dbos-cloud app deploy
|
|
|
73
73
|
|
|
74
74
|
## Next Steps
|
|
75
75
|
|
|
76
|
-
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/
|
|
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
|
|
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).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DBOS Background Job
|
|
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
|
|
|
@@ -96,5 +96,5 @@ dbos-cloud app deploy
|
|
|
96
96
|
|
|
97
97
|
## Next Steps
|
|
98
98
|
|
|
99
|
-
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/
|
|
100
|
-
- To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc
|
|
99
|
+
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
|
|
100
|
+
- 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,6 +1,6 @@
|
|
|
1
1
|
# DBOS Hello with Prisma
|
|
2
2
|
|
|
3
|
-
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Prisma](https://docs.dbos.dev/tutorials/using-prisma).
|
|
3
|
+
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [Prisma](https://docs.dbos.dev/typescript/tutorials/orms/using-prisma).
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ npm run build
|
|
|
22
22
|
|
|
23
23
|
Then, run a schema migration to create some tables.
|
|
24
24
|
Prisma provides rich support for [schema migrations](https://www.prisma.io/docs/orm/prisma-migrate), including automatic generation of migration files from Prisma schema.
|
|
25
|
-
Fore more information, see [our docs](https://docs.dbos.dev/tutorials/using-prisma).
|
|
25
|
+
Fore more information, see [our docs](https://docs.dbos.dev/typescript/tutorials/orms/using-prisma).
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
npx dbos migrate
|
|
@@ -44,8 +44,8 @@ Congratulations! You just launched a DBOS application.
|
|
|
44
44
|
|
|
45
45
|
## Next Steps
|
|
46
46
|
|
|
47
|
-
- For more information on using Prisma with DBOS, check out [our docs](https://docs.dbos.dev/tutorials/using-prisma).
|
|
47
|
+
- For more information on using Prisma with DBOS, check out [our docs](https://docs.dbos.dev/typescript/tutorials/orms/using-prisma).
|
|
48
48
|
- 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`.
|
|
49
|
-
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/
|
|
50
|
-
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/
|
|
51
|
-
- To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc
|
|
49
|
+
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
|
|
50
|
+
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/quickstart/)
|
|
51
|
+
- 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,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
7
|
+
await DBOS.launch();
|
|
8
|
+
await DBOS.launchAppHTTPServer();
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
afterAll(async () => {
|
|
13
|
-
await
|
|
12
|
+
await DBOS.shutdown();
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Test the HTTP endpoint.
|
|
18
17
|
*/
|
|
19
18
|
test("test-greet", async () => {
|
|
20
|
-
const res = await request(
|
|
19
|
+
const res = await request(DBOS.getHTTPHandlersCallback()!).get(
|
|
21
20
|
"/greeting/dbos"
|
|
22
21
|
);
|
|
23
22
|
expect(res.statusCode).toBe(200);
|
|
24
23
|
expect(res.text).toMatch("Greeting 1: Hello, dbos!");
|
|
24
|
+
expect (await Hello.helloTransaction('bob')).toMatch("Greeting 2: Hello, bob!");
|
|
25
25
|
});
|
|
26
26
|
});
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
// This is the Quickstart Prisma template app. It greets visitors, counting how many total greetings were made.
|
|
4
4
|
// To learn how to run this app, visit the Prisma tutorial: https://docs.dbos.dev/tutorials/using-prisma
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { DBOS } from '@dbos-inc/dbos-sdk';
|
|
7
7
|
|
|
8
8
|
import { PrismaClient } from "@prisma/client";
|
|
9
9
|
|
|
10
10
|
export class Hello {
|
|
11
11
|
|
|
12
12
|
// Serve this function from HTTP GET requests at the /greeting endpoint with 'name' as a path parameter
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
static async helloTransaction(
|
|
13
|
+
@DBOS.getApi('/greeting/:name')
|
|
14
|
+
@DBOS.transaction()
|
|
15
|
+
static async helloTransaction(name: string) {
|
|
16
16
|
const greeting = `Hello, ${name}!`;
|
|
17
|
-
const res = await
|
|
17
|
+
const res = await (DBOS.prismaClient as PrismaClient).dbosHello.create({
|
|
18
18
|
data: {
|
|
19
19
|
greeting: greeting,
|
|
20
20
|
},
|
|
@@ -24,8 +24,8 @@ export class Hello {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Serve a quick readme for the app at the / endpoint
|
|
27
|
-
@
|
|
28
|
-
static async readme(
|
|
27
|
+
@DBOS.getApi('/')
|
|
28
|
+
static async readme() {
|
|
29
29
|
const message = Hello.makeHTML(
|
|
30
30
|
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
31
31
|
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 TypeORM
|
|
2
2
|
|
|
3
|
-
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [TypeORM](https://docs.dbos.dev/tutorials/using-typeorm).
|
|
3
|
+
This is a [DBOS app](https://docs.dbos.dev/) bootstrapped with `npx @dbos-inc/create` and using [TypeORM](https://docs.dbos.dev/typescript/tutorials/orms/using-typeorm).
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ npm run build
|
|
|
22
22
|
|
|
23
23
|
Then, run a schema migration to create some tables.
|
|
24
24
|
TypeORM provides rich support for [schema migrations](https://typeorm.io/migrations), including automatic generation of migration files from entity files.
|
|
25
|
-
Fore more information, see [our docs](https://docs.dbos.dev/tutorials/using-typeorm).
|
|
25
|
+
Fore more information, see [our docs](https://docs.dbos.dev/typescript/tutorials/orms/using-typeorm).
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
npx dbos migrate
|
|
@@ -44,8 +44,8 @@ Congratulations! You just launched a DBOS application.
|
|
|
44
44
|
|
|
45
45
|
## Next Steps
|
|
46
46
|
|
|
47
|
-
- For more information on using TypeORM with DBOS, check out [our docs](https://docs.dbos.dev/tutorials/using-typeorm).
|
|
47
|
+
- For more information on using TypeORM with DBOS, check out [our docs](https://docs.dbos.dev/typescript/tutorials/orms/using-typeorm).
|
|
48
48
|
- 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`.
|
|
49
|
-
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/
|
|
50
|
-
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/
|
|
51
|
-
- To learn more about DBOS, take a look at [our documentation](https://docs.dbos.dev/) or our [source code](https://github.com/dbos-inc
|
|
49
|
+
- For a detailed tutorial, check out our [programming quickstart](https://docs.dbos.dev/typescript/programming-guide).
|
|
50
|
+
- To learn how to deploy your application to DBOS Cloud, visit our [cloud quickstart](https://docs.dbos.dev/quickstart)
|
|
51
|
+
- 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,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
7
|
+
await DBOS.launch();
|
|
8
|
+
await DBOS.launchAppHTTPServer();
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
afterAll(async () => {
|
|
13
|
-
await
|
|
12
|
+
await DBOS.shutdown();
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Test the HTTP endpoint.
|
|
18
17
|
*/
|
|
19
18
|
test("test-greet", async () => {
|
|
20
|
-
const res = await request(
|
|
19
|
+
const res = await request(DBOS.getHTTPHandlersCallback()!).get(
|
|
21
20
|
"/greeting/dbos"
|
|
22
21
|
);
|
|
23
22
|
expect(res.statusCode).toBe(200);
|
|
24
23
|
expect(res.text).toMatch("Greeting 1: Hello, dbos!");
|
|
24
|
+
|
|
25
|
+
expect(await Hello.helloTransaction('bob')).toMatch("Greeting 2: Hello, bob!");
|
|
25
26
|
});
|
|
26
27
|
});
|
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
// This is the Quickstart TypeORM template app. It greets visitors, counting how many total greetings were made.
|
|
4
4
|
// To learn how to run this app, visit the TypeORM tutorial: https://docs.dbos.dev/tutorials/using-typeorm
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { DBOS, OrmEntities } from '@dbos-inc/dbos-sdk';
|
|
7
7
|
import { EntityManager } from "typeorm";
|
|
8
8
|
import { DBOSHello } from '../entities/DBOSHello';
|
|
9
9
|
|
|
10
10
|
@OrmEntities([DBOSHello])
|
|
11
11
|
export class Hello {
|
|
12
12
|
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
static async helloTransaction(
|
|
13
|
+
@DBOS.getApi('/greeting/:name')
|
|
14
|
+
@DBOS.transaction()
|
|
15
|
+
static async helloTransaction(name: string) {
|
|
16
16
|
const greeting = `Hello, ${name}!`;
|
|
17
17
|
let entity = new DBOSHello();
|
|
18
18
|
entity.greeting = greeting;
|
|
19
|
-
entity = await
|
|
19
|
+
entity = await (DBOS.typeORMClient as EntityManager).save(entity);
|
|
20
20
|
const greeting_note = `Greeting ${entity.greeting_id}: ${greeting}`;
|
|
21
21
|
return Hello.makeHTML(greeting_note);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Serve a quick readme for the app at the / endpoint
|
|
25
|
-
@
|
|
26
|
-
static async readme(
|
|
25
|
+
@DBOS.getApi('/')
|
|
26
|
+
static async readme() {
|
|
27
27
|
const message = Hello.makeHTML(
|
|
28
28
|
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
29
29
|
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>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{hello-v2 → hello-contexts}/migrations/20240212161006_create_dbos_hello_tables.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|