@dbos-inc/create 1.23.4-preview → 1.23.8
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
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
// Welcome to DBOS!
|
|
2
|
+
|
|
3
|
+
// This is a sample "Hello" app built with DBOS.
|
|
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
|
+
|
|
1
7
|
import { HandlerContext, TransactionContext, Transaction, GetApi, ArgSource, ArgSources } from '@dbos-inc/dbos-sdk';
|
|
2
8
|
import { Knex } from 'knex';
|
|
3
9
|
|
|
4
|
-
const app_notes = `
|
|
5
|
-
To learn how to run this app on your computer, visit the
|
|
6
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart" >DBOS Quickstart</a>.<br>
|
|
7
|
-
After that, to learn how to build apps, visit the
|
|
8
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart-programming" >DBOS Programming Guide</a>.`;
|
|
9
|
-
|
|
10
10
|
// The schema of the database table used in this example.
|
|
11
11
|
export interface dbos_hello {
|
|
12
12
|
name: string;
|
|
@@ -15,20 +15,8 @@ export interface dbos_hello {
|
|
|
15
15
|
|
|
16
16
|
export class Hello {
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const readme = `<html><body><p>
|
|
21
|
-
Welcome to the DBOS Hello App!<br><br>
|
|
22
|
-
Visit the route /greeting/:name to be greeted!<br>
|
|
23
|
-
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
24
|
-
The counter increments with each page visit.<br>
|
|
25
|
-
If you visit a new name like <a href="/greeting/alice">/greeting/alice</a>, the counter starts at 1.<br><br>
|
|
26
|
-
${app_notes}
|
|
27
|
-
</p></body></html>`;
|
|
28
|
-
return Promise.resolve(readme);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@GetApi('/greeting/:user') // Serve this function from HTTP GET requests to the /greeting endpoint with 'user' as a path parameter
|
|
18
|
+
// Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
|
|
19
|
+
@GetApi('/greeting/:user')
|
|
32
20
|
@Transaction() // Run this function as a database transaction
|
|
33
21
|
static async helloTransaction(ctxt: TransactionContext<Knex>, @ArgSource(ArgSources.URL) user: string) {
|
|
34
22
|
// Retrieve and increment the number of times this user has been greeted.
|
|
@@ -36,7 +24,41 @@ export class Hello {
|
|
|
36
24
|
const { rows } = await ctxt.client.raw(query, [user]) as { rows: dbos_hello[] };
|
|
37
25
|
const greet_count = rows[0].greet_count;
|
|
38
26
|
const greeting = `Hello, ${user}! You have been greeted ${greet_count} times.`;
|
|
39
|
-
|
|
27
|
+
return Hello.makeHTML(greeting);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Serve a quick readme for the app at the / endpoint
|
|
31
|
+
@GetApi('/')
|
|
32
|
+
static async readme(_ctxt: HandlerContext) {
|
|
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/getting-started/quickstart" 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/getting-started/quickstart-programming" class="text-blue-600 hover:underline">Programming Guide</a>.<br>
|
|
59
|
+
</p>
|
|
60
|
+
</body>
|
|
61
|
+
</html>`;
|
|
40
62
|
return page;
|
|
41
63
|
}
|
|
42
64
|
}
|
|
@@ -1,34 +1,52 @@
|
|
|
1
|
+
// Welcome to DBOS!
|
|
2
|
+
|
|
3
|
+
// This is the Quickstart Drizzle template app. It greets visitors, counting how many total greetings were made.
|
|
4
|
+
// To learn how to run this app, visit the Drizzle tutorial: https://docs.dbos.dev/tutorials/using-drizzle
|
|
5
|
+
|
|
1
6
|
import { HandlerContext, TransactionContext, Transaction, GetApi } from '@dbos-inc/dbos-sdk';
|
|
2
7
|
import { dbosHello } from './schema';
|
|
3
8
|
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
4
9
|
|
|
5
|
-
const app_notes = `
|
|
6
|
-
To learn how to run this app on your computer, visit the
|
|
7
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart" >DBOS Quickstart</a>.<br>
|
|
8
|
-
After that, to learn how to build apps, visit the
|
|
9
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart-programming" >DBOS Programming Guide</a>.`;
|
|
10
|
-
|
|
11
10
|
export class Hello {
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
static async readme(_ctxt: HandlerContext) {
|
|
15
|
-
const readme = `<html><body><p>
|
|
16
|
-
Welcome to the DBOS Hello App!<br><br>
|
|
17
|
-
Visit the route /greeting/:name to be greeted!<br>
|
|
18
|
-
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
19
|
-
The counter increments with each page visit.<br><br>
|
|
20
|
-
${app_notes}
|
|
21
|
-
</p></body></html>`;
|
|
22
|
-
return Promise.resolve(readme);
|
|
23
|
-
}
|
|
24
|
-
|
|
12
|
+
// Serve this function from HTTP GET requests at the /greeting endpoint with 'user' as a path parameter
|
|
25
13
|
@GetApi('/greeting/:user')
|
|
26
14
|
@Transaction()
|
|
27
15
|
static async helloTransaction(ctxt: TransactionContext<NodePgDatabase>, user: string) {
|
|
28
16
|
const greeting = `Hello, ${user}!`;
|
|
29
17
|
const greetings_output = await ctxt.client.insert(dbosHello).values({greeting}).returning({greet_count: dbosHello.greet_count});
|
|
30
18
|
const greeting_message = `${greeting} We have made ${greetings_output[0].greet_count} greetings.`;
|
|
31
|
-
|
|
19
|
+
return Hello.makeHTML(greeting_message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Serve a quick readme for the app at the / endpoint
|
|
23
|
+
@GetApi('/')
|
|
24
|
+
static async readme(_ctxt: HandlerContext) {
|
|
25
|
+
const message = Hello.makeHTML(
|
|
26
|
+
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
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>
|
|
28
|
+
The counter increments with each page visit.`
|
|
29
|
+
);
|
|
30
|
+
return Promise.resolve(message);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// A helper function to create HTML pages with some styling
|
|
34
|
+
static makeHTML(message: string) {
|
|
35
|
+
const page = `
|
|
36
|
+
<!DOCTYPE html>
|
|
37
|
+
<html lang="en">
|
|
38
|
+
<head>
|
|
39
|
+
<title>DBOS Template App</title>
|
|
40
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
41
|
+
</head>
|
|
42
|
+
<body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
|
|
43
|
+
<h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
|
|
44
|
+
<p class="mt-8 mb-8">` + message + `</p>
|
|
45
|
+
<p class="mb-2">
|
|
46
|
+
This is the Drizzle quickstart template app. Read the documentation for it <a href="https://docs.dbos.dev/tutorials/using-drizzle" class="text-blue-600 hover:underline">here</a>.
|
|
47
|
+
</p>
|
|
48
|
+
</body>
|
|
49
|
+
</html>`;
|
|
32
50
|
return page;
|
|
33
51
|
}
|
|
34
52
|
}
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
+
// Welcome to DBOS!
|
|
2
|
+
|
|
3
|
+
// This is the Quickstart Prisma template app. It greets visitors, counting how many total greetings were made.
|
|
4
|
+
// To learn how to run this app, visit the Prisma tutorial: https://docs.dbos.dev/tutorials/using-prisma
|
|
5
|
+
|
|
1
6
|
import { HandlerContext, TransactionContext, Transaction, GetApi } from '@dbos-inc/dbos-sdk';
|
|
2
|
-
import { PrismaClient } from "@prisma/client";
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
To learn how to run this app on your computer, visit the
|
|
6
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart" >DBOS Quickstart</a>.<br>
|
|
7
|
-
After that, to learn how to build apps, visit the
|
|
8
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart-programming" >DBOS Programming Guide</a>.`;
|
|
8
|
+
import { PrismaClient } from "@prisma/client";
|
|
9
9
|
|
|
10
10
|
export class Hello {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
static async readme(_ctxt: HandlerContext) {
|
|
14
|
-
const readme = `<html><body><p>
|
|
15
|
-
Welcome to the DBOS Hello App!<br><br>
|
|
16
|
-
Visit the route /greeting/:name to be greeted!<br>
|
|
17
|
-
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
18
|
-
The counter increments with each page visit.<br><br>
|
|
19
|
-
${app_notes}
|
|
20
|
-
</p></body></html>`;
|
|
21
|
-
return Promise.resolve(readme);
|
|
22
|
-
}
|
|
23
|
-
|
|
12
|
+
// Serve this function from HTTP GET requests at the /greeting endpoint with 'name' as a path parameter
|
|
24
13
|
@GetApi('/greeting/:name')
|
|
25
14
|
@Transaction()
|
|
26
15
|
static async helloTransaction(txnCtxt: TransactionContext<PrismaClient>, name: string) {
|
|
@@ -31,7 +20,37 @@ export class Hello {
|
|
|
31
20
|
},
|
|
32
21
|
});
|
|
33
22
|
const greeting_note = `Greeting ${res.greeting_id}: ${greeting}`;
|
|
34
|
-
|
|
23
|
+
return Hello.makeHTML(greeting_note);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Serve a quick readme for the app at the / endpoint
|
|
27
|
+
@GetApi('/')
|
|
28
|
+
static async readme(_ctxt: HandlerContext) {
|
|
29
|
+
const message = Hello.makeHTML(
|
|
30
|
+
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
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>
|
|
32
|
+
The counter increments with each page visit.`
|
|
33
|
+
);
|
|
34
|
+
return Promise.resolve(message);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// A helper function to create HTML pages with some styling
|
|
38
|
+
static makeHTML(message: string) {
|
|
39
|
+
const page = `
|
|
40
|
+
<!DOCTYPE html>
|
|
41
|
+
<html lang="en">
|
|
42
|
+
<head>
|
|
43
|
+
<title>DBOS Template App</title>
|
|
44
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
45
|
+
</head>
|
|
46
|
+
<body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
|
|
47
|
+
<h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
|
|
48
|
+
<p class="mt-8 mb-8">` + message + `</p>
|
|
49
|
+
<p class="mb-2">
|
|
50
|
+
This is the Prisma quickstart template app. Read the documentation for it <a href="https://docs.dbos.dev/tutorials/using-prisma" class="text-blue-600 hover:underline">here</a>.
|
|
51
|
+
</p>
|
|
52
|
+
</body>
|
|
53
|
+
</html>`;
|
|
35
54
|
return page;
|
|
36
55
|
}
|
|
37
56
|
}
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
+
// Welcome to DBOS!
|
|
2
|
+
|
|
3
|
+
// This is the Quickstart TypeORM template app. It greets visitors, counting how many total greetings were made.
|
|
4
|
+
// To learn how to run this app, visit the TypeORM tutorial: https://docs.dbos.dev/tutorials/using-typeorm
|
|
5
|
+
|
|
1
6
|
import { HandlerContext, TransactionContext, Transaction, GetApi, OrmEntities } from '@dbos-inc/dbos-sdk';
|
|
2
7
|
import { EntityManager } from "typeorm";
|
|
3
8
|
import { DBOSHello } from '../entities/DBOSHello';
|
|
4
9
|
|
|
5
|
-
const app_notes = `
|
|
6
|
-
To learn how to run this app on your computer, visit the
|
|
7
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart" >DBOS Quickstart</a>.<br>
|
|
8
|
-
After that, to learn how to build apps, visit the
|
|
9
|
-
<a href="https://docs.dbos.dev/getting-started/quickstart-programming" >DBOS Programming Guide</a>.`;
|
|
10
|
-
|
|
11
10
|
@OrmEntities([DBOSHello])
|
|
12
11
|
export class Hello {
|
|
13
12
|
|
|
14
|
-
@GetApi('/') // Serve a quick readme for the app
|
|
15
|
-
static async readme(_ctxt: HandlerContext) {
|
|
16
|
-
const readme = `<html><body><p>
|
|
17
|
-
Welcome to the DBOS Hello App!<br><br>
|
|
18
|
-
Visit the route /greeting/:name to be greeted!<br>
|
|
19
|
-
For example, visit <a href="/greeting/dbos">/greeting/dbos</a>.<br>
|
|
20
|
-
The counter increments with each page visit.<br><br>
|
|
21
|
-
${app_notes}
|
|
22
|
-
</p></body></html>`;
|
|
23
|
-
return Promise.resolve(readme);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
13
|
@GetApi('/greeting/:name')
|
|
27
14
|
@Transaction()
|
|
28
15
|
static async helloTransaction(txnCtxt: TransactionContext<EntityManager>, name: string) {
|
|
@@ -31,7 +18,37 @@ export class Hello {
|
|
|
31
18
|
entity.greeting = greeting;
|
|
32
19
|
entity = await txnCtxt.client.save(entity);
|
|
33
20
|
const greeting_note = `Greeting ${entity.greeting_id}: ${greeting}`;
|
|
34
|
-
|
|
21
|
+
return Hello.makeHTML(greeting_note);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Serve a quick readme for the app at the / endpoint
|
|
25
|
+
@GetApi('/')
|
|
26
|
+
static async readme(_ctxt: HandlerContext) {
|
|
27
|
+
const message = Hello.makeHTML(
|
|
28
|
+
`Visit the route <code class="bg-gray-100 px-1 rounded">/greeting/{name}</code> to be greeted!<br>
|
|
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>
|
|
30
|
+
The counter increments with each page visit.`
|
|
31
|
+
);
|
|
32
|
+
return Promise.resolve(message);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// A helper function to create HTML pages with some styling
|
|
36
|
+
static makeHTML(message: string) {
|
|
37
|
+
const page = `
|
|
38
|
+
<!DOCTYPE html>
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<head>
|
|
41
|
+
<title>DBOS Template App</title>
|
|
42
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
43
|
+
</head>
|
|
44
|
+
<body class="font-sans text-gray-800 p-6 max-w-2xl mx-auto">
|
|
45
|
+
<h1 class="text-3xl font-semibold mb-4">Welcome to DBOS!</h1>
|
|
46
|
+
<p class="mt-8 mb-8">` + message + `</p>
|
|
47
|
+
<p class="mb-2">
|
|
48
|
+
This is the TypeORM quickstart template app. Read the documentation for it <a href="https://docs.dbos.dev/tutorials/using-typeorm" class="text-blue-600 hover:underline">here</a>.
|
|
49
|
+
</p>
|
|
50
|
+
</body>
|
|
51
|
+
</html>`;
|
|
35
52
|
return page;
|
|
36
53
|
}
|
|
37
54
|
}
|