@dbos-inc/create 1.31.24-preview → 1.31.26-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 (142) hide show
  1. package/dist/cli.js +3 -4
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +1 -1
  4. package/templates/dbos-drizzle/README.md +23 -0
  5. package/templates/dbos-drizzle/nodemon.json +7 -0
  6. package/templates/{hello-drizzle → dbos-drizzle}/package.json +1 -1
  7. package/templates/dbos-knex/README.md +23 -0
  8. package/templates/dbos-knex/nodemon.json +7 -0
  9. package/templates/{hello-contexts → dbos-knex}/package.json +3 -3
  10. package/templates/dbos-knex/src/main.ts +94 -0
  11. package/templates/dbos-prisma/README.md +23 -0
  12. package/templates/{hello-prisma → dbos-prisma}/nodemon.json +1 -1
  13. package/templates/{hello-prisma → dbos-prisma}/package.json +1 -1
  14. package/templates/{hello-express → dbos-prisma}/start_postgres_docker.js +0 -0
  15. package/templates/dbos-typeorm/README.md +23 -0
  16. package/templates/dbos-typeorm/nodemon.json +8 -0
  17. package/templates/{hello-typeorm → dbos-typeorm}/package.json +1 -1
  18. package/templates/{hello-nextjs → dbos-typeorm}/start_postgres_docker.js +0 -0
  19. package/templates/hello/.vscode/extensions.json +0 -7
  20. package/templates/hello/.vscode/launch.json +0 -21
  21. package/templates/hello/.vscode/tasks.json +0 -19
  22. package/templates/hello/README.md +0 -55
  23. package/templates/hello/dbos-config.yaml +0 -20
  24. package/templates/hello/eslint.config.js +0 -28
  25. package/templates/hello/gitignore.template +0 -144
  26. package/templates/hello/jest.config.js +0 -8
  27. package/templates/hello/knexfile.js +0 -20
  28. package/templates/hello/migrations/20240212161006_create_dbos_hello_tables.js +0 -18
  29. package/templates/hello/nodemon.json +0 -7
  30. package/templates/hello/package.json +0 -23
  31. package/templates/hello/src/operations.test.ts +0 -37
  32. package/templates/hello/src/operations.ts +0 -64
  33. package/templates/hello/start_postgres_docker.js +0 -40
  34. package/templates/hello/tsconfig.json +0 -25
  35. package/templates/hello-contexts/.vscode/extensions.json +0 -7
  36. package/templates/hello-contexts/.vscode/launch.json +0 -21
  37. package/templates/hello-contexts/.vscode/tasks.json +0 -19
  38. package/templates/hello-contexts/README.md +0 -76
  39. package/templates/hello-contexts/dbos-config.yaml +0 -20
  40. package/templates/hello-contexts/nodemon.json +0 -7
  41. package/templates/hello-contexts/src/operations.test.ts +0 -38
  42. package/templates/hello-contexts/src/operations.ts +0 -66
  43. package/templates/hello-drizzle/.vscode/extensions.json +0 -7
  44. package/templates/hello-drizzle/.vscode/launch.json +0 -21
  45. package/templates/hello-drizzle/.vscode/tasks.json +0 -19
  46. package/templates/hello-drizzle/README.md +0 -48
  47. package/templates/hello-drizzle/nodemon.json +0 -7
  48. package/templates/hello-express/README.md +0 -77
  49. package/templates/hello-express/knexfile.js +0 -20
  50. package/templates/hello-express/migrations/20240212161006_create_dbos_hello_tables.js +0 -18
  51. package/templates/hello-express/nodemon.json +0 -7
  52. package/templates/hello-express/package.json +0 -24
  53. package/templates/hello-express/src/main.ts +0 -99
  54. package/templates/hello-express/tsconfig.json +0 -25
  55. package/templates/hello-nextjs/README.md +0 -100
  56. package/templates/hello-nextjs/dbos-config.yaml +0 -18
  57. package/templates/hello-nextjs/eslint.config.mjs +0 -16
  58. package/templates/hello-nextjs/gitignore.template +0 -41
  59. package/templates/hello-nextjs/knexfile.js +0 -20
  60. package/templates/hello-nextjs/migrations/20240212161006_create_dbos_hello_tables.js +0 -18
  61. package/templates/hello-nextjs/next.config.ts +0 -18
  62. package/templates/hello-nextjs/package.json +0 -32
  63. package/templates/hello-nextjs/postcss.config.mjs +0 -8
  64. package/templates/hello-nextjs/public/file.svg +0 -1
  65. package/templates/hello-nextjs/public/globe.svg +0 -1
  66. package/templates/hello-nextjs/public/next.svg +0 -1
  67. package/templates/hello-nextjs/public/vercel.svg +0 -1
  68. package/templates/hello-nextjs/public/window.svg +0 -1
  69. package/templates/hello-nextjs/src/actions/dbosWorkflow.ts +0 -12
  70. package/templates/hello-nextjs/src/actions/hello.ts +0 -15
  71. package/templates/hello-nextjs/src/app/crash/route.ts +0 -8
  72. package/templates/hello-nextjs/src/app/favicon.ico +0 -0
  73. package/templates/hello-nextjs/src/app/globals.css +0 -21
  74. package/templates/hello-nextjs/src/app/greetings/route.ts +0 -11
  75. package/templates/hello-nextjs/src/app/layout.tsx +0 -34
  76. package/templates/hello-nextjs/src/app/page.tsx +0 -73
  77. package/templates/hello-nextjs/src/app/step/[slug]/route.ts +0 -15
  78. package/templates/hello-nextjs/src/app/tasks/[slug]/route.ts +0 -18
  79. package/templates/hello-nextjs/src/components/client/BackGroundTask.tsx +0 -179
  80. package/templates/hello-nextjs/src/components/client/callDBOSWorkflow.tsx +0 -31
  81. package/templates/hello-nextjs/src/dbos/background.ts +0 -23
  82. package/templates/hello-nextjs/src/dbos/hello.ts +0 -24
  83. package/templates/hello-nextjs/src/dbos/operations.ts +0 -9
  84. package/templates/hello-nextjs/tailwind.config.ts +0 -18
  85. package/templates/hello-nextjs/tsconfig.json +0 -29
  86. package/templates/hello-prisma/.vscode/extensions.json +0 -7
  87. package/templates/hello-prisma/.vscode/launch.json +0 -21
  88. package/templates/hello-prisma/.vscode/tasks.json +0 -19
  89. package/templates/hello-prisma/README.md +0 -51
  90. package/templates/hello-prisma/start_postgres_docker.js +0 -40
  91. package/templates/hello-typeorm/.vscode/extensions.json +0 -7
  92. package/templates/hello-typeorm/.vscode/launch.json +0 -21
  93. package/templates/hello-typeorm/.vscode/tasks.json +0 -19
  94. package/templates/hello-typeorm/README.md +0 -51
  95. package/templates/hello-typeorm/eslint.config.js +0 -28
  96. package/templates/hello-typeorm/gitignore.template +0 -144
  97. package/templates/hello-typeorm/jest.config.js +0 -8
  98. package/templates/hello-typeorm/nodemon.json +0 -8
  99. package/templates/hello-typeorm/start_postgres_docker.js +0 -40
  100. /package/templates/{hello-drizzle → dbos-drizzle}/dbos-config.yaml +0 -0
  101. /package/templates/{hello-drizzle → dbos-drizzle}/drizzle/0000_hello.sql +0 -0
  102. /package/templates/{hello-drizzle → dbos-drizzle}/drizzle/meta/0000_snapshot.json +0 -0
  103. /package/templates/{hello-drizzle → dbos-drizzle}/drizzle/meta/_journal.json +0 -0
  104. /package/templates/{hello-drizzle → dbos-drizzle}/drizzle.config.ts +0 -0
  105. /package/templates/{hello-contexts → dbos-drizzle}/eslint.config.js +0 -0
  106. /package/templates/{hello-contexts → dbos-drizzle}/gitignore.template +0 -0
  107. /package/templates/{hello-contexts → dbos-drizzle}/jest.config.js +0 -0
  108. /package/templates/{hello-drizzle → dbos-drizzle}/src/operations.test.ts +0 -0
  109. /package/templates/{hello-drizzle → dbos-drizzle}/src/operations.ts +0 -0
  110. /package/templates/{hello-drizzle → dbos-drizzle}/src/schema.ts +0 -0
  111. /package/templates/{hello-contexts → dbos-drizzle}/start_postgres_docker.js +0 -0
  112. /package/templates/{hello-contexts → dbos-drizzle}/tsconfig.json +0 -0
  113. /package/templates/{hello-express → dbos-knex}/dbos-config.yaml +0 -0
  114. /package/templates/{hello-drizzle → dbos-knex}/eslint.config.js +0 -0
  115. /package/templates/{hello-drizzle → dbos-knex}/gitignore.template +0 -0
  116. /package/templates/{hello-drizzle → dbos-knex}/jest.config.js +0 -0
  117. /package/templates/{hello-contexts → dbos-knex}/knexfile.js +0 -0
  118. /package/templates/{hello-contexts → dbos-knex}/migrations/20240212161006_create_dbos_hello_tables.js +0 -0
  119. /package/templates/{hello-express → dbos-knex}/src/main.test.ts +0 -0
  120. /package/templates/{hello-drizzle → dbos-knex}/start_postgres_docker.js +0 -0
  121. /package/templates/{hello-drizzle → dbos-knex}/tsconfig.json +0 -0
  122. /package/templates/{hello-prisma → dbos-prisma}/dbos-config.yaml +0 -0
  123. /package/templates/{hello-express → dbos-prisma}/eslint.config.js +0 -0
  124. /package/templates/{hello-prisma → dbos-prisma}/generate_env.js +0 -0
  125. /package/templates/{hello-prisma → dbos-prisma}/gitignore.template +0 -0
  126. /package/templates/{hello-express → dbos-prisma}/jest.config.js +0 -0
  127. /package/templates/{hello-prisma → dbos-prisma}/prisma/migrations/20240604184654_init/migration.sql +0 -0
  128. /package/templates/{hello-prisma → dbos-prisma}/prisma/migrations/migration_lock.toml +0 -0
  129. /package/templates/{hello-prisma → dbos-prisma}/prisma/schema.prisma +0 -0
  130. /package/templates/{hello-prisma → dbos-prisma}/src/operations.test.ts +0 -0
  131. /package/templates/{hello-prisma → dbos-prisma}/src/operations.ts +0 -0
  132. /package/templates/{hello-prisma → dbos-prisma}/tsconfig.json +0 -0
  133. /package/templates/{hello-typeorm → dbos-typeorm}/datasource.ts +0 -0
  134. /package/templates/{hello-typeorm → dbos-typeorm}/dbos-config.yaml +0 -0
  135. /package/templates/{hello-typeorm → dbos-typeorm}/entities/DBOSHello.ts +0 -0
  136. /package/templates/{hello-prisma → dbos-typeorm}/eslint.config.js +0 -0
  137. /package/templates/{hello-express → dbos-typeorm}/gitignore.template +0 -0
  138. /package/templates/{hello-prisma → dbos-typeorm}/jest.config.js +0 -0
  139. /package/templates/{hello-typeorm → dbos-typeorm}/migrations/1714934318136-DBOSHello.ts +0 -0
  140. /package/templates/{hello-typeorm → dbos-typeorm}/src/operations.test.ts +0 -0
  141. /package/templates/{hello-typeorm → dbos-typeorm}/src/operations.ts +0 -0
  142. /package/templates/{hello-typeorm → dbos-typeorm}/tsconfig.json +0 -0
@@ -1,77 +0,0 @@
1
- # DBOS Hello
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/typescript/tutorials/orms/using-knex) to interact with postgres.
4
-
5
- ## Getting Started
6
-
7
- Before you can launch your app, you need a database.
8
- DBOS works with any Postgres database, but to make things easier, we've provided a script that starts a Docker Postgres container and creates a database.
9
- Run:
10
-
11
- ```bash
12
- node start_postgres_docker.js
13
- ```
14
-
15
- If successful, the script should print `Database started successfully!`.
16
-
17
- Next, you can build and run the app in one step under `nodemon`:
18
-
19
- ```bash
20
- npm run dev
21
- ```
22
-
23
- To see that it's working, visit this URL in your browser: [`http://localhost:3000/greeting/dbos`](http://localhost:3000/greeting/dbos).
24
- You should get this message: `Hello, dbos! You have been greeted 1 times.`
25
- Each time you refresh the page, the counter should go up by one!
26
-
27
- Congratulations! You just launched a DBOS application.
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.
32
-
33
- ```bash
34
- npm run build
35
- ```
36
-
37
- Then, run a schema migration to create some tables:
38
-
39
- ```bash
40
- npx dbos migrate
41
- ```
42
-
43
- If successful, the migration should print `Migration successful!`.
44
-
45
- Finally, run the app:
46
-
47
- ```bash
48
- npx dbos start
49
- ```
50
-
51
- ## The application
52
-
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.
54
-
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.
59
-
60
- ## Running in DBOS Cloud
61
-
62
- To deploy this app to DBOS Cloud, first install the DBOS Cloud CLI (example with [npm](https://www.npmjs.com/)):
63
-
64
- ```shell
65
- npm i -g @dbos-inc/dbos-cloud
66
- ```
67
-
68
- Then, run this command to deploy your app:
69
-
70
- ```shell
71
- dbos-cloud app deploy
72
- ```
73
-
74
- ## Next Steps
75
-
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,20 +0,0 @@
1
- const { parseConfigFile } = require('@dbos-inc/dbos-sdk');
2
-
3
- const [dbosConfig, ] = parseConfigFile();
4
-
5
- const config = {
6
- client: 'pg',
7
- connection: {
8
- host: dbosConfig.poolConfig.host,
9
- port: dbosConfig.poolConfig.port,
10
- user: dbosConfig.poolConfig.user,
11
- password: dbosConfig.poolConfig.password,
12
- database: dbosConfig.poolConfig.database,
13
- ssl: dbosConfig.poolConfig.ssl,
14
- },
15
- migrations: {
16
- directory: './migrations'
17
- }
18
- };
19
-
20
- module.exports = config;
@@ -1,18 +0,0 @@
1
- const { Knex } = require("knex");
2
-
3
- exports.up = async function(knex) {
4
- await knex.schema.createTable('dbos_hello', table => {
5
- table.text('name').primary();
6
- table.integer('greet_count').defaultTo(0);
7
- });
8
-
9
- return knex.schema.createTable('dbos_greetings', table => {
10
- table.text('greeting_name');
11
- table.text('greeting_note_content');
12
- });
13
- };
14
-
15
- exports.down = async function(knex) {
16
- await knex.schema.dropTable('dbos_greetings');
17
- return knex.schema.dropTable('dbos_hello');
18
- };
@@ -1,7 +0,0 @@
1
- {
2
- "watch": ["src/","migrations/"],
3
- "ext": "ts,json",
4
- "ignore": ["src/**/*.test.ts"],
5
- "exec": "npm run build && npx dbos migrate && node dist/main.js"
6
- }
7
-
@@ -1,24 +0,0 @@
1
- {
2
- "name": "dbos-hello-express",
3
- "version": "0.0.1",
4
- "scripts": {
5
- "build": "tsc",
6
- "test": "npx dbos rollback && npx dbos migrate && jest",
7
- "dev": "nodemon",
8
- "start": "npx dbos start"
9
- },
10
- "devDependencies": {
11
- "@types/jest": "^29.5.12",
12
- "@types/supertest": "^2.0.16",
13
- "jest": "^29.7.0",
14
- "nodemon": "^3.1.0",
15
- "supertest": "^7.0.0",
16
- "ts-jest": "^29.1.2",
17
- "typescript": "^5.4.5"
18
- },
19
- "dependencies": {
20
- "@dbos-inc/dbos-sdk": "file:../../../..",
21
- "express": "^4.21.1",
22
- "knex": "3.1.0"
23
- }
24
- }
@@ -1,99 +0,0 @@
1
- // Welcome to DBOS!
2
-
3
- // This is a sample "Hello" app built with DBOS, Express.js, and Knex.
4
- // It greets visitors and keeps track of how many times each visitor has been greeted.
5
-
6
- // First let's import express and DBOS
7
- import express from "express";
8
- import { DBOS } from "@dbos-inc/dbos-sdk";
9
-
10
- // Then, let's declare a type representing the "dbos_hello" database table
11
- export interface dbos_hello {
12
- name: string;
13
- greet_count: number;
14
- }
15
-
16
- // Now let's define a class with some static functions.
17
- // DBOS uses TypeScript decorators to automatically make your functions reliable, so they need to be static.
18
- export class Hello {
19
- // This function greets a user and increments the greet count in the database.
20
- // The @DBOS.transaction() decorator ensures that this function runs as a database transaction.
21
- @DBOS.transaction()
22
- static async helloTransaction(user: string) {
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[] };
25
- const greet_count = rows[0].greet_count;
26
- const greeting = `Hello, ${user}! You have been greeted ${greet_count} times.`;
27
- return Hello.makeHTML(greeting);
28
- }
29
-
30
- // Finally, we will declare helper functions to serve static HTML to user.s
31
-
32
- static async readme() {
33
- const message = Hello.makeHTML(
34
- `Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
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>
36
- The counter increments with each page visit.`
37
- );
38
- return Promise.resolve(message);
39
- }
40
-
41
- // A helper function to create HTML pages with some styling
42
- static makeHTML(message: string) {
43
- const page = `
44
- <!DOCTYPE html>
45
- <html lang="en">
46
- <head>
47
- <title>DBOS Template App</title>
48
- <script src="https://cdn.tailwindcss.com"></script>
49
- </head>
50
- <body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
51
- <h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
52
- <p class="mt-8 mb-8">` + message + `</p>
53
- <p class="mb-2">
54
- To learn how to run this app yourself, visit our
55
- <a href="https://docs.dbos.dev/quickstart?language=typescript" class="text-blue-600 hover:underline">Quickstart</a>.
56
- </p><p class="mb-2">
57
- Then, to learn how to build crashproof apps, continue to our
58
- <a href="https://docs.dbos.dev/typescript/programming-guide" class="text-blue-600 hover:underline">Programming Guide</a>.<br>
59
- </p>
60
- </body>
61
- </html>`;
62
- return page;
63
- }
64
- }
65
-
66
- // Now, let's create an Express app and define some routes.
67
- export const app = express();
68
- // Parse JSON payloads and make it available to req.body
69
- app.use(express.json());
70
-
71
- // We'll serve the README at the root of the app
72
- app.get("/", async (_, res) => {
73
- res.send(await Hello.readme());
74
- });
75
-
76
- // Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
77
- // The handler will in turn call a reliable DBOS operation (helloTransaction) to greet the user
78
- app.get("/greeting/:user", async (req, res) => {
79
- const { user } = req.params;
80
- res.send(await Hello.helloTransaction(user));
81
- });
82
-
83
- // Finally, let's start the server
84
- async function main() {
85
- await DBOS.launch({expressApp: app});
86
-
87
- const PORT = DBOS.runtimeConfig?.port ?? 3000;
88
- const ENV = process.env.NODE_ENV || 'development';
89
-
90
- app.listen(PORT, () => {
91
- console.log(`🚀 Server is running on http://localhost:${PORT}`);
92
- console.log(`🌟 Environment: ${ENV}`);
93
- });
94
- }
95
-
96
- // Only start the server when this file is run directly from Node
97
- if (require.main === module) {
98
- main().catch(console.log);
99
- }
@@ -1,25 +0,0 @@
1
- /* Visit https://aka.ms/tsconfig to read more about this file */
2
- {
3
- "compilerOptions": {
4
- "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
5
- "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
6
- "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
7
- "module": "Node16", /* Specify what module code is generated. */
8
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
9
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
10
- "sourceMap": true, /* Create source map files for emitted JavaScript files. */
11
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
12
- "newLine": "lf", /* Set the newline character for emitting files. */
13
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
14
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
15
- "strict": true, /* Enable all strict type-checking options. */
16
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
17
- },
18
- "include": [ /* Specifies an array of filenames or patterns to include in the program. */
19
- "src"
20
- ],
21
- "exclude": [
22
- "**/*.test.ts",
23
- "dist"
24
- ]
25
- }
@@ -1,100 +0,0 @@
1
- # DBOS Background Job
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/typescript/tutorials/orms/using-knex) to interact with postgres.
4
-
5
- ## Getting Started
6
-
7
- Before you can launch your app, you need a database.
8
- DBOS works with any Postgres database, but to make things easier, we've provided a script that starts a Docker Postgres container and creates a database.
9
- Run:
10
-
11
- ```bash
12
- node start_postgres_docker.js
13
- ```
14
-
15
- If successful, the script should print `Database started successfully!`.
16
-
17
- ```
18
-
19
- ## Production build
20
-
21
- In production, instead of using `nodemon`, the following separate steps should be used to build, run database setup, and start the app.
22
-
23
- ```bash
24
- npm run build
25
- ```
26
-
27
- Then, run a schema migration to create some tables:
28
-
29
- ```bash
30
- npx dbos migrate
31
- ```
32
-
33
- If successful, the migration should print `Migration successful!`.
34
-
35
- Finally, run the app:
36
-
37
- ```bash
38
- npm run start
39
- ```
40
-
41
- To see that it's working, visit this URL in your browser: [`http://localhost:3000/`](http://localhost:3000/).
42
-
43
- Click on the "Start Background Job" button.
44
-
45
- You should this message: `Your background task has completed step 0 of 9.`
46
- As the background job completes steps, the step counter should go up by one!
47
-
48
- Click on "Crash the application" button.
49
-
50
- The step counter stops increasing.
51
- On the command line, you will see that the application has stopped.
52
- Start the application again.
53
- ```bash
54
- npm run start
55
- ```
56
- In the browser, you will see that the execution of steps resumes where it left off and eventually completes.
57
-
58
- Congratulations! You just run a DBOS application.
59
-
60
- ## The application
61
-
62
- - In `src/action/dbosWorkflow.tsx`, the DBOS workflow is created. When called, it increments a counter in the database and returns a greeting.
63
-
64
- - The code below in the same file, launches the dbos runtime. This is required for DBOS runtime to start. Do not remove the code
65
- ```
66
- if (process.env.NEXT_PHASE !== "phase-production-build") {
67
- await DBOS.launch();
68
- }
69
- ```
70
- - The workflow for the background job is called by the called the GET method in app/tasks/route.ts.
71
-
72
- - The GET is called by the component in src/components/BackGroundTask.tsx. It calls the route /tasks.
73
-
74
- - The component is called from the main UI page.tsx.
75
-
76
- - This is how the DBOS workflow is wired to the NextJs application.
77
-
78
-
79
- DBOS will wrap all routes with an [OpenTelemetry](https://opentelemetry.io/) tracing middleware and tie HTTP traces to DBOS workflow traces.
80
-
81
- To add more functionality to this application, modify `src/operations.ts`. If you used `npm run dev`, it will automatically rebuild and restart.
82
-
83
- ## Running in DBOS Cloud
84
-
85
- To deploy this app to DBOS Cloud, first install the DBOS Cloud CLI (example with [npm](https://www.npmjs.com/)):
86
-
87
- ```shell
88
- npm i -g @dbos-inc/dbos-cloud
89
- ```
90
-
91
- Then, run this command to deploy your app:
92
-
93
- ```shell
94
- dbos-cloud app deploy
95
- ```
96
-
97
- ## Next Steps
98
-
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,18 +0,0 @@
1
- # To enable auto-completion and validation for this file in VSCode, install the RedHat YAML extension
2
- # https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
3
-
4
- # yaml-language-server: $schema=https://raw.githubusercontent.com/dbos-inc/dbos-transact/main/dbos-config.schema.json
5
-
6
- language: node
7
- database:
8
- hostname: localhost
9
- port: 5432
10
- username: postgres
11
- password: ${PGPASSWORD}
12
- connectionTimeoutMillis: 3000
13
- app_db_client: knex
14
- migrate:
15
- - npx knex migrate:latest
16
- runtimeConfig:
17
- start:
18
- - "npm run start"
@@ -1,16 +0,0 @@
1
- import { dirname } from "path";
2
- import { fileURLToPath } from "url";
3
- import { FlatCompat } from "@eslint/eslintrc";
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = dirname(__filename);
7
-
8
- const compat = new FlatCompat({
9
- baseDirectory: __dirname,
10
- });
11
-
12
- const eslintConfig = [
13
- ...compat.extends("next/core-web-vitals", "next/typescript"),
14
- ];
15
-
16
- export default eslintConfig;
@@ -1,41 +0,0 @@
1
- # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
-
3
- # dependencies
4
- /node_modules
5
- /.pnp
6
- .pnp.*
7
- .yarn/*
8
- !.yarn/patches
9
- !.yarn/plugins
10
- !.yarn/releases
11
- !.yarn/versions
12
-
13
- # testing
14
- /coverage
15
-
16
- # next.js
17
- /.next/
18
- /out/
19
-
20
- # production
21
- /build
22
-
23
- # misc
24
- .DS_Store
25
- *.pem
26
-
27
- # debug
28
- npm-debug.log*
29
- yarn-debug.log*
30
- yarn-error.log*
31
- .pnpm-debug.log*
32
-
33
- # env files (can opt-in for committing if needed)
34
- .env*
35
-
36
- # vercel
37
- .vercel
38
-
39
- # typescript
40
- *.tsbuildinfo
41
- next-env.d.ts
@@ -1,20 +0,0 @@
1
- const { parseConfigFile } = require('@dbos-inc/dbos-sdk');
2
-
3
- const [dbosConfig, ] = parseConfigFile();
4
-
5
- const config = {
6
- client: 'pg',
7
- connection: {
8
- host: dbosConfig.poolConfig.host,
9
- port: dbosConfig.poolConfig.port,
10
- user: dbosConfig.poolConfig.user,
11
- password: dbosConfig.poolConfig.password,
12
- database: dbosConfig.poolConfig.database,
13
- ssl: dbosConfig.poolConfig.ssl,
14
- },
15
- migrations: {
16
- directory: './migrations'
17
- }
18
- };
19
-
20
- module.exports = config;
@@ -1,18 +0,0 @@
1
- const { Knex } = require("knex");
2
-
3
- exports.up = async function(knex) {
4
- await knex.schema.createTable('dbos_hello', table => {
5
- table.text('name').primary();
6
- table.integer('greet_count').defaultTo(0);
7
- });
8
-
9
- return knex.schema.createTable('dbos_greetings', table => {
10
- table.text('greeting_name');
11
- table.text('greeting_note_content');
12
- });
13
- };
14
-
15
- exports.down = async function(knex) {
16
- await knex.schema.dropTable('dbos_greetings');
17
- return knex.schema.dropTable('dbos_hello');
18
- };
@@ -1,18 +0,0 @@
1
- import type { NextConfig } from "next";
2
-
3
- const nextConfig: NextConfig = {
4
- /* config options here */
5
- webpack: (config) => {
6
- // Treat @dbos-inc/dbos-sdk as an external package for client builds
7
- config.externals = [
8
- ...config.externals,
9
- {
10
- "@dbos-inc/dbos-sdk": "commonjs @dbos-inc/dbos-sdk",
11
- },
12
- ];
13
-
14
- return config;
15
- },
16
- };
17
-
18
- export default nextConfig;
@@ -1,32 +0,0 @@
1
- {
2
- "name": "hello-nextjs",
3
- "version": "0.1.0",
4
- "private": true,
5
- "scripts": {
6
- "dev": "next dev",
7
- "build": "next build",
8
- "start": "next start",
9
- "lint": "next lint"
10
- },
11
- "dependencies": {
12
- "@dbos-inc/dbos-sdk": "^1.31.17-preview",
13
- "next": "15.0.3",
14
- "react": "19.0.0-rc-66855b96-20241106",
15
- "react-dom": "19.0.0-rc-66855b96-20241106",
16
- "typeorm": "^0.3.20",
17
- "webpack": "^5.96.1"
18
- },
19
- "devDependencies": {
20
- "@babel/cli": "^7.25.9",
21
- "@babel/core": "^7.26.0",
22
- "@babel/preset-env": "^7.26.0",
23
- "@types/node": "^20",
24
- "@types/react": "^18",
25
- "@types/react-dom": "^18",
26
- "eslint": "^8",
27
- "eslint-config-next": "15.0.3",
28
- "postcss": "^8",
29
- "tailwindcss": "^3.4.1",
30
- "typescript": "^5"
31
- }
32
- }
@@ -1,8 +0,0 @@
1
- /** @type {import('postcss-load-config').Config} */
2
- const config = {
3
- plugins: {
4
- tailwindcss: {},
5
- },
6
- };
7
-
8
- export default config;
@@ -1 +0,0 @@
1
- <svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
@@ -1 +0,0 @@
1
- <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -1 +0,0 @@
1
- <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
@@ -1 +0,0 @@
1
- <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
@@ -1,12 +0,0 @@
1
- "use server";
2
-
3
- import { DBOS } from "@dbos-inc/dbos-sdk";
4
- import { dbosWorkflowClass } from "../dbos/operations";
5
-
6
- console.log("Hello from dbosWorkflow.ts");
7
-
8
-
9
- export async function dbosBackgroundTask(workflowID: string) {
10
- DBOS.logger.info("Hello from DBOS!");
11
- return DBOS.startWorkflow(dbosWorkflowClass, {workflowID: workflowID}).backgroundTask(10);
12
- }
@@ -1,15 +0,0 @@
1
- "use server";
2
-
3
- import { DBOS } from "@dbos-inc/dbos-sdk";
4
- import { helloWorkflowClass } from "../dbos/operations";
5
-
6
-
7
- console.log("Hello from hello.ts");
8
-
9
- // The exported function is the entry point for the workflow
10
- // The function is exported and not the class because Next does not support exporting classes
11
- export async function helloWorkflow(userName: string) {
12
- DBOS.logger.info("Hello from DBOS!");
13
- return await helloWorkflowClass.helloDBOS(userName);
14
- }
15
-
@@ -1,8 +0,0 @@
1
-
2
- export async function GET(request: Request) {
3
-
4
- console.log("Received request Crashing the app");
5
-
6
- process.exit(1);
7
-
8
- }
@@ -1,21 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
4
-
5
- :root {
6
- --background: #ffffff;
7
- --foreground: #171717;
8
- }
9
-
10
- @media (prefers-color-scheme: dark) {
11
- :root {
12
- --background: #0a0a0a;
13
- --foreground: #ededed;
14
- }
15
- }
16
-
17
- body {
18
- color: var(--foreground);
19
- background: var(--background);
20
- font-family: Arial, Helvetica, sans-serif;
21
- }
@@ -1,11 +0,0 @@
1
- import { NextResponse } from "next/server";
2
- import { helloWorkflow } from "../../actions/hello";
3
- import { DBOS } from "@dbos-inc/dbos-sdk";
4
-
5
- export async function POST(request: Request) {
6
- const body = await request.json();
7
- const { userName } = body;
8
- DBOS.logger.info(`Received request with name: ${userName}`);
9
- const response = await helloWorkflow(userName);
10
- return NextResponse.json(response);
11
- }